@sjcrh/proteinpaint-server 2.96.1 → 2.96.2-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.96.1",
3
+ "version": "2.96.2-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",
@@ -42,6 +42,7 @@
42
42
  "@babel/preset-env": "^7.9.6",
43
43
  "@babel/preset-typescript": "^7.21.4",
44
44
  "@babel/register": "^7.14.5",
45
+ "@sjcrh/proteinpaint-types": "2.96.2-0",
45
46
  "@types/node": "^20.11.24",
46
47
  "@types/tough-cookie": "^4.0.5",
47
48
  "@typescript-eslint/eslint-plugin": "^8.13.0",
@@ -61,7 +62,6 @@
61
62
  "@sjcrh/augen": "2.87.0",
62
63
  "@sjcrh/proteinpaint-rust": "2.84.0",
63
64
  "@sjcrh/proteinpaint-shared": "2.96.0",
64
- "@sjcrh/proteinpaint-types": "2.96.1",
65
65
  "better-sqlite3": "^9.4.1",
66
66
  "body-parser": "^1.15.2",
67
67
  "canvas": "~2.11.2",
@@ -1,6 +1,7 @@
1
1
  import path from "path";
2
2
  import { diffExpPayload } from "#types/checkers";
3
3
  import { run_rust } from "@sjcrh/proteinpaint-rust";
4
+ import { getData } from "../src/termdb.matrix.js";
4
5
  import { get_ds_tdb } from "../src/termdb.js";
5
6
  import run_R from "../src/run_R.js";
6
7
  import serverconfig from "../src/serverconfig.js";
@@ -25,7 +26,22 @@ function init({ genomes }) {
25
26
  if (!genome)
26
27
  throw "invalid genome";
27
28
  const [ds] = get_ds_tdb(genome, q);
28
- const results = await run_DE(req.query, ds);
29
+ let term_results = [];
30
+ if (q.tw) {
31
+ const terms = [q.tw];
32
+ term_results = await getData(
33
+ {
34
+ filter: q.filter,
35
+ filter0: q.filter0,
36
+ terms
37
+ },
38
+ ds,
39
+ genome
40
+ );
41
+ if (term_results.error)
42
+ throw term_results.error;
43
+ }
44
+ const results = await run_DE(req.query, ds, term_results);
29
45
  res.send(results);
30
46
  } catch (e) {
31
47
  res.send({ status: "error", error: e.message || e });
@@ -34,7 +50,7 @@ function init({ genomes }) {
34
50
  }
35
51
  };
36
52
  }
37
- async function run_DE(param, ds) {
53
+ async function run_DE(param, ds, term_results) {
38
54
  if (param.samplelst?.groups?.length != 2)
39
55
  throw ".samplelst.groups.length!=2";
40
56
  if (param.samplelst.groups[0].values?.length < 1)
@@ -48,6 +64,7 @@ async function run_DE(param, ds) {
48
64
  if (!q.file)
49
65
  throw "unknown data type for rnaseqGeneCount";
50
66
  const group1names = [];
67
+ const conf1_group1 = [];
51
68
  for (const s of param.samplelst.groups[0].values) {
52
69
  if (!Number.isInteger(s.sampleId))
53
70
  continue;
@@ -56,10 +73,14 @@ async function run_DE(param, ds) {
56
73
  continue;
57
74
  if (q.allSampleSet.has(n)) {
58
75
  group1names.push(n);
76
+ if (param.tw) {
77
+ conf1_group1.push(term_results.samples[s.sampleId][param.tw.$id]["value"]);
78
+ }
59
79
  } else {
60
80
  }
61
81
  }
62
82
  const group2names = [];
83
+ const conf1_group2 = [];
63
84
  for (const s of param.samplelst.groups[1].values) {
64
85
  if (!Number.isInteger(s.sampleId))
65
86
  continue;
@@ -68,6 +89,9 @@ async function run_DE(param, ds) {
68
89
  continue;
69
90
  if (q.allSampleSet.has(n)) {
70
91
  group2names.push(n);
92
+ if (param.tw) {
93
+ conf1_group2.push(term_results.samples[s.sampleId][param.tw.$id]["value"]);
94
+ }
71
95
  } else {
72
96
  }
73
97
  }
@@ -88,6 +112,10 @@ async function run_DE(param, ds) {
88
112
  min_total_count: param.min_total_count,
89
113
  storage_type: param.storage_type
90
114
  };
115
+ if (param.tw) {
116
+ expression_input.conf1 = [...conf1_group2, ...conf1_group1];
117
+ expression_input.conf1_type = param.tw.term.type;
118
+ }
91
119
  const sample_size_limit = 8;
92
120
  let result;
93
121
  if (group1names.length <= sample_size_limit && group2names.length <= sample_size_limit || param.method == "edgeR") {
@@ -102,18 +130,6 @@ async function run_DE(param, ds) {
102
130
  }
103
131
  }
104
132
  param.method = "edgeR";
105
- } else if (param.method == "wilcoxon") {
106
- const time1 = (/* @__PURE__ */ new Date()).valueOf();
107
- const rust_output = await run_rust("DEanalysis", JSON.stringify(expression_input));
108
- const time2 = (/* @__PURE__ */ new Date()).valueOf();
109
- for (const line of rust_output.split("\n")) {
110
- if (line.startsWith("adjusted_p_values:")) {
111
- result = JSON.parse(line.replace("adjusted_p_values:", ""));
112
- } else {
113
- }
114
- }
115
- console.log("Time taken to run rust DE pipeline:", time2 - time1, "ms");
116
- param.method = "wilcoxon";
117
133
  } else {
118
134
  const time1 = (/* @__PURE__ */ new Date()).valueOf();
119
135
  const rust_output = await run_rust("DEanalysis", JSON.stringify(expression_input));