Skip to content

Commit 4833129

Browse files
authored
Pigean updates (#962)
* exomes and hpo selectable. need to make phenotype show up * still need exomes/HPO in phenotype search * trait groups * pigean plot is receiving colors * pigean plot colors are harmonized to the phewas * harmonized on geneset as well * phenotype page colors restored * cleanup
1 parent 994ef92 commit 4833129

File tree

10 files changed

+52
-32
lines changed

10 files changed

+52
-32
lines changed

src/components/PigeanPlot.vue

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default Vue.component("pigean-plot", {
2626
},
2727
props: [
2828
"pigeanData", "config", "phenotypeMap", "filter",
29-
"genesetSize", "traitGroup", "matchingHoverDots"
29+
"genesetSize", "traitGroup", "matchingHoverDots", "pigeanColors"
3030
],
3131
data() {
3232
return {
@@ -41,7 +41,6 @@ export default Vue.component("pigean-plot", {
4141
tooltip: null,
4242
tooltipElement: null,
4343
tooltipPinned: false,
44-
colorMap: this.groupColors(),
4544
allHoverFields: this.getHoverFields(),
4645
hoverBoxPosition: this.config.hoverBoxPosition || "left",
4746
dotOutlineColor: "#00000075"
@@ -257,29 +256,14 @@ export default Vue.component("pigean-plot", {
257256
this.tooltip.style("opacity", 0);
258257
}
259258
},
260-
groupColors(){
261-
// Based on pigeanData not filtered data. Phenotypes should always match PheWAS
262-
let groupsInUse = this.pigeanData.map(d => d.phenotype)
263-
.map(p => !!this.phenotypeMap[p] ? this.phenotypeMap[p]["group"] : "")
264-
.filter(g => g !== "");
265-
let uniqueGroups = [];
266-
groupsInUse.forEach(g => {
267-
if (!uniqueGroups.includes(g)){
268-
uniqueGroups.push(g);
269-
}});
270-
uniqueGroups.sort();
271-
let colorMap = {};
272-
let colors = plotUtils.plotColors();
273-
for (let i = 0; i < uniqueGroups.length; i++){
274-
colorMap[uniqueGroups[i]] = colors[i % colors.length];
275-
}
276-
return colorMap;
277-
},
278259
dotColor(phenotype){
279260
if (!this.phenotypeMap[phenotype]){
280261
return this.dotOutlineColor;
281262
}
282-
return this.colorMap[this.phenotypeMap[phenotype].group];
263+
if (this.pigeanColors === null){
264+
return "lightgray";
265+
}
266+
return this.pigeanColors[this.phenotypeMap[phenotype].group];
283267
},
284268
phDesc(phenotype){
285269
if (!this.phenotypeMap[phenotype]){
@@ -320,6 +304,9 @@ export default Vue.component("pigean-plot", {
320304
this.unHighlightDots();
321305
let phenotypes = Object.keys(JSON.parse(newDots));
322306
phenotypes.forEach(phenotype => this.highlightDot(phenotype));
307+
},
308+
pigeanColors(newColors){
309+
this.drawChart();
323310
}
324311
}
325312
});

src/components/TraitGroupSelectPicker.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<template>
22
<select v-model="traitGroup" class="form-control">
33
<option value="all">All</option>
4-
<option value="portal">A2F</option>
5-
<option value="gcat_trait">GWAS Catalog</option>
6-
<option value="rare_v2">Orphanet</option>
4+
<option v-for="group in groups" :value="group[0]">
5+
{{ group[1] }}
6+
</option>
77
</select>
88
</template>
99

1010
<script>
1111
import Vue from "vue";
1212
import { BootstrapVue, IconsPlugin } from "bootstrap-vue";
1313
import keyParams from "@/utils/keyParams";
14+
import bioIndexUtils from "@/utils/bioIndexUtils";
1415
import "bootstrap/dist/css/bootstrap.css";
1516
import "bootstrap-vue/dist/bootstrap-vue.css";
1617
Vue.use(BootstrapVue);
@@ -27,6 +28,11 @@ export default Vue.component("trait-group-selectpicker", {
2728
keyParamsTraitGroup() {
2829
return keyParams.traitGroup;
2930
},
31+
groups(){
32+
let bioindexGroups = bioIndexUtils.TRAIT_GROUPS;
33+
return Object.keys(bioIndexUtils.TRAIT_GROUPS).map(
34+
g => [g, bioindexGroups[g]]);
35+
}
3036
},
3137
watch: {
3238
traitGroup(newGroup) {

src/components/researchPortal/ResearchPheWAS.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,15 @@ export default Vue.component("ResearchPhewasPlot", {
731731
let groupsArr = Object.keys(groups).sort();
732732
733733
let dotIndex = 0;
734+
let pigeanColors = {};
734735
735736
if (totalNum > 1) {
736737
for (const [key, value] of Object.entries(renderData)) {
737738
let keyIndex =
738739
groupsArr.indexOf(key) % this.colors.length;
739740
let fillColor = this.colors[keyIndex];
740741
let strokeColor = "#00000075"; //this.colors[keyIndex];
741-
742+
pigeanColors[key] = fillColor;
742743
let labelIndex = 0;
743744
let labelOrigin = 0;
744745
let maxWidthPerGroup =
@@ -905,6 +906,7 @@ export default Vue.component("ResearchPhewasPlot", {
905906
let keyIndex =
906907
groupsArr.indexOf(key) % this.colors.length;
907908
let fillColor = this.colors[keyIndex];
909+
pigeanColors[key] = fillColor;
908910
let strokeColor = "#00000075"; //this.colors[keyIndex];
909911
value.map((p) => {
910912
let xPos = canvasWidth / 2;
@@ -986,6 +988,7 @@ export default Vue.component("ResearchPhewasPlot", {
986988
});
987989
}
988990
}
991+
this.$emit("pigeanColors", pigeanColors);
989992
}
990993
},
991994

src/utils/bioIndexUtils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ async function processRequest(req, onResolve, onError, onLoad, limitWhile) {
141141
export const DEFAULT_SIGMA = 2;
142142
export const DEFAULT_GENESET_SIZE = "small";
143143
export const DEFAULT_TRAIT_GROUP = "all";
144-
export const TRAIT_GROUPS = ["portal", "gcat_trait", "rare_v2"];
144+
export const TRAIT_GROUPS = {
145+
"portal": "A2F",
146+
"gcat_trait": "GWAS Catalog",
147+
"rare_v2": "Orphanet",
148+
"hpo": "HPO",
149+
"portal_exomes": "Exomes"};
145150

146151
export default {
147152
query,

src/views/PIGEAN/Gene/Template.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@
149149
:matchingHoverDots="
150150
$parent.hoverDotsToPhewas
151151
"
152+
@pigeanColors="(colors) => $parent.storeColors(colors)"
152153
>
153154
</research-phewas-plot>
154155
</div>
155156
<div class="col-md-4">
156157
<pigean-plot
157158
v-if="$parent.plotReady"
159+
:pigeanColors="$parent.pigeanColors"
158160
:pigean-data="
159161
$parent.pigeanFilteredData
160162
"

src/views/PIGEAN/Gene/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ new Vue({
9393
hoverFields: ["gene", "combined"],
9494
},
9595
plotColors: plotUtils.plotColors(),
96+
pigeanColors: null,
9697
renderConfig: {
9798
type: "phewas plot",
9899
"render by": "phenotype",
@@ -211,6 +212,9 @@ new Vue({
211212
} else {
212213
this.dotsToPhewas = dots;
213214
}
215+
},
216+
storeColors(colors){
217+
this.pigeanColors = colors;
214218
}
215219
},
216220

src/views/PIGEAN/GeneSet/Template.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@
123123
:utils="$parent.utilsBox"
124124
:filter="filter"
125125
:native-dl-btn="false"
126+
@pigeanColors="(colors) => $parent.storeColors(colors)"
126127
>
127128
</research-phewas-plot>
128129
</div>
129130
<div class="col-md-4">
130131
<pigean-plot
131132
v-if="$parent.plotReady"
133+
:pigeanColors="$parent.pigeanColors"
132134
:pigean-data="$parent.phewasAllData"
133135
:config="$parent.pigeanPlotConfig"
134136
:phenotype-map="$parent.pigeanMap"

src/views/PIGEAN/GeneSet/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ new Vue({
8888
dotKey: "phenotype",
8989
},
9090
plotColors: plotUtils.plotColors(),
91+
pigeanColors: null,
9192
renderConfig: {
9293
type: "phewas plot",
9394
"render by": "phenotype",
@@ -146,6 +147,11 @@ new Vue({
146147
return this.$store.state.phewasData;
147148
}
148149
},
150+
methods: {
151+
storeColors(colors){
152+
this.pigeanColors = colors;
153+
}
154+
},
149155
watch: {
150156
diseaseGroup(group) {
151157
this.$store.dispatch("kp4cd/getFrontContents", group.name);

src/views/PIGEAN/Phenotype/Template.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
:config="$parent.genePigeanPlotConfig"
130130
:phenotypeMap="$parent.pigeanMap"
131131
:filter="filter"
132+
:pigeanColors="$parent.pigeanColors"
132133
>
133134
</pigean-plot>
134135
<pigean-table
@@ -184,6 +185,7 @@
184185
:pigeanData="$store.state.genesetPhenotype.data"
185186
:config="$parent.genesetPigeanPlotConfig"
186187
:phenotypeMap="$parent.pigeanMap"
188+
:pigeanColors="$parent.pigeanColors"
187189
:filter="filter"
188190
>
189191
</pigean-plot>

src/views/PIGEAN/Phenotype/main.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import pigeanUtils from "@/utils/pigeanUtils.js";
1313
import sessionUtils from "@/utils/sessionUtils";
1414
import sortUtils from "@/utils/sortUtils";
1515
import dataConvert from "@/utils/dataConvert";
16+
import bioIndexUtils from "@/utils/bioIndexUtils";
1617
import SearchHeaderWrapper from "@/components/SearchHeaderWrapper.vue";
1718
import GenesetSizeSelectPicker from "@/components/GenesetSizeSelectPicker.vue";
1819
import PigeanTable from "@/components/PigeanTable.vue";
@@ -47,13 +48,7 @@ new Vue({
4748
mixins: [pageMixin],
4849
data() {
4950
return {
50-
plotColors: plotUtils.plotColors(),
5151
pigeanPhenotypeMap: {},
52-
traitGroups: {
53-
portal: "A2F",
54-
gcat_trait:"GWAS Catalog",
55-
rare_v2: "Orphanet"
56-
},
5752
phewasPlotLabel: "",
5853
phenotypeSearchKey: null,
5954
newPhenotypeSearchKey: null,
@@ -297,6 +292,9 @@ new Vue({
297292
return this.$store.state.diseaseInSession;
298293
}
299294
},
295+
traitGroups(){
296+
return bioIndexUtils.TRAIT_GROUPS;
297+
},
300298
phenotypesInSession() {
301299
if (this.$store.state.phenotypesInSession == null) {
302300
return this.$store.state.bioPortal.phenotypes;
@@ -337,6 +335,11 @@ new Vue({
337335
},
338336
pigeanMap(){
339337
return this.pigeanPhenotypeMap;
338+
},
339+
pigeanColors(){
340+
let colors = {};
341+
colors[this.$store.state.phenotype.group] = plotUtils.plotColors()[0];
342+
return colors;
340343
}
341344

342345
},

0 commit comments

Comments
 (0)