@sjcrh/proteinpaint-server 2.81.4-0 → 2.81.5-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 +1 -1
- package/routes/termdb.cluster.js +8 -3
- package/src/app.js +18 -8
package/package.json
CHANGED
package/routes/termdb.cluster.js
CHANGED
|
@@ -72,18 +72,21 @@ async function getResult(q, ds) {
|
|
|
72
72
|
return { term: { gene: g, type: TermTypes.GENE_EXPRESSION }, data: term2sample2value.get(g) };
|
|
73
73
|
}
|
|
74
74
|
const t = Date.now();
|
|
75
|
-
const clustering = await doClustering(term2sample2value, q);
|
|
75
|
+
const clustering = await doClustering(term2sample2value, q, Object.keys(bySampleId).length);
|
|
76
76
|
if (serverconfig.debugmode)
|
|
77
77
|
console.log("clustering done:", Date.now() - t, "ms");
|
|
78
78
|
return { clustering, byTermId, bySampleId };
|
|
79
79
|
}
|
|
80
|
-
async function doClustering(data, q) {
|
|
80
|
+
async function doClustering(data, q, numCases = 1e3) {
|
|
81
81
|
const sampleSet = /* @__PURE__ */ new Set();
|
|
82
82
|
for (const o of data.values()) {
|
|
83
83
|
for (const s in o)
|
|
84
84
|
sampleSet.add(s);
|
|
85
|
-
|
|
85
|
+
if (sampleSet.size >= numCases)
|
|
86
|
+
break;
|
|
86
87
|
}
|
|
88
|
+
if (sampleSet.size == 0)
|
|
89
|
+
throw "termdb.cluster: no samples";
|
|
87
90
|
if (!clusterMethodLst.find((i) => i.value == q.clusterMethod))
|
|
88
91
|
throw "Invalid cluster method";
|
|
89
92
|
if (!distanceMethodLst.find((i) => i.value == q.distanceMethod))
|
|
@@ -107,6 +110,8 @@ async function doClustering(data, q) {
|
|
|
107
110
|
}
|
|
108
111
|
inputData.matrix.push(getZscore(row));
|
|
109
112
|
}
|
|
113
|
+
if (inputData.matrix.length == 0)
|
|
114
|
+
throw "Clustering matrix is empty";
|
|
110
115
|
const Routput = JSON.parse(
|
|
111
116
|
await run_R(path.join(serverconfig.binpath, "utils", "hclust.R"), JSON.stringify(inputData))
|
|
112
117
|
);
|