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 Cellsnp to modules #5518

Merged
merged 22 commits into from
May 8, 2024
9 changes: 9 additions & 0 deletions modules/nf-core/cellsnp/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "cellsnp"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::cellsnp-lite=1.2.3"
67 changes: 67 additions & 0 deletions modules/nf-core/cellsnp/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
process CELLSNP {
tag "$meta.id"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/cellsnp-lite:1.2.3--h6141fd1_2' :
'biocontainers/cellsnp-lite:1.2.3--h6141fd1_2' }"

input:
tuple val(meta), path(bam), path(bai), path(region_vcf), path(barcode), path(sample_list)
wxicu marked this conversation as resolved.
Show resolved Hide resolved

output:
tuple val(meta), path('*/cellSNP.base.vcf.gz') , emit: base
tuple val(meta), path('*/cellSNP.cells.vcf.gz') , emit: cell, optional: true
tuple val(meta), path('*/cellSNP.samples.tsv') , emit: sample
tuple val(meta), path('*/cellSNP.tag.AD.mtx') , emit: allele_depth
tuple val(meta), path('*/cellSNP.tag.DP.mtx') , emit: depth_coverage
tuple val(meta), path('*/cellSNP.tag.OTH.mtx') , emit: depth_other
path 'versions.yml' , emit: versions
wxicu marked this conversation as resolved.
Show resolved Hide resolved

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def barcode_file = barcode ? "-b $barcode" : ''
def region_file = region_vcf ? "-R $region_vcf" : ''
def sample = sample_list ? "-I $sample_list" : ''
wxicu marked this conversation as resolved.
Show resolved Hide resolved

"""
cellsnp-lite -s $bam \\
$barcode_file \\
$region_file \\
$sample \\
-O $prefix --gzip \\
wxicu marked this conversation as resolved.
Show resolved Hide resolved
--nproc $task.cpus \\
$args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
cellsnp: \$(cellsnp-lite --v | awk '{print \$2}')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def barcode_file = barcode ? "-b $barcode" : ''
def region_file = region_vcf ? "-R $region_vcf" : ''
def sample = sample_list ? "-I $sample_list" : ''
wxicu marked this conversation as resolved.
Show resolved Hide resolved

"""
mkdir $prefix
touch $prefix/cellSNP.base.vcf.gz
touch $prefix/cellSNP.samples.tsv
touch $prefix/cellSNP.tag.AD.mtx
touch $prefix/cellSNP.tag.DP.mtx
touch $prefix/cellSNP.tag.OTH.mtx

cat <<-END_VERSIONS > versions.yml
"${task.process}":
cellsnp: \$(cellsnp-lite --v | awk '{print \$2}')
END_VERSIONS
"""
}
85 changes: 85 additions & 0 deletions modules/nf-core/cellsnp/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "cellsnp"
description: Cellsnp-lite is a C/C++ tool for efficient genotyping bi-allelic SNPs on single cells. You can use cellsnp-lite after read alignment to obtain the snp x cell pileup UMI or read count matrices for each alleles of given or detected SNPs.
keywords:
- genotyping
- single cell
- SNP
tools:
- "cellsnp":
description: "Efficient genotyping bi-allelic SNPs on single cells"
homepage: "https://github.com/single-cell-genetics/cellsnp-lite"
documentation: "https://cellsnp-lite.readthedocs.io"
tool_dev_url: "https://github.com/single-cell-genetics/cellsnp-lite"
doi: "10.1093/bioinformatics/btab358"
licence: ["Apache-2.0"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`

- bam:
type: file
description: Indexed BAM/CRAM file(s), comma separated multiple samples.
wxicu marked this conversation as resolved.
Show resolved Hide resolved
pattern: "*.{bam,cram,sam}"
- bai:
type: file
description: Index of the BAM/CRAM file.
wxicu marked this conversation as resolved.
Show resolved Hide resolved
pattern: "*.{bai,crai}"
- region_vcf:
type: file
description: A vcf file listing all candidate SNPs, for fetch each variants.
pattern: "*.{vcf, vcf.gz}"
- barcode:
type: file
description: A plain file listing all effective cell barcodes.
pattern: "*.tsv"
- sample_list:
type: file
description: A list file containing sample IDs, each per line.

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1']`

- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

- base:
type: file
description: A VCF file listing genotyped SNPs and aggregated AD & DP infomation (without GT).
pattern: "*.base.vcf.gz"
- cell:
type: file
description: A VCF file listing genotyped SNPs and aggregated AD & DP infomation & genotype (GT) information for each cell or sample.
pattern: "*.cells.vcf.gz"
- sample:
type: file
description: A TSV file listing cell barcodes or sample IDs.
pattern: "*.tsv"
- allele_depth:
type: file
description: A file in “Matrix Market exchange formats”, containing the allele depths of the alternative (ALT) alleles.
pattern: "*.tag.AD.mtx"
- depth_coverage:
type: file
description: A file in “Matrix Market exchange formats”, containing the sum of allele depths of the reference and alternative alleles (REF + ALT).
pattern: "*.tag.DP.mtx"
- depth_other:
type: file
description: A file in “Matrix Market exchange formats”, containing the sum of allele depths of all the alleles other than REF and ALT.
pattern: "*.tag.OTH.mtx"

authors:
- "@wxicu"
maintainers:
- "@wxicu"
90 changes: 90 additions & 0 deletions modules/nf-core/cellsnp/tests/main.nf.test
wxicu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// nf-core modules test cellsnp
nextflow_process {

name "Test Process CELLSNP"
script "../main.nf"
process "CELLSNP"

tag "modules"
tag "modules_nfcore"
tag "cellsnp"
tag "samtools/index"

test("genotyping") {
setup {
run("SAMTOOLS_INDEX") {
script "../../samtools/index/main.nf"
process {
"""
input[0] = [
[ id:'sample1' ],
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/chr21.bam', checkIfExists: true) ]
"""
}
}
}

when {
process {
"""
input[0] = SAMTOOLS_INDEX.out.bai.collect{ meta, bai -> bai }.map{
bai -> [[ id: 'sample1'],
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/chr21.bam', checkIfExists: true),
bai,
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/donor_genotype_chr21.vcf', checkIfExists: true),
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/barcodes.tsv', checkIfExists: true),
[]
]}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match("versions") },
{ assert path(process.out.base.get(0).get(1)).exists() },
{ assert path(process.out.sample.get(0).get(1)).exists() },
{ assert path(process.out.allele_depth.get(0).get(1)).exists() },
{ assert path(process.out.depth_coverage.get(0).get(1)).exists() },
{ assert path(process.out.depth_other.get(0).get(1)).exists() }
wxicu marked this conversation as resolved.
Show resolved Hide resolved
)
}

}

test("genotyping - stub") {

options "-stub"

when {
process {
"""

input[0] = [
[ id:'sample1'], // meta map
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/chr21.bam', checkIfExists: true),
[],
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/donor_genotype_chr21.vcf', checkIfExists: true),
file(params.modules_testdata_base_path + '/genomics/homo_sapiens/demultiplexing/barcodes.tsv', checkIfExists: true),
[]
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match("versions-stub") },
{ assert path(process.out.base.get(0).get(1)).exists() },
{ assert path(process.out.sample.get(0).get(1)).exists() },
{ assert path(process.out.allele_depth.get(0).get(1)).exists() },
{ assert path(process.out.depth_coverage.get(0).get(1)).exists() },
{ assert path(process.out.depth_other.get(0).get(1)).exists() }
)
wxicu marked this conversation as resolved.
Show resolved Hide resolved
}

}

}
26 changes: 26 additions & 0 deletions modules/nf-core/cellsnp/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"versions": {
"content": [
[
"versions.yml:md5,89366928a2dbfad795438e38c7ef8695"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-24T10:01:10.254512578"
},
"versions-stub": {
"content": [
[
"versions.yml:md5,89366928a2dbfad795438e38c7ef8695"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-24T10:01:50.522835434"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/cellsnp/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cellsnp:
- "modules/nf-core/cellsnp/**"
Loading