11<template >
2- <div id =" bulk-table" :class = " isSubtable ? 'bulk-subtable' : '' " >
2+ <div id =" bulk-table" >
33 <div >
44 <div >
55 </div >
6- <div v-if = " !isSubtable " class =" text-right mb-2" >
6+ <div class =" text-right mb-2" >
77 <data-download
88 :data =" bulkData"
99 filename =" bulk_gene"
1010 ></data-download >
1111 </div >
1212 <div class =" show-inline" >
1313 <div class =" table-total-rows" >Total rows:{{ rows }}</div >
14- <b-form-radio-group v-if = " !isSubtable " class =" show-inline"
14+ <b-form-radio-group class =" show-inline"
1515 v-model =" showGenes" >
1616 <b-form-radio
1717 value =" " >
1818 All genes
1919 </b-form-radio >
2020 <b-form-radio
2121 :value =" up" >
22+ <span class =" upregulated" >█ ; </span >
2223 Upregulated only
2324 </b-form-radio >
2425 <b-form-radio
2526 :value =" down" >
27+ <span class =" downregulated" >█ ; </span >
2628 Downregulated only
2729 </b-form-radio >
2830 </b-form-radio-group >
2931 </div >
3032 <div v-if =" tableData.length > 0" >
3133 <b-table v-model =" currentData"
32- :hover =" isSubtable "
34+ :hover =" false "
3335 small
3436 responsive =" sm"
3537 :items =" tableData"
3638 :fields =" config.fields"
3739 :per-page =" perPage"
3840 :current-page =" currentPage"
3941 :tbody-tr-class =" rowClasses"
42+ :sort-by.sync =" sortField"
43+ :sort-desc.sync =" sortDesc"
4044 >
4145 <template #cell (gene)="r">
42- <!-- Link to where? -->
43- <a :href =' `/gene.html?gene=${r.item.gene}`' >
44- {{ r.item.gene }}
45- </a >
46+ <button class =" invisible-button" @click =" findGene(r.item.gene)" >{{ r.item.gene }}</button >
4647 </template >
47- <template #cell (expand)="row">
48- <b-button
49- variant =" outline-primary"
50- size =" sm"
51- @click =" showDetails(row, 1)"
52- >
53- {{ row.detailsShowing ? "Hide" : "Show" }}
54- </b-button >
55- </template >
56- <template #row-details =" row " >
57- <div class =" subtable-all" v-if ="
58- subtableData[subtableKey(row.item)]?.length > 0"
59- >
60- <div class =" row subtable-selectors" >
61- <div class =" col-md-1" ></div >
62- <div class =" col-md-4" >
63- <div class =" label" >View data by categorical field.</div >
64- <select v-model =" catField" >
65- <option v-for =" field in
66- subtableFields[subtableKey(row.item)].filter(f => f.isCat)"
67- :value =" field" >
68- {{ field.label }}
69- </option >
70- </select >
71- </div >
72- <div class =" col-md-2" ></div >
73- <div class =" col-md-4" >
74-
75- <div class =" label" >View data by continuous field.</div >
76- <select v-model =" contField" >
77- <option v-for =" field in
78- subtableFields[subtableKey(row.item)].filter(f => f.isNumerical)"
79- :value =" field" >
80- {{ field.label }}
81- </option >
82- </select >
83- </div >
84- <div class =" col-md-1" ></div >
85- </div >
86- <div class =" row subtable-plots" >
87- <div class =" col-md-6" >
88- <bulk-violin-plot
89- v-if =" catFields.length > 0"
90- :data =" subtableData[subtableKey(row.item)]"
91- :gene =" row.item.gene"
92- :xField =" catField?.key || catFields[0].key"
93- :xLabel =" catField?.label || catFields[0].label"
94- />
95- <div v-else class =" no-fields" >
96- No categorical fields available for this dataset.
97- </div >
98- </div >
99- <div class =" col-md-6" >
100- <scatterplot
101- v-if =" contFields.length > 0"
102- :plotData =" subtableData[subtableKey(row.item)]"
103- :config =" scatterConfig"
104- :plotId =" `bulk_${row.item.gene}`"
105- :hideDownload =" true"
106- :tightenLeft =" true" >
107- </scatterplot >
108- <div v-else class =" no-fields" >
109- No continuous fields available for this dataset.</div >
110- </div >
111- </div >
112- <bulk-table
113- :bulkData =" subtableData[subtableKey(row.item)]"
114- :config =" {fields : subtableFields[subtableKey(row.item)]}"
115- :isSubtable =" true"
116- >
117- </bulk-table >
118- </div >
119-
120- </template >
121- </b-table >
48+ </b-table >
12249 <b-pagination
12350 v-model =" currentPage"
12451 class =" pagination-sm justify-content-center"
@@ -156,7 +83,6 @@ export default Vue.component("bulk-table", {
15683 props: [
15784 " bulkData" ,
15885 " config" ,
159- " isSubtable" ,
16086 " filter" ,
16187 " dataset" ,
16288 " highlightedGene" ,
@@ -176,15 +102,16 @@ export default Vue.component("bulk-table", {
176102 currentData: [],
177103 tableYField: " -log10P" ,
178104 tableXField: " logFoldChange" ,
105+ sortField: " absoluteFoldChange" ,
106+ sortDesc: true ,
179107 up: " upregulated" ,
180108 down: " downregulated"
181109 };
182110 },
183111 async mounted (){
184- if (this .isSubtable ){
185- return ;
112+ if (this .highlightedGene !== " " ){
113+ await this . findGene ( this . highlightedGene );
186114 }
187- await this .findGene (this .highlightedGene );
188115 this .$emit (" upGenes" , this .upregulatedGenes );
189116 this .$emit (" downGenes" , this .downregulatedGenes );
190117 },
@@ -229,7 +156,7 @@ export default Vue.component("bulk-table", {
229156 if (this .filter ) {
230157 data = data .filter (this .filter );
231158 }
232- if (!! this .showGenes && ! this . isSubtable ){
159+ if (!! this .showGenes ){
233160 data = data .filter (item => this .showRegulation (item) === this .showGenes );
234161 }
235162 return data;
@@ -257,9 +184,6 @@ export default Vue.component("bulk-table", {
257184 tissueFormatter: Formatters .tissueFormatter ,
258185 tpmFormatter: Formatters .tpmFormatter ,
259186 async getSubtable (item ) {
260- if (this .isSubtable ){
261- return ;
262- }
263187 let queryKey = this .subtableKey (item);
264188 if (! this .subtableData [queryKey]) {
265189 let data = await this .query (this .config .subtableEndpoint , queryKey);
@@ -347,9 +271,6 @@ export default Vue.component("bulk-table", {
347271 return item .gene === this .highlightedGene ? " table-warning " : " " ;
348272 },
349273 showRegulation (item ){
350- if (this .isSubtable ){
351- return " " ;
352- }
353274 let cond = this .regulationConditions ;
354275 if (item[this .tableYField ] < cond .yGreater ){
355276 return " " ;
@@ -362,11 +283,19 @@ export default Vue.component("bulk-table", {
362283 }
363284 return " " ;
364285 },
365- async findGene (gene ){
366- // Populate the subtable before toggling it open
286+ findGene (gene ){
287+ if (gene === " " ){
288+ return ;
289+ }
290+ if (this .highlightedGene !== gene){
291+ this .$emit (" highlightRow" , gene);
292+ }
367293 this .$emit (" geneFound" , false );
368- // await this.getSubtable(dataItem);
369- let location = this .allGenes .indexOf (gene);
294+ let sortedItems = this .bulkData .toSorted (
295+ (a ,b ) => this .sortDesc
296+ ? b[this .sortField ] - a[this .sortField ]
297+ : a[this .sortField ] - b[this .sortField ]);
298+ let location = sortedItems .findIndex (i => i .gene === gene);
370299 if (location === - 1 ){
371300 return ;
372301 }
@@ -377,18 +306,18 @@ export default Vue.component("bulk-table", {
377306 },
378307 watch: {
379308 async highlightedGene (newGene ){
380- if (!! newGene){await this .findGene (newGene)};
309+ if (!! newGene){ this .findGene (newGene)};
381310 },
382311 async tableData (data ){
383- await this .findGene (this .highlightedGene );
312+ this .findGene (this .highlightedGene );
384313 },
385314 upregulatedGenes (newGenes ){
386315 this .$emit (" upGenes" , newGenes);
387316 },
388317 downregulatedGenes (newGenes ){
389318 this .$emit (" downGenes" , newGenes);
390319 },
391- currentData (newData ){
320+ async currentData (newData ){
392321 console .log (" Current data received" );
393322 }
394323 }
0 commit comments