@sjcrh/proteinpaint-server 2.122.0 → 2.124.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.
@@ -5,6 +5,9 @@ copyDataFilesFromRepo2Tp();
5
5
  function termdb_test_default() {
6
6
  return {
7
7
  isMds3: true,
8
+ isSupportedChartOverride: {
9
+ runChart: () => true
10
+ },
8
11
  cohort: {
9
12
  massNav: {
10
13
  tabs: {
@@ -34,7 +37,7 @@ function termdb_test_default() {
34
37
  },
35
38
  termdb: {
36
39
  allowedTermTypes: ["geneVariant"],
37
- displaySampleIds: true,
40
+ displaySampleIds: () => true,
38
41
  // allow to display sample-level data
39
42
  timeUnit: "years",
40
43
  minTimeSinceDx: 5,
@@ -123,16 +126,6 @@ function termdb_test_default() {
123
126
  ]
124
127
  }
125
128
  },
126
- customTwQByType: {
127
- // dataset-specific termsetting configs on certain term types
128
- geneVariant: {
129
- default: { cnvGainCutoff: 0.1, cnvLossCutoff: -0.1, cnvMaxLength: 0 },
130
- byGene: {
131
- // key is term.name, thus possible to use non-gene names e.g. C19MC
132
- MYCN: { cnvGainCutoff: 0.5, cnvLossCutoff: -0.1, cnvMaxLength: 0 }
133
- }
134
- }
135
- },
136
129
  variant2samples: {
137
130
  variantkey: "ssm_id",
138
131
  // required, tells client to return ssm_id for identifying variants
package/genome/hg38.js CHANGED
@@ -14,6 +14,19 @@ var hg38_default = {
14
14
  termdb: {
15
15
  isGeneSetTermdb: true
16
16
  }
17
+ },
18
+ analysisGenesetGroups: [
19
+ { label: "-", value: "-" },
20
+ { label: "BP: subset of GO", value: "BP: subset of GO" },
21
+ { label: "MF: subset of GO", value: "MF: subset of GO" },
22
+ { label: "CC: subset of GO", value: "CC: subset of GO" },
23
+ { label: "WikiPathways subset of CP", value: "WikiPathways subset of CP" },
24
+ { label: "REACTOME subset of CP", value: "REACTOME subset of CP" },
25
+ { label: "H: hallmark gene sets", value: "H: hallmark gene sets" }
26
+ ],
27
+ geneORAparam: {
28
+ minCutoff: 15,
29
+ maxCutoff: 500
17
30
  }
18
31
  }
19
32
  },
@@ -13,6 +13,14 @@ const genome = {
13
13
  termdb: {
14
14
  isGeneSetTermdb: true
15
15
  }
16
+ },
17
+ analysisGenesetGroups: [
18
+ { label: "-", value: "-" },
19
+ { label: "H: hallmark gene sets", value: "H: hallmark gene sets" }
20
+ ],
21
+ geneORAparam: {
22
+ minCutoff: 0,
23
+ maxCutoff: 500
16
24
  }
17
25
  }
18
26
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.122.0",
3
+ "version": "2.124.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",
@@ -67,9 +67,10 @@
67
67
  "dependencies": {
68
68
  "@sjcrh/augen": "2.121.0",
69
69
  "@sjcrh/proteinpaint-python": "2.118.0",
70
- "@sjcrh/proteinpaint-rust": "2.122.0",
71
- "@sjcrh/proteinpaint-shared": "2.121.0",
72
- "@sjcrh/proteinpaint-types": "2.121.0",
70
+ "@sjcrh/proteinpaint-r": "2.123.0",
71
+ "@sjcrh/proteinpaint-rust": "2.124.0",
72
+ "@sjcrh/proteinpaint-shared": "2.124.0",
73
+ "@sjcrh/proteinpaint-types": "2.124.0",
73
74
  "@types/express": "^5.0.0",
74
75
  "@types/express-session": "^1.18.1",
75
76
  "better-sqlite3": "^9.4.1",
@@ -110,12 +111,9 @@
110
111
  "start.js",
111
112
  "src/app.js",
112
113
  "src/serverconfig.js",
113
- "src/run_R.js",
114
114
  "src/mds3.gdc.filter.js",
115
115
  "src/checkReadingFrame.js",
116
116
  "src/bedj.parseBed.js",
117
- "utils/*.R",
118
- "utils/*.py",
119
117
  "LICENSE/*"
120
118
  ],
121
119
  "bugs": {
package/routes/burden.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { burdenPayload } from "#types/checkers";
2
- import run_R from "#src/run_R.js";
2
+ import { run_R } from "@sjcrh/proteinpaint-r";
3
3
  import path from "path";
4
4
  import serverconfig from "#src/serverconfig.js";
5
5
  const api = {
@@ -57,7 +57,7 @@ async function getBurdenResult(q, cumburden) {
57
57
  let result = cumburden.db.connection.prepare("SELECT * FROM estimates WHERE id=?").get(id);
58
58
  if (!result) {
59
59
  result = { id, status: null, input: jsonInput };
60
- const estJson = await run_R(path.join(serverconfig.binpath, "utils", "burden-main.R"), jsonInput, []);
60
+ const estJson = await run_R("burden-main.R", jsonInput, []);
61
61
  const estimate = JSON.parse(estJson);
62
62
  const ages = Object.keys(estimate[0]).filter((k) => k.startsWith("["));
63
63
  const overall = { chc: 0 };
@@ -92,7 +92,6 @@ function normalizeInput(q, cumburden) {
92
92
  files: cumburden.files,
93
93
  boosubdir: cumburden.bootsubdir
94
94
  };
95
- normalized.binpath = serverconfig.binpath;
96
95
  const jsonInput = JSON.stringify(normalized);
97
96
  return { id, jsonInput };
98
97
  }
@@ -102,7 +101,7 @@ async function compute95ci(result, cumburden) {
102
101
  throw "result{} does not have .input";
103
102
  const input = structuredClone(result.input);
104
103
  input.burden = Object.values(result.estimate).filter((est) => est.chc !== 0);
105
- const lowup = await run_R(path.join(serverconfig.binpath, "utils", "burden-ci95.R"), JSON.stringify(input), []);
104
+ const lowup = await run_R("burden-ci95.R", JSON.stringify(input), []);
106
105
  const { low, up, overall } = JSON.parse(lowup);
107
106
  const ci95 = { 0: {} };
108
107
  for (const est of Object.values(result.estimate)) {
@@ -1,9 +1,7 @@
1
1
  import { CorrelationVolcanoPayload } from "#types/checkers";
2
2
  import { getData } from "../src/termdb.matrix.js";
3
- import run_R from "../src/run_R.js";
4
- import serverconfig from "../src/serverconfig.js";
3
+ import { run_R } from "@sjcrh/proteinpaint-r";
5
4
  import { mayLog } from "#src/helpers.ts";
6
- import path from "path";
7
5
  import { getStdDev } from "#shared/descriptive.stats.js";
8
6
  import { formatElapsedTime } from "#shared/time.js";
9
7
  const minArrayLength = 3;
@@ -91,7 +89,7 @@ async function compute(q, ds, genome) {
91
89
  };
92
90
  const time1 = Date.now();
93
91
  const output = {
94
- terms: JSON.parse(await run_R(path.join(serverconfig.binpath, "utils", "corr.R"), JSON.stringify(input)))
92
+ terms: JSON.parse(await run_R("corr.R", JSON.stringify(input)))
95
93
  };
96
94
  const elapsedMs = Date.now() - time1;
97
95
  const formattedTime = formatElapsedTime(elapsedMs);
@@ -42,13 +42,7 @@ async function run_genesetOverrepresentation_analysis(q, genomes) {
42
42
  const rust_output = await run_rust("genesetORA", JSON.stringify(gene_overrepresentation_input_type));
43
43
  const time2 = (/* @__PURE__ */ new Date()).valueOf();
44
44
  console.log("Time taken to run rust gene over representation pipeline:", time2 - time1, "ms");
45
- let result;
46
- for (const line of rust_output.split("\n")) {
47
- if (line.startsWith("pathway_p_values:")) {
48
- result = JSON.parse(line.replace("pathway_p_values:", ""));
49
- } else {
50
- }
51
- }
45
+ const result = JSON.parse(rust_output);
52
46
  return result;
53
47
  }
54
48
  export {
package/routes/genomes.js CHANGED
@@ -93,7 +93,11 @@ function clientcopy_genome(genomename, genomes) {
93
93
  if (g.termdbs) {
94
94
  g2.termdbs = {};
95
95
  for (const k in g.termdbs) {
96
- g2.termdbs[k] = { label: g.termdbs[k].label };
96
+ g2.termdbs[k] = {
97
+ label: g.termdbs[k].label,
98
+ analysisGenesetGroups: g.termdbs[k].analysisGenesetGroups,
99
+ geneORAparam: g.termdbs[k].geneORAparam
100
+ };
97
101
  }
98
102
  }
99
103
  for (const dsname in g.datasets) {
@@ -30,6 +30,15 @@ function init({ genomes }) {
30
30
  if (annotations) {
31
31
  wsimage.overlays = annotations;
32
32
  }
33
+ if (ds.queries.WSImages.getZoomInPoints) {
34
+ const zoomInPoints = await ds.queries.WSImages.getZoomInPoints(
35
+ sampleId,
36
+ wsimage.filename
37
+ );
38
+ if (zoomInPoints) {
39
+ wsimage.zoomInPoints = zoomInPoints;
40
+ }
41
+ }
33
42
  }
34
43
  }
35
44
  res.send({ sampleWSImages: wsimages });
@@ -4,7 +4,7 @@ import { diffExpPayload } from "#types/checkers";
4
4
  import { run_rust } from "@sjcrh/proteinpaint-rust";
5
5
  import { getData } from "../src/termdb.matrix.js";
6
6
  import { get_ds_tdb } from "../src/termdb.js";
7
- import run_R from "../src/run_R.js";
7
+ import { run_R } from "@sjcrh/proteinpaint-r";
8
8
  import { mayLog } from "#src/helpers.ts";
9
9
  import serverconfig from "../src/serverconfig.js";
10
10
  import imagesize from "image-size";
@@ -223,9 +223,7 @@ async function run_DE(param, ds, term_results, term_results2) {
223
223
  const sample_size_limit = 8;
224
224
  if (group1names.length <= sample_size_limit && group2names.length <= sample_size_limit || param.method == "edgeR" || param.method == "limma") {
225
225
  const time12 = (/* @__PURE__ */ new Date()).valueOf();
226
- const result2 = JSON.parse(
227
- await run_R(path.join(serverconfig.binpath, "utils", "edge.R"), JSON.stringify(expression_input))
228
- );
226
+ const result2 = JSON.parse(await run_R("edge.R", JSON.stringify(expression_input)));
229
227
  mayLog("Time taken to run edgeR:", formatElapsedTime(Date.now() - time12));
230
228
  param.method = "edgeR";
231
229
  const ql_imagePath = path.join(serverconfig.cachedir, result2.edgeR_ql_image_name[0]);
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import run_R from "#src/run_R.js";
2
+ import { run_R } from "@sjcrh/proteinpaint-r";
3
3
  import { run_rust } from "@sjcrh/proteinpaint-rust";
4
4
  import { termdbClusterPayload } from "#types/checkers";
5
5
  import * as utils from "#src/utils.js";
@@ -172,9 +172,7 @@ async function doClustering(data, q, numCases = 1e3) {
172
172
  }
173
173
  if (inputData.matrix.length == 0)
174
174
  throw "Clustering matrix is empty";
175
- const Routput = JSON.parse(
176
- await run_R(path.join(serverconfig.binpath, "utils", "hclust.R"), JSON.stringify(inputData))
177
- );
175
+ const Routput = JSON.parse(await run_R("hclust.R", JSON.stringify(inputData)));
178
176
  const row_names_index = Routput.RowOrder.map((row) => inputData.row_names.indexOf(row.name));
179
177
  const col_names_index = Routput.ColOrder.map((col) => inputData.col_names.indexOf(col.name));
180
178
  const output_matrix = [];
@@ -41,7 +41,6 @@ function make(q, req, res, ds, genome) {
41
41
  const c = {
42
42
  selectCohort: getSelectCohort(ds, req),
43
43
  supportedChartTypes: tdb.q?.getSupportedChartTypes(req),
44
- hiddenTermIds: tdb.hiddenTermIds,
45
44
  renamedChartTypes: ds.cohort.renamedChartTypes,
46
45
  allowedTermTypes: getAllowedTermTypes(ds),
47
46
  termMatch2geneSet: tdb.termMatch2geneSet,
@@ -76,8 +75,6 @@ function make(q, req, res, ds, genome) {
76
75
  c.timeUnit = tdb.timeUnit;
77
76
  if (tdb.cohortStartTimeMsg)
78
77
  c.cohortStartTimeMsg = tdb.cohortStartTimeMsg;
79
- if (tdb.displaySampleIds)
80
- c.displaySampleIds = tdb.displaySampleIds;
81
78
  if (tdb.hasAncestry)
82
79
  c.hasAncestry = tdb.hasAncestry;
83
80
  if (tdb.logscaleBase2)
@@ -92,8 +89,6 @@ function make(q, req, res, ds, genome) {
92
89
  c.regression = tdb.regression;
93
90
  if (ds.assayAvailability)
94
91
  c.assayAvailability = ds.assayAvailability;
95
- if (ds.customTwQByType)
96
- c.customTwQByType = ds.customTwQByType;
97
92
  if (ds.cohort.correlationVolcano)
98
93
  c.correlationVolcano = ds.cohort.correlationVolcano;
99
94
  c.requiredAuth = authApi.getRequiredCredForDsEmbedder(q.dslabel, q.embedder);
@@ -104,6 +99,8 @@ function make(q, req, res, ds, genome) {
104
99
  c.requiredAuth = authApi.getRequiredCredForDsEmbedder(q.dslabel, q.embedder);
105
100
  const info = authApi.getNonsensitiveInfo(req);
106
101
  c.clientAuthResult = info?.clientAuthResult || {};
102
+ if (tdb.displaySampleIds)
103
+ c.displaySampleIds = tdb.displaySampleIds(c.clientAuthResult);
107
104
  res.send({ termdbConfig: c });
108
105
  }
109
106
  function addRestrictAncestries(c, tdb) {
@@ -25,7 +25,7 @@ function init({ genomes }) {
25
25
  throw "invalid dataset name";
26
26
  if (!tdb)
27
27
  throw "invalid termdb object";
28
- await trigger_rootterm(q, res, tdb);
28
+ await trigger_rootterm(req, q, res, tdb);
29
29
  } catch (e) {
30
30
  res.send({ error: e instanceof Error ? e.message : e });
31
31
  if (e instanceof Error && e.stack)
@@ -33,10 +33,10 @@ function init({ genomes }) {
33
33
  }
34
34
  };
35
35
  }
36
- async function trigger_rootterm(q, res, tdb) {
36
+ async function trigger_rootterm(req, q, res, tdb) {
37
37
  const cohortValues = q.cohortValues ? q.cohortValues : "";
38
38
  const treeFilter = q.treeFilter ? q.treeFilter : "";
39
- res.send({ lst: await tdb.q.getRootTerms(cohortValues, treeFilter) });
39
+ res.send({ lst: await tdb.q.getRootTerms(req, cohortValues, treeFilter) });
40
40
  }
41
41
  export {
42
42
  api
@@ -25,7 +25,7 @@ function init({ genomes }) {
25
25
  throw "invalid dataset name";
26
26
  if (!tdb)
27
27
  throw "invalid termdb object";
28
- const result = await trigger_children(q, tdb);
28
+ const result = await trigger_children(req, q, tdb);
29
29
  res.send(result);
30
30
  } catch (e) {
31
31
  res.send({ error: e instanceof Error ? e.message : e });
@@ -34,12 +34,12 @@ function init({ genomes }) {
34
34
  }
35
35
  };
36
36
  }
37
- async function trigger_children(q, tdb) {
37
+ async function trigger_children(req, q, tdb) {
38
38
  if (!q.tid)
39
39
  throw "no parent term id";
40
40
  const cohortValues = q.cohortValues ? q.cohortValues : "";
41
41
  const treeFilter = q.treeFilter ? q.treeFilter : "";
42
- const terms = await tdb.q.getTermChildren(q.tid, cohortValues, treeFilter);
42
+ const terms = await tdb.q.getTermChildren(req, q.tid, cohortValues, treeFilter);
43
43
  return { lst: terms.map(copy_term) };
44
44
  }
45
45
  export {
@@ -7,9 +7,7 @@ import { getOrderedLabels } from "../src/termdb.barchart.js";
7
7
  import { summaryStats } from "#shared/descriptive.stats.js";
8
8
  import { isNumericTerm } from "#shared/terms.js";
9
9
  import { numericBins, parseValues } from "./termdb.boxplot.ts";
10
- import serverconfig from "../src/serverconfig.js";
11
- import run_R from "../src/run_R.js";
12
- import path from "path";
10
+ import { run_R } from "@sjcrh/proteinpaint-r";
13
11
  const api = {
14
12
  endpoint: "termdb/violin",
15
13
  methods: {
@@ -238,8 +236,7 @@ async function getDensity(values) {
238
236
  return result.plot;
239
237
  }
240
238
  async function getDensities(plot2Values, min, max) {
241
- const densityScript = path.join(serverconfig.binpath, "utils", "density.R");
242
- const plot2Density = JSON.parse(await run_R(densityScript, JSON.stringify({ plot2Values, min, max })));
239
+ const plot2Density = JSON.parse(await run_R("density.R", JSON.stringify({ plot2Values, min, max })));
243
240
  const densities = {};
244
241
  for (const plot in plot2Density) {
245
242
  const result = plot2Density[plot];