Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pigean empty gene #809

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
};
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
Loading