Skip to content

Commit e34165e

Browse files
author
Habib Rehman
committed
Adding denoist method
1 parent 0c38992 commit e34165e

2 files changed

Lines changed: 43 additions & 19 deletions

File tree

src/methods_expression_correction/denoist_correction/config.vsh.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ references:
1212
doi: "10.1101/2025.11.13.688387"
1313

1414
arguments:
15+
- name: --input_ist
16+
direction: input
17+
required: true
18+
type: file
19+
1520
- name: --celltype_key
1621
required: false
1722
direction: input
@@ -23,12 +28,21 @@ arguments:
2328
direction: input
2429
type: integer
2530
default: 200
31+
description: Number of bins to use for hexagonal binning, which is used for calculating background transcript contamination
2632

2733
- name: --distance
2834
required: false
2935
direction: input
3036
type: integer
3137
default: 50
38+
description: Maximum distance to consider for local background estimation
39+
40+
- name: --keep_all_cells
41+
required: false
42+
direction: input
43+
type: boolean
44+
default: false
45+
description: Whether to keep cells with 0 counts (may cause errors if set to TRUE)
3246

3347

3448
resources:
@@ -43,21 +57,22 @@ engines:
4357
# run: |
4458
# apt-get update && apt-get install -y wget
4559
- type: r
46-
bioc: [anndataR, rhdf5, scuttle, DenoIST, devtools]
47-
#- type: r
48-
# bioc: [SummarizedExperiment,SingleCellExperiment,SpatialExperiment]
49-
# bioc_force_install: true
50-
# - type: docker
51-
# run: |
52-
# Rscript -e "BiocManager::install('SingleCellExperiment', type = 'source', force = TRUE, ask = FALSE); devtools::install_github('aaronkwc/DenoIST')"
60+
bioc: [anndataR, rhdf5, scuttle, devtools, DelayedMatrixStats]
61+
cran: [arrow]
62+
- type: r
63+
bioc: [SummarizedExperiment,SingleCellExperiment,SpatialExperiment]
64+
# bioc_force_install: true
65+
- type: docker
66+
run: |
67+
Rscript -e "BiocManager::install('SingleCellExperiment', type = 'source', force = TRUE, ask = FALSE); devtools::install_github('aaronkwc/DenoIST')"
5368
5469
# SingleCellExperiment part can probably be left out again in the future. It currently fixes a bug described in these issues:
5570
# https://github.com/drighelli/SpatialExperiment/issues/171
5671
# https://github.com/satijalab/seurat/issues/9889
5772
# The reinstall of SingleCellExperiment triggers the correct re-install of SpatialExperiment.
5873

59-
# Is there a better way to install an r package from github?
60-
# The 6 million timeout thing stops it from breaking
74+
# DenoIST is not available for bioconductor 3.22, only 3.23 :/
75+
# if bioconductor is updated, it should make things easier
6176

6277
- type: native
6378

src/methods_expression_correction/denoist_correction/script.R

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ library(SpatialExperiment)
44
library(SingleCellExperiment)
55
library(anndataR)
66
library(scuttle)
7+
library(arrow)
78

89
## VIASH START
910
par <- list(
1011
"input_spatial_with_cell_types" = "task_ist_preprocessing/resources_test/task_ist_preprocessing/mouse_brain_combined/spatial_aggregated_counts.h5ad",
11-
"input_tx" = "mouse_combined_transcripts.csv",
12-
"output" = "task_ist_preprocessing/tmp/split_corrected.h5ad",
12+
"input_ist" = "task_ist_preprocessing/resources_test/task_ist_preprocessing/mouse_brain_combined/raw_ist.zarr",
13+
"output" = "task_ist_preprocessing/tmp/denoist_corrected.h5ad",
1314
# "keep_all_cells" = FALSE,
1415
"distance" = 50,
1516
"nbins" = 200,
@@ -22,21 +23,29 @@ meta <- list(
2223
## VIASH END
2324

2425
# Read the input h5ad file and convert to SingleCellExperiment and Seurat
26+
cat("Reading input files\n")
2527
sce <- read_h5ad(par$input_spatial_with_cell_types, as = "SingleCellExperiment")
28+
29+
# filter out 0 cells
30+
if (!par$keep_all_cells) {
31+
cat("Filtering cells with 0 counts\n")
32+
sce <- sce[, colSums(counts(sce)) > 0]
33+
}
34+
2635
spe <- SpatialExperiment(
2736
assay = counts(sce),
2837
colData = colData(sce),
2938
spatialCoordsNames = c("centroid_x", "centroid_y"))
3039

31-
tx <- read.csv(par$input_tx)
32-
33-
# filter out 0 cells
34-
# if (!par$keep_all_cells) {
35-
# cat("Filtering cells with 0 counts\n")
36-
# sce <- sce[, colSums(counts(sce)) > 0]
37-
# xe <- subset(xe, subset = nCount_RNA > 0)
38-
# }
40+
# Read in transcripts
41+
tx_dataset <- arrow::open_dataset(file.path(par$input_ist, "points/transcripts/points.parquet"))
42+
tx <- as.data.frame((tx_dataset))
3943

44+
#If no QV column
45+
if(!("qv" %in% names(tx))) {
46+
cat("QV column not found, adding dummy column of 20 (should be unecessary in future updates?)")
47+
tx["qv"] <- 20
48+
}
4049

4150
# check cores
4251
cores <- 1

0 commit comments

Comments
 (0)