@sjcrh/proteinpaint-server 2.40.8 → 2.41.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
package/routes/termdb.cluster.ts
CHANGED
|
@@ -104,9 +104,7 @@ async function doClustering(data: any, q: TermdbClusterRequest) {
|
|
|
104
104
|
const Rinputfile = path.join(serverconfig.cachedir, Math.random().toString() + '.json')
|
|
105
105
|
await utils.write_file(Rinputfile, JSON.stringify(inputData))
|
|
106
106
|
const Routput = JSON.parse(await lines2R(path.join(serverconfig.binpath, 'utils/hclust.R'), [], [Rinputfile]))
|
|
107
|
-
fs.unlink(Rinputfile
|
|
108
|
-
return
|
|
109
|
-
})
|
|
107
|
+
await fs.promises.unlink(Rinputfile)
|
|
110
108
|
|
|
111
109
|
const row_names_index: number[] = Routput.RowOrder.map(row => inputData.row_names.indexOf(row.name)) // sorted rows. value is array index in input data
|
|
112
110
|
const col_names_index: number[] = Routput.ColOrder.map(col => inputData.col_names.indexOf(col.name)) // sorted columns, value is array index from input array
|
|
@@ -184,16 +182,6 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
|
|
|
184
182
|
console.log(q.samples.length, 'samples from geneExpression of', ds.label)
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
/*
|
|
188
|
-
query exp data one gene at a time
|
|
189
|
-
param{}
|
|
190
|
-
.genes[{}]
|
|
191
|
-
.gene=str
|
|
192
|
-
.chr=str
|
|
193
|
-
.start=int
|
|
194
|
-
.stop=int
|
|
195
|
-
.filterObj{}
|
|
196
|
-
*/
|
|
197
185
|
q.get = async (param: TermdbClusterRequest) => {
|
|
198
186
|
const limitSamples = await mayLimitSamples(param, q.samples, ds)
|
|
199
187
|
if (limitSamples?.size == 0) {
|
|
@@ -216,6 +204,7 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
|
|
|
216
204
|
}
|
|
217
205
|
}
|
|
218
206
|
|
|
207
|
+
// only valid genes with data are added. invalid genes or genes missing from data file is not added. backend returned genes is allowed to be fewer than supplied by client
|
|
219
208
|
const gene2sample2value = new Map() // k: gene symbol, v: { sampleId : value }
|
|
220
209
|
|
|
221
210
|
for (const g of param.genes) {
|
|
@@ -232,7 +221,7 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
|
|
|
232
221
|
g.chr = j.chr
|
|
233
222
|
}
|
|
234
223
|
|
|
235
|
-
|
|
224
|
+
const s2v = {}
|
|
236
225
|
await utils.get_lines_bigfile({
|
|
237
226
|
args: [q.file, (q.nochr ? g.chr?.replace('chr', '') : g.chr) + ':' + g.start + '-' + g.stop], // must do g.chr?.replace to avoid tsc error
|
|
238
227
|
callback: line => {
|
|
@@ -242,14 +231,15 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
|
|
|
242
231
|
for (let i = 4; i < l.length; i++) {
|
|
243
232
|
const sampleId = samples[i - 4]
|
|
244
233
|
if (limitSamples && !limitSamples.has(sampleId)) continue // doing filtering and sample of current column is not used
|
|
245
|
-
|
|
234
|
+
if (!l[i]) continue // blank string
|
|
246
235
|
const v = Number(l[i])
|
|
247
236
|
if (Number.isNaN(v)) throw 'exp value not number'
|
|
248
|
-
|
|
237
|
+
s2v[sampleId] = v
|
|
249
238
|
}
|
|
250
239
|
}
|
|
251
240
|
} as any)
|
|
252
241
|
// Above!! add "as any" to suppress a npx tsc alert
|
|
242
|
+
if (Object.keys(s2v).length) gene2sample2value.set(g.gene, s2v) // only add gene if has data
|
|
253
243
|
}
|
|
254
244
|
// pass blank byTermId to match with expected output structure
|
|
255
245
|
const byTermId = {}
|
|
@@ -152,15 +152,16 @@ function validateDataNative(D: SingleCellDataNative, ds: any) {
|
|
|
152
152
|
const cellId = l[0],
|
|
153
153
|
x = Number(l[4]), // FIXME standardize, or define idx in plot
|
|
154
154
|
y = Number(l[5])
|
|
155
|
+
const category = l[plot.colorColumn?.index] || ''
|
|
155
156
|
if (!cellId) throw 'cell id missing'
|
|
156
157
|
if (!Number.isFinite(x) || !Number.isFinite(y)) throw 'x/y not number'
|
|
157
|
-
cells.push({ cellId, x, y })
|
|
158
|
+
cells.push({ cellId, x, y, category })
|
|
158
159
|
|
|
159
160
|
for (const tid of D.termIds) {
|
|
160
161
|
tid2cellvalue[tid][cellId] = l[1]
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
plots.push({ name: plot.name, cells })
|
|
164
|
+
plots.push({ name: plot.name, cells, colorBy: plot.colorColumn?.name })
|
|
164
165
|
}
|
|
165
166
|
if (plots.length == 0) {
|
|
166
167
|
// no data available for this sample
|