Skip to content

Commit

Permalink
NN-391 Implement the graph/pathway selection menu
Browse files Browse the repository at this point in the history
  • Loading branch information
TripZz committed Nov 26, 2023
1 parent 259221c commit 801ffec
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 134 deletions.
2 changes: 2 additions & 0 deletions frontend/src/components/enrichment/PathwayTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</div>
<div class="graph-section">
<PathwayGraph v-show="tool == 'Termgraph'"
:mode = 'mode'
:gephi_data='gephi_data'
:filtered_terms = 'filtered_terms'
:bookmark_off = 'bookmark_off'
Expand Down Expand Up @@ -52,6 +53,7 @@ export default {
favourite_graphs: new Set(),
bookmark_off: true,
tool_selecting: false,
mode: 'protein',
tools: [{id: 'Termgraph'}, {id: 'Heatmap'}]
}
},
Expand Down
42 changes: 26 additions & 16 deletions frontend/src/components/enrichment/graph/PathwayGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div v-for="(entry, index) in filt_graphs" :key="index" class="graph" v-on:click="switch_graph(entry)" @mouseover="activeGraphIndex = index" @mouseout="activeGraphIndex = -1">
<SnapshotGraph :propValue="entry" :index="entry.id"/>
<div class="graph-options" v-show="activeGraphIndex == index" >
<div class="bookmark-graph" v-on:click.stop="add_graph(entry)" :class="{ checked: favourite_graphs.has(entry)}" ref="checkboxStatesGraph"></div>
<div class="bookmark-graph" v-on:click.stop="add_graph(entry)" :class="{ checked: favourite_graphs.has(entry.id)}" ref="checkboxStatesGraph"></div>
<img class="remove-graph" src="@/assets/pathwaybar/cross.png" v-on:click.stop="remove_graph(entry)">
<div class="graph-name">
<input type="text" v-model="entry.label" class="empty" @click.stop />
Expand All @@ -19,7 +19,7 @@ import SnapshotGraph from '@/components/enrichment/graph/SnapshotGraph.vue'
export default {
name: 'PathwayGraphs',
props: ['gephi_data','filtered_terms', 'bookmark_off'],
props: ['gephi_data','filtered_terms', 'bookmark_off','mode'],
components: {
SnapshotGraph,
},
Expand All @@ -31,13 +31,20 @@ export default {
term_graphs: new Set(),
favourite_graphs: new Set(),
activeGraphIndex: -1,
graph_number: 0,
graph_number: -1,
species: null
}
},
mounted(){
this.emitter.on("generateGraph", (set) => {
this.get_term_data(set)
});
if(this.mode !='term') {
this.emitter.on("generateGraph", (set) => {
this.get_term_data(set)
});
}
},
activated(){
this.term_graphs = new Set(this.$store.state.term_graph_dict)
this.favourite_graphs = this.$store.state.favourite_graph_dict
},
methods: {
get_term_data(set) {
Expand All @@ -54,32 +61,35 @@ export default {
if(response.data){
this.graph_number += 1
if(this.term_graphs.size < 1) this.$store.commit('assign_term_graph', response.data)
this.$store.commit('assign_new_term_graph', {label: `Graph ${this.graph_number}`, graph: response.data})
this.$store.commit('assign_new_term_graph', {id: this.graph_number, label: `Graph ${this.graph_number}`, graph: response.data})
this.term_graphs.add({ id: this.graph_number, label: `Graph ${this.graph_number}`, graph: response.data});
}
})
},
switch_graph(entry) {
this.$store.commit('assign_term_graph', entry.graph)
this.$router.push("terms")
if(this.mode == 'term') this.emitter.emit('graphChanged')
else this.$router.push("terms")
},
remove_graph(entry) {
if (!this.favourite_graphs.has(entry)) {
if (!this.favourite_graphs.has(entry.id)) {
// Checkbox is checked, add its state to the object
this.favourite_graphs.delete(entry)
this.favourite_graphs.delete(entry.id)
this.$store.commit('assign_favourite_graph', this.favourite_graphs)
}
this.term_graphs.delete(entry)
this.$store.commit('remove_snapshotPathway', entry.id)
this.$store.commit('remove_term_graph', entry)
},
add_graph(entry){
if (!this.favourite_graphs.has(entry)) {
// Checkbox is checked, add its state to the object
this.favourite_graphs.add(entry)
if (!this.favourite_graphs.has(entry.id)) {
this.favourite_graphs.add(entry.id)
} else {
// Checkbox is unchecked, remove its state from the object
this.favourite_graphs.delete(entry)
this.favourite_graphs.delete(entry.id)
}
this.$store.commit('assign_favourite_graph', this.favourite_graphs)
},
},
computed: {
Expand All @@ -89,7 +99,7 @@ export default {
if (!com.bookmark_off){
filtered = filtered.filter(function(term) {
return com.favourite_graphs.has(term)
return com.favourite_graphs.has(term.id)
});
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/enrichment/graph/SnapshotGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default {
updated(){
if(this.findSnapshot()) this.initializeSnapshot(this.findSnapshot().snapshot)
},
activated(){
if(this.findSnapshot()) this.initializeSnapshot(this.findSnapshot().snapshot)
},
mounted(){
if(!this.findSnapshot()) this.initializeSnapshot(this.getSnapshot(this.propValue.graph))
else this.initializeSnapshot(this.findSnapshot().snapshot)
Expand Down
70 changes: 7 additions & 63 deletions frontend/src/components/pathwaytools/PathwayGraphGraphs.vue
Original file line number Diff line number Diff line change
@@ -1,96 +1,40 @@
<template>
<div id="pathways-graphs">
<div id="pathway-tools-filter" v-on:click="handling_filter_menu()" >
<span>{{ tool }}</span>s
</div>
<div id="pathway-tools-filter-categories" v-show="tool_selecting== true">
<div class="element" v-for="(entry, index) in tools" :key="index" v-on:click="tool = entry.id; handling_filter_menu()">
<a>{{ entry.id }}</a>
</div>
</div>
<div class="generate" v-show="tool == 'Termgraph'">
<div class="generate-text" v-on:click="get_term_graph()">Generate term graph</div>
</div>
<div class="generate" v-show="tool == 'Heatmap'">
<div class="generate-text" v-on:click="get_heatmap()">Generate heatmap</div>
</div>
<div class="bookmark-button-graph" v-on:click="bookmark_off = !bookmark_off">
<img class="bookmark-image" src="@/assets/pathwaybar/favorite.png" :class="{recolor_filter: bookmark_off == false}">
</div>
<div class="export-heatmap" v-show="tool == 'Heatmap'">
<div class="generate-text" v-on:click="get_svg()">Export Snapshot</div>
<div id="pathway-tools-filter">
<span>{{ tool }}</span>
</div>
<div class="graph-section">
<PathwayGraph v-show="tool == 'Termgraph'"
:gephi_data='gephi_data'
:term_data='term_data'
:mode = 'mode'
:filtered_terms = 'filtered_terms'
:bookmark_off = 'bookmark_off'
></PathwayGraph>
<PathwayHeatmap v-show="tool == 'Heatmap'"
:bookmark_off = 'bookmark_off'
:favourite_pathways = 'favourite_pathways'
></PathwayHeatmap>
</div>
</div>
</template>

<script>
import PathwayGraph from '@/components/enrichment/graph/PathwayGraph.vue'
import PathwayHeatmap from '@/components/enrichment/heatmap/PathwayHeatmap.vue'
export default {
name: 'PathwayGraphGraphs',
props: ['gephi_data','filtered_terms', 'favourite_pathways'],
props: ['term_data','filtered_terms'],
components: {
PathwayGraph,
PathwayHeatmap
},
data() {
return {
tool: 'Termgraph',
favourite_graphs: new Set(),
bookmark_off: true,
tool_selecting: false,
tools: [{id: 'Termgraph'}, {id: 'Heatmap'}]
mode: 'term',
tools: [{id: 'Termgraph'}]
}
},
methods: {
get_term_graph(){
this.emitter.emit("generateGraph");
},
get_heatmap(){
this.emitter.emit("generateHeatmap");
},
get_svg(){
this.emitter.emit("exportHeatmap");
},
handling_filter_menu() {
var com = this;
if (!com.tool_selecting) {
com.tool_selecting = true;
// Add the event listener
document.addEventListener('mouseup', com.handleMouseUp);
}
else{
com.tool_selecting = false;
document.removeEventListener('mouseup', com.handleMouseUp);
}
},
handleMouseUp(e) {
var com = this;
var container = document.getElementById('pathway-tools-filter-categories');
var container_button = document.getElementById('pathway-tools-filter');
if (!container.contains(e.target) && !container_button.contains(e.target)) {
com.tool_selecting = false;
// Remove the event listener
document.removeEventListener('mouseup', com.handleMouseUp);
}
}
},
}
</script>
Expand Down
48 changes: 8 additions & 40 deletions frontend/src/components/pathwaytools/PathwayGraphMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,34 @@
<div class="pathwaybar" v-show="pane_hidden === false">
<PathwayGraphList
:term_data='term_data'
:terms='terms'
:await_load = 'await_load'
@favourite_pathways_changed = 'favourite_pathways = $event'
@filtered_terms_changed = 'filtered_terms = $event'
></PathwayGraphList>
<PathwayGraphGraphs
:gephi_data='gephi_data'
:filtered_terms='filtered_terms'
:favourite_pathways='favourite_pathways'
></PathwayGraphGraphs>
<img id="pathway-bg" src="@/assets/pathwaybar/background-dna.png">
</div>
</div>
</template>

<script>
import PathwayGraphList from '@/components/pathwaytools/PathwayGraphList.vue'
import PathwayGraphGraphs from '@/components/pathwaytools/PathwayGraphGraphs.vue'
export default {
name: 'PathwayMenu',
props: ['term_data','active_term'],
components: {
PathwayGraphList,
PathwayGraphGraphs
},
data() {
return {
api: {
subgraph: "api/subgraph/enrichment",
},
terms: null,
pane_hidden: false,
await_load: false,
terms_list: [],
favourite_pathways: [],
filtered_terms: []
}
},
methods: {
generatePathways(species, genes){
var com = this
//Adding proteins and species to formdata
var formData = new FormData()
formData.append('genes', genes)
formData.append('species_id', species);
this.await_load = true
//POST request for generating pathways
com.sourceToken = this.axios.CancelToken.source();
com.axios
.post(com.api.subgraph, formData, { cancelToken: com.sourceToken.token })
.then((response) => {
com.terms = response.data.sort((t1, t2) => t1.fdr_rate - t2.fdr_rate)
if (com.terms_list.length == 0) this.$store.commit('assign_current_enrichment_terms', com.terms)
com.terms_list.push(com.terms)
com.await_load = false
this.emitter.emit("generateGraph", com.terms);
})
},
abort_enrichment() {
this.sourceToken.cancel('Request canceled');
this.await_load = false
},
mounted() {
},
}
</script>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const store = createStore({
test_sample: "Gnai3;Klf6;Xpo6;Gmpr;Trim25;Tbrg4;Mx1;Pdgfb;Zfp385a;Gpcr2;Clcn4-2;Myo18a;Heatr6;Ccl3;Nhp2;Poldip2;Ckb;Smg5;Tubb5;Ell2;Ergic1;Brpf1;Ubl3;Il16;Tcirg1;Rtcb;Rac1;Nfix;Blvra;Celf2;Sf3a1;Ppard;Daxx;Ipo4;Ccdc97;Lcp2;Cse1l;Il17ra;Pnkp;Apoe;Hbp1;Klf4;Ap1m1;Ppp5c;Hck;Keap1;Prkcsh;Ier3;Klc4;Man1a;Nfat5;Stat3;Psap;Ptpn6;Coro1c;Arhgef40;Chn2;Arid3b;Ly9;Cd244;Emr1;Ulk2;Grap;Dtx2;Prkacb;Cstb;Wdr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Nadk;Gnb1;Lrpap1;Rnf4;Slc35f6;Tbc1d14;Commd8;Tec;Srd5a3;Aff1;Coq2;Hnrnpdl;Cds1;Ccng2;Rilpl1;Naaa;Slc15a4;Scarb2;Atp2a2;P2rx4;Kdm2b;Ncor2;Sppl3;Psmg3;Tes;Lfng;Tmem106b;Wipi2;Aimp2;Arpc1b;Phf14;Pomp;Cux1;Tsc22d4;Pon3;Exoc4;Tmem176b;Zc3hav1;Zyx;Clec5a;Hpgds;Mkrn1;Tbxas1;Pcyox1;Arhgap25;Cnbp;Foxp1;Arl8b;Ptms;Etv6;Dusp16;Atf7ip;Wbp11;Arhgdib;Ptpro;Strap;Ldhb;Camk1;Itpr2;Cd9;Vasp;Cyfip1;Siglece;Tjp1;Furin;Mef2a;Ctsc;Tyrobp;Nfkbib;Zfand6;Anapc15;Ipo5;Mvp;Fchsd2;Slco2b1;Il21r;Il4ra;Arhgap17;Pak1;Cd37;Stx4a;Rgs10;Mrpl17;Fam53b;Ctbp2;ENSMUSG00000030982;Cask;St5;Slc9a9;Msn;Ophn1;Efnb1;Phka2",
highlighted_edges: new Set(),
snapshot_pathways: [],
favourite_graph_dict: new Set(),
snapshot_heatmaps: [],
node_cluster_index: {},
node_modul_index: new Set(),
Expand Down Expand Up @@ -62,6 +63,13 @@ export const store = createStore({
assign_new_term_graph(state, value) {
state.term_graph_dict.push(value)
},
remove_term_graph(state, value) {
const index = state.term_graph_dict.indexOf(value)
state.term_graph_dict.splice(index,1)
},
assign_favourite_graph(state, value) {
state.favourite_graph_dict = value
},
assign_highlightedSet(state, value) {
state.highlighted_edges = value
},
Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/ProteinView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default {
const term = this.$store.state.enrichment
const all_terms = this.$store.state.current_enrichment_terms
console.log(all_terms)
if(term != null){
for (var idx in all_terms) {
var node = all_terms[idx];
Expand Down
36 changes: 22 additions & 14 deletions frontend/src/views/TermView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,7 @@ export default {
},
activated() {
this.term_data = this.$store.state.term_graph_data
const term_node = this.$store.state.active_node_enrichment
if(term_node != null){
console.log(this.term_data)
for (var idx in this.term_data.nodes) {
var node = this.term_data.nodes[idx];
if(node.attributes["Ensembl ID"] == term_node.id){
this.active_node = this.term_data.nodes[idx]
}
}
this.$store.commit('assign_active_enrichment_node', null)
}
this.change_graph()
},
mounted() {
const com = this;
Expand Down Expand Up @@ -181,6 +168,27 @@ export default {
const maingraph = new Set(com.term_data.subgraph)
com.unconnected_nodes = com.term_data.nodes.filter(item => !maingraph.has(item.id));
this.emitter.on("graphChanged", () => {
this.change_graph()
});
},
methods:{
change_graph(){
this.term_data = this.$store.state.term_graph_data
const term_node = this.$store.state.active_node_enrichment
if(term_node != null){
for (var idx in this.term_data.nodes) {
var node = this.term_data.nodes[idx];
if(node.attributes["Ensembl ID"] == term_node.id){
this.active_node = this.term_data.nodes[idx]
}
}
this.$store.commit('assign_active_enrichment_node', null)
}
}
}
}
</script>
Expand Down

0 comments on commit 801ffec

Please sign in to comment.