Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scds module #6907

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
7 changes: 7 additions & 0 deletions modules/nf-core/scds/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::bioconductor-scds=1.18.0
- conda-forge::r-seurat=5.1.0
nictru marked this conversation as resolved.
Show resolved Hide resolved
- conda-forge::r-xgboost=1.7.6
33 changes: 33 additions & 0 deletions modules/nf-core/scds/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
process SCDS {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/bioconductor-scds:1.18.0--r43hdfd78af_0':
'biocontainers/bioconductor-scds:1.18.0--r43hdfd78af_0' }"

input:
tuple val(meta), path(rds)

output:
tuple val(meta), path("*.rds"), emit: rds
LeonHafner marked this conversation as resolved.
Show resolved Hide resolved
tuple val(meta), path("*.csv"), emit: predictions
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
prefix = task.ext.prefix ?: "${meta.id}"
template 'scds.R'

stub:
def args = task.ext.args ?: ''
nictru marked this conversation as resolved.
Show resolved Hide resolved
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.rds
touch ${prefix}.csv
touch versions.yml
nictru marked this conversation as resolved.
Show resolved Hide resolved
"""
}
59 changes: 59 additions & 0 deletions modules/nf-core/scds/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: scds
description: Module to use scds for doublet scoring
keywords:
- doublet
- single-cell
- transcriptomics
tools:
- scds:
description: scds is an in-silico doublet annotation tool for single cell RNA sequencing data
homepage: https://www.bioconductor.org/packages/release/bioc/html/scds.html
documentation: https://www.bioconductor.org/packages/release/bioc/vignettes/scds/inst/doc/scds.html
tool_dev_url: https://github.com/kostkalab/scds
doi: 10.1093/bioinformatics/btz698
licence: ["MIT"]
identifier: biotools:scds

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- rds:
type: file
description: RDS file containing filtered data (without empty droplets) in SingleCellExperiment format
pattern: "*.rds"

output:
- rds:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- "*.rds":
type: file
description: RDS file containing doublet scores in SingleCellExperiment format
pattern: "*.rds"
- predictions:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- "*.csv":
type: file
description: CSV file containing doublet scores
pattern: "*.csv"
- versions:
- versions.yml:
type: file
description: File containing software version
pattern: "versions.yml"

authors:
- "@cakirb"
maintainers:
- "@cakirb"
53 changes: 53 additions & 0 deletions modules/nf-core/scds/templates/scds.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env Rscript

library(scds)
library(SingleCellExperiment)

sce <- readRDS("${rds}")

sce <- Seurat::as.SingleCellExperiment(sce)

## Annotate doublet using binary classification based doublet scoring:
sce <- bcds(sce, retRes = TRUE, estNdbl=TRUE)

## Annotate doublet using co-expression based doublet scoring:
try({
sce <- cxds(sce, retRes = TRUE, estNdbl=TRUE)
})

### If cxds worked, run hybrid, otherwise use bcds annotations
if ("cxds_score" %in% colnames(colData(sce))) {
## Combine both annotations into a hybrid annotation
sce <- cxds_bcds_hybrid(sce, estNdbl=TRUE)

predictions <- colData(sce)[, 'hybrid_call', drop=FALSE]
} else {
predictions <- colData(sce)[, 'bcds_call', drop=FALSE]
}

saveRDS(sce, "${prefix}.rds")

colnames(predictions) <- "${prefix}"
write.csv(predictions, "${prefix}.csv")

################################################
################################################
## VERSIONS FILE ##
################################################
################################################

r.version <- strsplit(version[['version.string']], ' ')[[1]][3]
scds.version <- as.character(packageVersion('scds'))

writeLines(
c(
'"${task.process}":',
paste(' R:', r.version),
nictru marked this conversation as resolved.
Show resolved Hide resolved
paste(' scds:', scds.version)
),
'versions.yml')

################################################
################################################
################################################
################################################
nictru marked this conversation as resolved.
Show resolved Hide resolved
52 changes: 52 additions & 0 deletions modules/nf-core/scds/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
nextflow_process {
name 'Test Process SCDS'
script '../main.nf'
process 'SCDS'

tag "modules"
tag "modules_nfcore"
tag "scds"

test("test_scds") {
when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file("https://raw.githubusercontent.com/nf-core/test-datasets/scdownstream/samples/SAMN14430801_custom_emptydrops_filter_matrix.rds", checkIfExists: true) ]
"""
}
}
then {
assertAll(
{assert process.success},
{assert snapshot(process.out.rds).match("res_scds_rds")},
{assert snapshot(process.out.csv).match("res_scds_csv")},
{assert snapshot(process.out.versions).match("res_scds_versions")}
)
}
}

test("test_scds - stub") {
options '-stub'

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file("https://raw.githubusercontent.com/nf-core/test-datasets/scdownstream/samples/SAMN14430801_custom_emptydrops_filter_matrix.rds", checkIfExists: true) ]
]
"""
}
}
then {
assertAll(
{assert process.success},
{assert snapshot(process.out.rds).match("res_scds_rds_stub")},
{assert snapshot(process.out.csv).match("res_scds_csv_stub")},
{assert snapshot(process.out.versions).match("res_scds_versions_stub")}
)
}
}
}
34 changes: 34 additions & 0 deletions modules/nf-core/scds/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"res_scds_csv": {
"content": null,
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T11:50:55.821158"
},
"res_scds_versions": {
"content": [
[

]
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T11:50:55.827718"
},
"res_scds_rds": {
"content": [
[

]
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T11:50:55.808717"
}
}
Loading