Skip to content

Commit

Permalink
Pigean geneset fix (#811)
Browse files Browse the repository at this point in the history
* fixes issue where empty genes do not display but instead leave preexisting data

* working toward a geneset page for all traits

* remove superfluous console log

* bioindex util constant for the list of all trait groups

* correct autocomplete options

* gene and geneset single search
  • Loading branch information
moriondo2022 authored Dec 11, 2024
1 parent 60d0722 commit 0038f34
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 22 deletions.
4 changes: 3 additions & 1 deletion src/utils/bioIndexUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ async function processRequest(req, onResolve, onError, onLoad, limitWhile) {
export const DEFAULT_SIGMA = 2;
export const DEFAULT_GENESET_SIZE = "small";
export const DEFAULT_TRAIT_GROUP = "all";
export const TRAIT_GROUPS = ["portal", "gcat_trait", "rare_v2"];

export default {
query,
Expand All @@ -152,5 +153,6 @@ export default {
BIO_INDEX_HOST_PRIVATE,
DEFAULT_SIGMA,
DEFAULT_GENESET_SIZE,
DEFAULT_TRAIT_GROUP
DEFAULT_TRAIT_GROUP,
TRAIT_GROUPS
};
2 changes: 1 addition & 1 deletion src/views/PIGEAN/Gene/Template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
:field="'phenotype'"
placeholder="Select a phenotype ..."
:options="
$store.state.pigeanGene.data.map(
$parent.phewasAllData.map(
(d) => d.phenotype
)
"
Expand Down
8 changes: 4 additions & 4 deletions src/views/PIGEAN/Gene/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default new Vuex.Store({
state.aliasName = aliasName || state.aliasName;
},
setPhewasData(state, phewasData){
state.phewasData = phewasData || state.phewasData;
state.phewasData = phewasData;
}
},

Expand Down Expand Up @@ -77,6 +77,7 @@ export default new Vuex.Store({

actions: {
async queryGeneName(context, symbol) {
await context.commit("setPhewasData", []);
let name = context.state.geneToQuery || context.state.geneName;
let genesetSize = context.state.genesetSizeToQuery || context.state.genesetSize;
let traitGroup = context.state.traitGroupToQuery || context.state.traitGroup;
Expand All @@ -91,10 +92,9 @@ export default new Vuex.Store({
context.commit("setPhewasData", context.state.pigeanGene.data);
} else {
// If ALL is selected, query all trait groups and get top results across all
const TRAIT_GROUPS = ["portal", "gcat_trait", "rare_v2"];
let traitsData = [];
for (let i = 0; i < TRAIT_GROUPS.length; i++){
let group = TRAIT_GROUPS[i];
for (let i = 0; i < bioIndexUtils.TRAIT_GROUPS.length; i++){
let group = bioIndexUtils.TRAIT_GROUPS[i];
let traitQuery = `${group},${context.state.geneName},${
bioIndexUtils.DEFAULT_SIGMA},${context.state.genesetSize}`;
let groupData = await bioIndexUtils.query("pigean-gene", traitQuery);
Expand Down
10 changes: 3 additions & 7 deletions src/views/PIGEAN/GeneSet/Template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
:field="'phenotype'"
placeholder="Select a phenotype ..."
:options="
$store.state.pigeanGeneset.data.map(
$parent.phewasAllData.map(
(d) => d.phenotype
)
"
Expand Down Expand Up @@ -130,9 +130,7 @@
<div class="col-md-4">
<pigean-plot
v-if="$parent.plotReady"
:pigean-data="
$store.state.pigeanGeneset.data
"
:pigean-data="$parent.phewasAllData"
:config="$parent.pigeanPlotConfig"
:phenotype-map="$parent.pigeanMap"
:filter="filter"
Expand All @@ -142,9 +140,7 @@
<div class="card-body pigean-table">
<pigean-table
v-if="$parent.plotReady"
:pigean-data="
$store.state.pigeanGeneset.data
"
:pigean-data="$parent.phewasAllData"
:phenotype-map="$parent.pigeanMap"
:config="$parent.tableConfig"
:filter="filter"
Expand Down
9 changes: 5 additions & 4 deletions src/views/PIGEAN/GeneSet/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ new Vue({
},
plotReady() {
return (
this.$store.state.pigeanGeneset.data.length > 0 &&
this.phewasAllData.length > 0 &&
Object.keys(this.pigeanPhenotypeMap).length > 0
);
},
phewasAdjustedData() {
let adjustedData = JSON.parse(
JSON.stringify(this.$store.state.pigeanGeneset.data)
); // Deep copy
let adjustedData = structuredClone(this.phewasAllData);
for (let i = 0; i < adjustedData.length; i++) {
if (adjustedData[i].beta_uncorrected < 0) {
adjustedData[i].beta_uncorrected = 0;
Expand All @@ -142,6 +140,9 @@ new Vue({
},
pigeanMap(){
return this.pigeanPhenotypeMap;
},
phewasAllData(){
return this.$store.state.phewasData;
}
},
watch: {
Expand Down
24 changes: 21 additions & 3 deletions src/views/PIGEAN/GeneSet/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default new Vuex.Store({
aliasName: null,
traitGroup: keyParams.traitGroup || bioIndexUtils.DEFAULT_TRAIT_GROUP,
traitGroupToQuery: null,
phewasData: [],
},

mutations: {
Expand All @@ -39,23 +40,40 @@ export default new Vuex.Store({
state.traitGroup = traitGroup || state.traitGroup;
keyParams.set({ traitGroup: state.traitGroup });
},
setPhewasData(state, phewasData){
state.phewasData = phewasData;
}
},

getters: {
},

actions: {
async queryGeneset(context, symbol) {
await context.commit("setPhewasData", []);
let name = context.state.genesetToQuery || context.state.geneset;
let genesetSize = context.state.genesetSizeToQuery || context.state.genesetSize;
let traitGroup = context.state.traitGroupToQuery || context.state.traitGroup;
context.commit("setGeneset", name);
context.commit("setGenesetSize", genesetSize);
context.commit("setTraitGroup", traitGroup);

if (!!name) {
context.dispatch("pigeanGeneset/query", { q:
`${traitGroup},${name},${bioIndexUtils.DEFAULT_SIGMA},${genesetSize}` });
if (traitGroup !== 'all'){
await context.dispatch("pigeanGeneset/query", { q:
`${traitGroup},${name},${bioIndexUtils.DEFAULT_SIGMA},${genesetSize}`});
context.commit("setPhewasData", context.state.pigeanGeneset.data);
} else {
// If ALL is selected, query all trait groups and get top results across all
let traitsData = [];
for (let i = 0; i < bioIndexUtils.TRAIT_GROUPS.length; i++){
let group = bioIndexUtils.TRAIT_GROUPS[i];
let traitQuery = `${group},${name},${
bioIndexUtils.DEFAULT_SIGMA},${genesetSize}`;
let groupData = await bioIndexUtils.query("pigean-gene-set", traitQuery);
traitsData = traitsData.concat(groupData);
}
traitsData = traitsData.sort((a,b) => b.combined - a.combined);
context.commit("setPhewasData", traitsData.slice(0,1500));
}
},
async getPigeanPhenotypes(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/views/PIGEAN/Index/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ new Vue({
parameter: "gene",
"data point": {
type: "api",
url: `${BIO_INDEX_HOST}/api/bio/keys/pigean-gene/3?columns=gene`,
url: `${BIO_INDEX_HOST}/api/bio/keys/pigean-gene/4?columns=gene`,
"data type": "json",
"data wrapper": ["keys"],
},
Expand All @@ -82,7 +82,7 @@ new Vue({
parameter: "geneset",
"data point": {
type: "api",
url: `${BIO_INDEX_HOST}/api/bio/keys/pigean-gene-set/3?columns=gene_set`,
url: `${BIO_INDEX_HOST}/api/bio/keys/pigean-gene-set/4?columns=gene_set`,
"data type": "json",
"data wrapper": ["keys"],
},
Expand Down

0 comments on commit 0038f34

Please sign in to comment.