Skip to content

Commit facf1a8

Browse files
authored
Merge pull request #225 from nf-core/ambient
Improve ambient RNA implementation
2 parents ff54c6b + 87a2937 commit facf1a8

File tree

26 files changed

+843
-395
lines changed

26 files changed

+843
-395
lines changed

assets/schema_input.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@
115115
"default": 0,
116116
"errorMessage": "Number of cells expected from the experimental design, used as input to cellbender.",
117117
"meta": ["expected_cells"]
118+
},
119+
"ambient_correction": {
120+
"type": "boolean",
121+
"default": true,
122+
"errorMessage": "'ambient_correction' must be a boolean.",
123+
"meta": ["ambient_correction"]
124+
},
125+
"ambient_corrected_integration": {
126+
"type": "boolean",
127+
"errorMessage": "'ambient_corrected_integration' must be a boolean.",
128+
"meta": ["ambient_corrected_integration"]
118129
}
119130
},
120131
"anyOf": [

conf/modules.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ process {
139139

140140
withName: '.*:AMBIENT_RNA_REMOVAL:CELLBENDER_MERGE' {
141141
ext.prefix = { meta.id + '_cellbender' }
142-
ext.output_layer = 'ambient'
143142
publishDir = [
144143
path: { "${params.outdir}/quality_control/ambient_rna_removal" },
145144
mode: params.publish_dir_mode,

docs/usage.md

Lines changed: 59 additions & 21 deletions
Large diffs are not rendered by default.

modules.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"cellbender/merge": {
1919
"branch": "master",
2020
"git_sha": "05954dab2ff481bcb999f24455da29a5828af08d",
21-
"installed_by": ["modules"]
21+
"installed_by": ["modules"],
22+
"patch": "modules/nf-core/cellbender/merge/cellbender-merge.diff"
2223
},
2324
"cellbender/removebackground": {
2425
"branch": "master",
@@ -43,7 +44,8 @@
4344
"scvitools/scar": {
4445
"branch": "master",
4546
"git_sha": "05954dab2ff481bcb999f24455da29a5828af08d",
46-
"installed_by": ["modules"]
47+
"installed_by": ["modules"],
48+
"patch": "modules/nf-core/scvitools/scar/scvitools-scar.diff"
4749
},
4850
"scvitools/solo": {
4951
"branch": "master",

modules/local/celda/decontx/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ process CELDA_DECONTX {
88
tuple val(meta), path(h5ad), path(raw)
99
val(batch_col)
1010
val(input_layer)
11+
val(output_layer)
1112

1213
output:
1314
tuple val(meta), path("*.h5ad"), emit: h5ad
@@ -18,7 +19,6 @@ process CELDA_DECONTX {
1819

1920
script:
2021
prefix = task.ext.prefix ?: "${meta.id}"
21-
output_layer = task.ext.output_layer ?: "decontXcounts"
2222
template 'decontx.R'
2323

2424
stub:

modules/local/celda/decontx/templates/decontx.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ corrected <- do.call(decontX, c(list(sce), params))
3232
adata_corrected <- as_AnnData(corrected)
3333

3434
# Convert back to AnnData and update layers
35-
adata\$layers["${output_layer}"] <- adata_corrected\$layers["decontXcounts"]
35+
if ("${output_layer}" == "X") {
36+
adata\$X <- adata_corrected\$layers[["decontXcounts"]]
37+
} else {
38+
adata\$layers[["${output_layer}"]] <- adata_corrected\$layers[["decontXcounts"]]
39+
}
3640

3741
# Save the output
3842
write_h5ad(adata, "${prefix}.h5ad")

modules/local/celda/decontx/tests/main.nf.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ nextflow_process {
2323
)
2424
input[1] = "sample"
2525
input[2] = "X"
26+
input[3] = "X"
2627
"""
2728
}
2829
}
@@ -57,6 +58,7 @@ nextflow_process {
5758
)
5859
input[1] = "sample"
5960
input[2] = "X"
61+
input[3] = "X"
6062
"""
6163
}
6264
}
@@ -91,6 +93,7 @@ nextflow_process {
9193
)
9294
input[1] = "sample"
9395
input[2] = "X"
96+
input[3] = "X"
9497
"""
9598
}
9699
}
@@ -120,6 +123,7 @@ nextflow_process {
120123
)
121124
input[1] = "sample"
122125
input[2] = "X"
126+
input[3] = "X"
123127
"""
124128
}
125129
}
@@ -155,6 +159,7 @@ nextflow_process {
155159
)
156160
input[1] = "sample"
157161
input[2] = "X"
162+
input[3] = "X"
158163
"""
159164
}
160165
}

modules/local/celda/decontx/tests/main.nf.test.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"versions.yml:md5,c546ef8ddb5673ef5f14e733d02de1d1"
1919
],
2020
true,
21-
20467768
21+
14391284
2222
],
2323
"meta": {
2424
"nf-test": "0.9.2",
2525
"nextflow": "25.04.6"
2626
},
27-
"timestamp": "2025-07-13T20:47:56.707357668"
27+
"timestamp": "2025-08-31T13:29:55.8622939"
2828
},
2929
"Should run without failures with raw - stub": {
3030
"content": [

modules/local/soupx/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ process SOUPX {
66

77
input:
88
tuple val(meta), path(h5ad), path(raw)
9+
val(cluster_resolution)
910
val(input_layer)
11+
val(output_layer)
1012

1113
output:
1214
tuple val(meta), path("${prefix}.h5ad"), emit: h5ad
@@ -17,8 +19,6 @@ process SOUPX {
1719

1820
script:
1921
prefix = task.ext.prefix ?: "${meta.id}"
20-
cluster_resolution = task.ext.cluster_resolution ?: 0.8
21-
output_layer = task.ext.output_layer ?: "ambient_corrected"
2222
template 'soupx.R'
2323

2424
stub:

modules/local/soupx/templates/soupx.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ sc <- autoEstCont(sc, doPlot = FALSE)
5757
out <- adjustCounts(sc, roundToInt = FALSE)
5858

5959
# Update the original AnnData object with ambient layer
60-
adata\$layers[["${output_layer}"]] <- t(out)
60+
if ("${output_layer}" == "X") {
61+
adata\$X <- t(out)
62+
} else {
63+
adata\$layers[["${output_layer}"]] <- t(out)
64+
}
6165

6266
# Save the output
6367
write_h5ad(adata, "${prefix}.h5ad")

0 commit comments

Comments
 (0)