@sjcrh/proteinpaint-server 2.87.0 → 2.88.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/dataset/termdb.test.js +0 -11
- package/package.json +3 -3
- package/routes/termdb.boxplot.js +12 -10
- package/routes/termdb.cohort.summary.js +1 -1
- package/routes/termdb.cohorts.js +2 -0
- package/routes/termdb.config.js +5 -6
- package/routes/termdb.singlecellSamples.js +8 -3
- package/src/app.js +590 -571
package/dataset/termdb.test.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "2.88.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",
|
|
@@ -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.
|
|
64
|
-
"@sjcrh/proteinpaint-types": "2.
|
|
63
|
+
"@sjcrh/proteinpaint-shared": "2.87.1",
|
|
64
|
+
"@sjcrh/proteinpaint-types": "2.88.0",
|
|
65
65
|
"better-sqlite3": "^9.4.1",
|
|
66
66
|
"body-parser": "^1.15.2",
|
|
67
67
|
"canvas": "~2.11.2",
|
package/routes/termdb.boxplot.js
CHANGED
|
@@ -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 {
|
|
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:
|
|
161
|
-
{ id: "p25", label: "1st quartile", value:
|
|
162
|
-
{ id: "median", label: "Median", value:
|
|
163
|
-
{ id: "mean", label: "Mean", value:
|
|
164
|
-
{ id: "p75", label: "3rd quartile", value:
|
|
165
|
-
{ id: "max", label: "Maximum", value:
|
|
166
|
-
{ id: "sd", label: "Standard deviation", value: isNaN(sd) ? null :
|
|
167
|
-
{ id: "variance", label: "Variance", value:
|
|
168
|
-
{ id: "iqr", label: "Inter-quartile range", value:
|
|
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
|
|
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 });
|
package/routes/termdb.cohorts.js
CHANGED
|
@@ -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)
|
package/routes/termdb.config.js
CHANGED
|
@@ -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.
|
|
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,12 +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(
|
|
46
|
-
allowedChartTypes: ds.cohort.allowedChartTypes,
|
|
47
|
-
hiddenChartTypes: ds.cohort.hiddenChartTypes,
|
|
46
|
+
supportedChartTypes: tdb.q?.getSupportedChartTypes(auth),
|
|
48
47
|
renamedChartTypes: ds.cohort.renamedChartTypes,
|
|
49
48
|
allowedTermTypes: getAllowedTermTypes(ds),
|
|
50
49
|
termMatch2geneSet: tdb.termMatch2geneSet,
|
|
@@ -242,8 +241,8 @@ function getAllowedTermTypes(ds) {
|
|
|
242
241
|
mayComputeTermtypeByCohort(ds);
|
|
243
242
|
const typeSet = /* @__PURE__ */ new Set();
|
|
244
243
|
for (const r of ds.cohort.termdb.termtypeByCohort) {
|
|
245
|
-
if (r.
|
|
246
|
-
typeSet.add(r.
|
|
244
|
+
if (r.termType)
|
|
245
|
+
typeSet.add(r.termType);
|
|
247
246
|
}
|
|
248
247
|
if (ds.cohort.termdb.allowedTermTypes) {
|
|
249
248
|
for (const t of ds.cohort.termdb.allowedTermTypes)
|
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { read_file } from "#src/utils.js";
|
|
4
4
|
import run_R from "#src/run_R.js";
|
|
5
|
+
import { joinUrl } from "#src/helpers.ts";
|
|
5
6
|
import { run_rust } from "@sjcrh/proteinpaint-rust";
|
|
6
7
|
import serverconfig from "#src/serverconfig.js";
|
|
7
8
|
import { termdbSingleCellSamplesPayload } from "#types/checkers";
|
|
@@ -228,15 +229,19 @@ function gdc_validateGeneExpression(G, ds, genome) {
|
|
|
228
229
|
try {
|
|
229
230
|
const uuid = ds.__gdc.map2caseid.get(q.sample.sID);
|
|
230
231
|
const fileid = q.sample.eID;
|
|
232
|
+
const hdf5id = ds.__gdc.scrnaAnalysis2hdf5.get(fileid);
|
|
233
|
+
if (!hdf5id)
|
|
234
|
+
throw "cannot map eID to hdf5 id";
|
|
231
235
|
const aliasLst = genome.genedb.getAliasByName.all(q.gene);
|
|
232
236
|
const gencodeId = aliasLst.find((a) => a?.alias.toUpperCase().startsWith("ENSG"))?.alias;
|
|
237
|
+
if (!gencodeId)
|
|
238
|
+
throw "cannot map gene symbol to GENCODE";
|
|
233
239
|
const body = {
|
|
234
|
-
case_id: uuid,
|
|
235
240
|
gene_ids: [gencodeId],
|
|
236
|
-
file_id:
|
|
241
|
+
file_id: hdf5id
|
|
237
242
|
};
|
|
238
243
|
const { host } = ds.getHostHeaders(q);
|
|
239
|
-
const out = await ky.post(
|
|
244
|
+
const out = await ky.post(joinUrl(host.rest, "scrna_seq/gene_expression"), { timeout: false, json: body }).json();
|
|
240
245
|
const result = out.data[0].cells;
|
|
241
246
|
const data = {};
|
|
242
247
|
for (const r of result) {
|