@sjcrh/proteinpaint-server 2.92.1-0 → 2.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ var termdb_test_default = {
45
45
  // term.id is specific to this dataset, should not use literally in client/server code but always through a variable
46
46
  term: {
47
47
  id: "subcohort",
48
- type: "categorical"
48
+ type: "multivalue"
49
49
  },
50
50
  prompt: "Select a cohort and test the plots.",
51
51
  values: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.92.1-0",
3
+ "version": "2.94.0",
4
4
  "type": "module",
5
5
  "description": "a genomics visualization tool for exploring a cohort's genotype and phenotype data",
6
6
  "main": "src/app.js",
@@ -61,7 +61,7 @@
61
61
  "@sjcrh/augen": "2.87.0",
62
62
  "@sjcrh/proteinpaint-rust": "2.84.0",
63
63
  "@sjcrh/proteinpaint-shared": "2.88.2",
64
- "@sjcrh/proteinpaint-types": "2.92.1-0",
64
+ "@sjcrh/proteinpaint-types": "2.94.0",
65
65
  "better-sqlite3": "^9.4.1",
66
66
  "body-parser": "^1.15.2",
67
67
  "canvas": "~2.11.2",
@@ -4,6 +4,7 @@ import { brainImagingPayload } from "#types/checkers";
4
4
  import { spawn } from "child_process";
5
5
  import { getData } from "../src/termdb.matrix.js";
6
6
  import { isNumericTerm } from "@sjcrh/proteinpaint-shared/terms.js";
7
+ import { getColors } from "#shared/common.js";
7
8
  const api = {
8
9
  endpoint: "brainImaging",
9
10
  methods: {
@@ -63,6 +64,7 @@ async function getBrainImage(query, genomes, plane, index) {
63
64
  const selectedSampleNames = query.selectedSampleFileNames.map((s) => s.split(".nii")[0]);
64
65
  const data = await getData({ terms }, ds, q.genome);
65
66
  const divideByCat = {};
67
+ const uniqueOverlayTwCats = /* @__PURE__ */ new Set();
66
68
  for (const sampleName of selectedSampleNames) {
67
69
  const sampleId = ds.sampleName2Id.get(sampleName);
68
70
  const sampleData = data.samples[sampleId];
@@ -76,14 +78,16 @@ async function getBrainImage(query, genomes, plane, index) {
76
78
  }
77
79
  if (overlayTW) {
78
80
  const value = sampleData[overlayTW.$id];
79
- if (value)
81
+ if (value) {
80
82
  overlayCategory = overlayTW.term.values?.[value.key]?.label || value.key;
83
+ uniqueOverlayTwCats.add(overlayCategory);
84
+ }
81
85
  }
82
86
  if (!divideByCat[divideCategory])
83
87
  divideByCat[divideCategory] = {};
84
88
  if (!query.legendFilter?.includes(overlayCategory)) {
85
89
  if (!divideByCat[divideCategory][overlayCategory]) {
86
- let color = overlayTW?.term?.values?.[overlayCategory]?.color || "red";
90
+ let color = overlayTW?.term?.values?.[overlayCategory]?.color;
87
91
  if (overlayTW && isNumericTerm(overlayTW.term)) {
88
92
  const bins = data.refs.byTermId[overlayTW.$id].bins;
89
93
  color = bins.find((b) => b.label == overlayCategory).color;
@@ -96,12 +100,17 @@ async function getBrainImage(query, genomes, plane, index) {
96
100
  divideByCat[divideCategory][overlayCategory].samples.push(samplePath);
97
101
  }
98
102
  }
103
+ const k2c = getColors(uniqueOverlayTwCats.size);
99
104
  const lengths = [];
100
- for (const dcategory in divideByCat)
105
+ for (const dcategory in divideByCat) {
101
106
  for (const category in divideByCat[dcategory]) {
102
- const samples = divideByCat[dcategory][category].samples;
107
+ const overlayCat = divideByCat[dcategory][category];
108
+ const samples = overlayCat.samples;
103
109
  lengths.push(samples.length);
110
+ if (!overlayCat.color)
111
+ overlayCat.color = category == "default" ? "red" : k2c(category);
104
112
  }
113
+ }
105
114
  const maxLength = Math.max(...lengths);
106
115
  const brainImageDict = {};
107
116
  const legend = {};