@sjcrh/proteinpaint-server 2.87.0 → 2.87.1

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.
@@ -26,17 +26,6 @@ var termdb_test_default = {
26
26
  db: {
27
27
  file: "files/hg38/TermdbTest/db"
28
28
  },
29
- allowedChartTypes: [
30
- "summary",
31
- "survival",
32
- "matrix",
33
- "sampleScatter",
34
- "cuminc",
35
- "dataDownload",
36
- "sampleView",
37
- "regression",
38
- "facet"
39
- ],
40
29
  termdb: {
41
30
  displaySampleIds: true,
42
31
  // allow to display sample-level data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.87.0",
3
+ "version": "2.87.1",
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",
@@ -60,8 +60,8 @@
60
60
  "dependencies": {
61
61
  "@sjcrh/augen": "2.87.0",
62
62
  "@sjcrh/proteinpaint-rust": "2.84.0",
63
- "@sjcrh/proteinpaint-shared": "2.87.0",
64
- "@sjcrh/proteinpaint-types": "2.87.0",
63
+ "@sjcrh/proteinpaint-shared": "2.87.1",
64
+ "@sjcrh/proteinpaint-types": "2.87.1",
65
65
  "better-sqlite3": "^9.4.1",
66
66
  "body-parser": "^1.15.2",
67
67
  "canvas": "~2.11.2",
@@ -2,7 +2,7 @@ import { boxplotPayload } from "#types/checkers";
2
2
  import { getData } from "../src/termdb.matrix.js";
3
3
  import { boxplot_getvalue } from "../src/utils.js";
4
4
  import { sortKey2values } from "../src/termdb.violin.js";
5
- import { roundValue } from "#shared/roundValue.js";
5
+ import { roundValueAuto } from "#shared/roundValue.js";
6
6
  const api = {
7
7
  endpoint: "termdb/boxplot",
8
8
  methods: {
@@ -147,6 +147,8 @@ function setHiddenPlots(term, plots) {
147
147
  return plots;
148
148
  }
149
149
  function setDescrStats(boxplot, sortedValues) {
150
+ if (sortedValues.length < 5)
151
+ return [{ id: "total", label: "Total", value: sortedValues.length }];
150
152
  const mean = sortedValues.reduce((s2, i) => s2 + i, 0) / sortedValues.length;
151
153
  let s = 0;
152
154
  for (const v of sortedValues) {
@@ -157,15 +159,15 @@ function setDescrStats(boxplot, sortedValues) {
157
159
  const variance = squareDiffs / (sortedValues.length - 1);
158
160
  return [
159
161
  { id: "total", label: "Total", value: sortedValues.length },
160
- { id: "min", label: "Minimum", value: roundValue(sortedValues[0], 2) },
161
- { id: "p25", label: "1st quartile", value: roundValue(boxplot.p25, 2) },
162
- { id: "median", label: "Median", value: roundValue(boxplot.p50, 2) },
163
- { id: "mean", label: "Mean", value: roundValue(mean, 2) },
164
- { id: "p75", label: "3rd quartile", value: roundValue(boxplot.p75, 2) },
165
- { id: "max", label: "Maximum", value: roundValue(sortedValues[sortedValues.length - 1], 2) },
166
- { id: "sd", label: "Standard deviation", value: isNaN(sd) ? null : roundValue(sd, 2) },
167
- { id: "variance", label: "Variance", value: roundValue(variance, 2) },
168
- { id: "iqr", label: "Inter-quartile range", value: roundValue(boxplot.iqr, 2) }
162
+ { id: "min", label: "Minimum", value: roundValueAuto(sortedValues[0]) },
163
+ { id: "p25", label: "1st quartile", value: roundValueAuto(boxplot.p25) },
164
+ { id: "median", label: "Median", value: roundValueAuto(boxplot.p50) },
165
+ { id: "mean", label: "Mean", value: roundValueAuto(mean) },
166
+ { id: "p75", label: "3rd quartile", value: roundValueAuto(boxplot.p75) },
167
+ { id: "max", label: "Maximum", value: roundValueAuto(sortedValues[sortedValues.length - 1]) },
168
+ { id: "sd", label: "Standard deviation", value: isNaN(sd) ? null : roundValueAuto(sd) },
169
+ { id: "variance", label: "Variance", value: roundValueAuto(variance) },
170
+ { id: "iqr", label: "Inter-quartile range", value: roundValueAuto(boxplot.iqr) }
169
171
  ];
170
172
  }
171
173
  function setUncomputableValues(values) {
@@ -19,7 +19,7 @@ function init({ genomes }) {
19
19
  if (!genome)
20
20
  throw "invalid genome";
21
21
  const [ds] = get_ds_tdb(genome, q);
22
- const count = ds.cohort.termdb.q.getCohortSampleCount(q.cohort);
22
+ const count = ds.cohort.termdb.q?.getCohortSampleCount?.(q.cohort) || 1;
23
23
  res.send({ count });
24
24
  } catch (e) {
25
25
  res.send({ error: e.message || e });
@@ -31,6 +31,8 @@ function init({ genomes }) {
31
31
  };
32
32
  }
33
33
  function getCohortsData(ds) {
34
+ if (!ds.cohort.db)
35
+ return { cohorts: [], features: [], cfeatures: [] };
34
36
  const features = ds.cohort.db.connection.prepare("select * from features").all();
35
37
  const cohorts = ds.cohort.db.connection.prepare(
36
38
  `select * from cohorts where cohort in (select distinct(cohort) from cohort_features)
@@ -2,7 +2,7 @@ import serverconfig from "#src/serverconfig.js";
2
2
  import { authApi } from "#src/auth.js";
3
3
  import { get_ds_tdb } from "#src/termdb.js";
4
4
  import { mayCopyFromCookie } from "#src/utils.js";
5
- import { mayComputeTermtypeByCohort } from "#src/termdb.server.init.js";
5
+ import { mayComputeTermtypeByCohort } from "#src/termdb.server.init.ts";
6
6
  import { TermTypes } from "#shared/terms.js";
7
7
  const api = {
8
8
  endpoint: "termdb/config",
@@ -39,11 +39,11 @@ function init({ genomes }) {
39
39
  }
40
40
  function make(q, res, ds, genome) {
41
41
  const tdb = ds.cohort.termdb;
42
+ const auth = { embedder: q.embedder };
42
43
  const c = {
43
44
  selectCohort: tdb.selectCohort,
44
45
  // optional
45
- supportedChartTypes: tdb.q?.getSupportedChartTypes(q.embedder),
46
- allowedChartTypes: ds.cohort.allowedChartTypes,
46
+ supportedChartTypes: tdb.q?.getSupportedChartTypes(auth),
47
47
  hiddenChartTypes: ds.cohort.hiddenChartTypes,
48
48
  renamedChartTypes: ds.cohort.renamedChartTypes,
49
49
  allowedTermTypes: getAllowedTermTypes(ds),
@@ -242,8 +242,8 @@ function getAllowedTermTypes(ds) {
242
242
  mayComputeTermtypeByCohort(ds);
243
243
  const typeSet = /* @__PURE__ */ new Set();
244
244
  for (const r of ds.cohort.termdb.termtypeByCohort) {
245
- if (r.type)
246
- typeSet.add(r.type);
245
+ if (r.termType)
246
+ typeSet.add(r.termType);
247
247
  }
248
248
  if (ds.cohort.termdb.allowedTermTypes) {
249
249
  for (const t of ds.cohort.termdb.allowedTermTypes)