@sjcrh/proteinpaint-server 2.65.0 → 2.66.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 +2 -2
- package/routes/termdb.categories.js +3 -0
- package/routes/termdb.cluster.js +6 -2
- package/routes/termdb.config.js +6 -1
- package/routes/termdb.singlecellSamples.js +30 -46
- package/routes/termdb.topVariablyExpressedGenes.js +12 -12
- package/src/app.js +358 -275
- package/utils/getGeneFromMatrix.R +40 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
library(jsonlite)
|
|
2
|
+
library(Matrix)
|
|
3
|
+
|
|
4
|
+
# This script assumes the .Rds file is a gene
|
|
5
|
+
# by sample matrix. Use this script to extract
|
|
6
|
+
# the values per sample for a particular gene.
|
|
7
|
+
|
|
8
|
+
args <- commandArgs(trailingOnly = TRUE)
|
|
9
|
+
if (length(args) == 0) {
|
|
10
|
+
stop("No arguments provided.")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# str
|
|
14
|
+
file_path <- args[1]
|
|
15
|
+
# str
|
|
16
|
+
gene_name <- args[2]
|
|
17
|
+
|
|
18
|
+
data <- tryCatch({
|
|
19
|
+
readRDS(file_path)
|
|
20
|
+
}, error = function(e) {
|
|
21
|
+
# Show error if file is not found or cannot be read
|
|
22
|
+
# (i.e. not an RDS file)
|
|
23
|
+
stop(paste("Error reading RDS file:", e$message))
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
# Show error if gene not found
|
|
27
|
+
if (!(gene_name %in% rownames(data))) {
|
|
28
|
+
stop(paste("Gene", gene_name, "not found in the matrix."))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Extract the gene data and filter out zero values
|
|
32
|
+
gene_data <- data[gene_name, ]
|
|
33
|
+
non_zero_indices <- gene_data != 0
|
|
34
|
+
filtered_samples <- colnames(data)[non_zero_indices]
|
|
35
|
+
filtered_values <- as.numeric(gene_data[non_zero_indices])
|
|
36
|
+
|
|
37
|
+
# Create a JSON object with the samples as the keys and the
|
|
38
|
+
# values as the values, e.g. {"sample1": 1, "sample2": 2, ...n }
|
|
39
|
+
result <- setNames(as.list(filtered_values), filtered_samples)
|
|
40
|
+
toJSON(result, pretty = TRUE, auto_unbox = TRUE)
|