Skip to content

Commit

Permalink
Added p-values to geneset table (#763)
Browse files Browse the repository at this point in the history
* Added p-values to geneset table

* passing gene sets parameter
  • Loading branch information
moriondo2022 authored Oct 23, 2024
1 parent 82d0f79 commit faf12e3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/views/Factorization/Template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Gene Sets
</div>
<select class="form-control"
:v-model="$parent.genesetParam"
v-model="$parent.genesetParam"
>
<option v-for=" o in $store.state.genesetOptions"
:value="o">
Expand Down
23 changes: 21 additions & 2 deletions src/views/Factorization/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ new Vue({
],
extraGenesetFields: [
{
key: "gene_Set",
key: "gene_set",
label: "Gene set",
sortable: true
},
{
key: "p_value",
label: "P-value",
formatter: Formatters.pValueFormatter,
sortable: true
}
],
extraGeneFields: [
Expand Down Expand Up @@ -162,13 +168,22 @@ new Vue({
},
genesetFactor() {
let data = this.flatData(this.$store.state.genesetFactor);
data.forEach(item => item["p_value"] = this.pValueLookup[item.gene_set]);
return this.formatLabels(data);
},
genesetFields(){
return this.baseFields.concat(this.extraGenesetFields);
},
geneFields(){
return this.baseFields.concat(this.extraGeneFields);
},
pValueLookup(){
let pValueList = this.$store.state.genesetPValues;
let lookup = {};
pValueList.forEach(item =>
lookup[item.gene_set] = item.p_value
);
return lookup;
}
},
watch: {
Expand All @@ -188,7 +203,11 @@ new Vue({
if (this.geneInput) {
let genes = this.geneInput.trim().split(/[\n, ]+/);
let geneSets = this.genesetParam;
this.$store.dispatch("queryBayesGenes", genes, geneSets);
let queryString = JSON.stringify({
"genes": genes,
"gene_sets": geneSets
});
this.$store.dispatch("queryBayesGenes", queryString);
}
},
flatData(data){
Expand Down
20 changes: 10 additions & 10 deletions src/views/Factorization/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default new Vuex.Store({
genesetFactor: [],
roundTripInputGenes: [],
genesetOptions: [],
genesetPValues: [],
},

mutations: {
Expand All @@ -37,40 +38,39 @@ export default new Vuex.Store({
state.roundTripInputGenes = data || state.roundTripInputGenes;
},
setGenesetOptions(state, data){
state.genesetOptions = data || state.genesetOptions
state.genesetOptions = data || state.genesetOptions;
},
setGenesetPValues(state, data){
state.genesetPValues = data || state.genesetPValues;
},
clearAllData(state){
state.pigeanFactor = [];
state.geneFactor = [];
state.genesetFactor = [];
state.roundTripInputGenes = [];
state.genesetPValues = [];
}
},

getters: {
},

actions: {
async queryBayesGenes(context, genesList, geneSets){
async queryBayesGenes(context, queryString){
context.commit("clearAllData");
let address = "https://translator.broadinstitute.org/genetics_provider/bayes_gene/pigean";
let genesQuery = JSON.stringify(
{
"genes": genesList,
"gene_sets": geneSets,
}
);
let json = await fetch(address, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: genesQuery
body: queryString
}).then(resp => resp.json());
context.commit("setRoundTripInputGenes", json.input_genes);
context.commit("setPigeanFactor", json["pigean-factor"].data);
context.commit("setGeneFactor", json["gene-factor"]);
context.commit("setGenesetFactor", json["gene-set-factor"]);
context.commit("setGenesetPValues", json["gene_sets"]);
},
async queryGenesetOptions(context){
let address = "https://translator.broadinstitute.org/genetics_provider/bayes_gene/heartbeat";
Expand All @@ -81,6 +81,6 @@ export default new Vuex.Store({
}
}).then(resp => resp.json());
context.commit("setGenesetOptions", json.gene_sets);
}
},
},
});

0 comments on commit faf12e3

Please sign in to comment.