Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #304 from vib-singlecell-nf/cellranger_updates
Browse files Browse the repository at this point in the history
Allow use of Cell Ranger 5.0+ options `no-bam` and `include-introns`
Add preflight check for providing a Cell Ranger container
Update prerequisite docs to include building Cell Ranger container
Add custom config for use at VSC
  • Loading branch information
KrisDavie authored Feb 17, 2021
2 parents 0d1f711 + 2fc382b commit ec1fb30
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 5 deletions.
1 change: 0 additions & 1 deletion conf/singularity.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
singularity {
enabled = true
autoMounts = true
runOptions = '-B /ddn1/vol1/staging/leuven/stg_00002/,/staging/leuven/stg_00002/'
}
14 changes: 14 additions & 0 deletions conf/vsc.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
params {
sc {
cellranger {
container = 'file:///staging/leuven/res_00001/software/vsn_containers/vibsinglecellnf-cellranger-5.0.1.img'
}
}
}

singularity {
enabled = true
autoMounts = true
runOptions = '--cleanenv -H $PWD -B /ddn1,/staging,/data,${VSC_SCRATCH}'
cacheDir = '/staging/leuven/res_00001/software/vsn_containers/'
}
5 changes: 5 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ Make sure you have the following software installed,
- Docker_
- Singularity_

**NOTE**: Due to licensing restrictions, to use the cellranger components of VSN you must build and/or provide a container with ``cellranger`` and ``bcl2fastq2`` installed yourself.
A sample ``Dockerfile`` can be found in ``./src/cellranger/``, you must download bcl2fastq2 from the Illumina_ website, and cellranger from the `10x Genomics`_ website yourself to build this container.

.. _Nextflow: https://www.nextflow.io/
.. _Docker: https://docs.docker.com/
.. _Singularity: https://www.sylabs.io/singularity/
.. _Illumina: https://emea.support.illumina.com/downloads/bcl2fastq-conversion-software-v2-20.html
.. _`10x Genomics`: https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/what-is-cell-ranger

Quick start
***********
Expand Down
4 changes: 4 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ profiles {
includeConfig 'conf/test__compute_resources.config'
}

vsc {
includeConfig 'conf/vsc.config'
}

}


Expand Down
2 changes: 1 addition & 1 deletion src/cellranger/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:buster-slim

ENV CELLRANGER_VER 3.1.0
ENV CELLRANGER_VER 5.0.1

# Pre-downloaded files:
# cellranger: https://support.10xgenomics.com/single-cell-gene-expression/software/downloads/latest
Expand Down
2 changes: 1 addition & 1 deletion src/cellranger/conf/base.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
params {
sc {
cellranger {
container = 'vibsinglecellnf/cellranger:3.1.0'
container = '/path/to/cellranger/cellranger'
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/cellranger/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ nextflow.enable.dsl=2
include {
SC__CELLRANGER__MKFASTQ;
} from './processes/mkfastq' params(params)
include {
SC__CELLRANGER__PREFLIGHT;
} from './processes/preflight' params(params)
include {
SC__CELLRANGER__COUNT;
} from './processes/count' params(params)
Expand All @@ -24,6 +27,7 @@ workflow CELLRANGER {
runFolder
transcriptome
main:
SC__CELLRANGER__PREFLIGHT()
data = MKFASTQ(mkfastq_csv, runFolder)

// Allow to combine old demultiplexed data with new data
Expand Down Expand Up @@ -54,6 +58,7 @@ workflow CELLRANGER {
workflow CELLRANGER_WITH_METADATA {

main:
SC__CELLRANGER__PREFLIGHT()
CELLRANGER_COUNT_WITH_METADATA(file("metadata_test.tsv"))

emit:
Expand Down
28 changes: 27 additions & 1 deletion src/cellranger/processes/count.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ def generateCellRangerCountCommandDefaults = {
} else if (processParams.containsKey('chemistry')) {
_chemistry = processParams.chemistry
}

def _includeIntrons = null
if(processParams.containsKey('includeIntrons')) {
if (processParams.includeIntrons == true) {
_includeIntrons = true
} else if (processParams.includeIntrons == false) {
_includeIntrons = false
} else {
throw new Exception("includeIntrons option must be a boolean (true | false)")
}
}

def _noBam = null
if(processParams.containsKey('noBam')) {
if (processParams.noBam == true) {
_noBam = true
} else if (processParams.noBam == false) {
_noBam = false
} else {
throw new Exception("noBam option must be a boolean (true | false)")
}
}
return (
"""
cellranger count \
Expand All @@ -38,6 +60,8 @@ def generateCellRangerCountCommandDefaults = {
${(processParams.containsKey('r1Length')) ? '--r1-length ' + processParams.r1Length: ''} \
${(processParams.containsKey('r2Length')) ? '--r2-length ' + processParams.r2Length: ''} \
${(processParams.containsKey('lanes')) ? '--lanes ' + processParams.lanes: ''} \
${_includeIntrons ? '--include-introns ': ''} \
${_noBam ? '--no-bam ': ''} \
--localcores=${task.cpus} \
--localmem=${task.memory.toGiga()} \
"""
Expand Down Expand Up @@ -148,7 +172,9 @@ process SC__CELLRANGER__COUNT_WITH_LIBRARIES {

csvData = "fastqs,sample,library_type\n"
fastqs.eachWithIndex { fastq, ix ->
csvData += "\$PWD/${fastq},${sampleNames[ix]},${assays[ix]}\n"
if (sampleNames[ix] != null) {
csvData += "\$PWD/${fastq},${sampleNames[ix]},${assays[ix]}\n"
}
}

"""
Expand Down
16 changes: 16 additions & 0 deletions src/cellranger/processes/preflight.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
nextflow.enable.dsl=2

toolParams = params.sc.cellranger

process SC__CELLRANGER__PREFLIGHT {

exec:
if (toolParams.containsKey('container')) {
if (toolParams.container == '/path/to/cellranger/cellranger' || toolParams.container == '') {
throw new Exception("You must specify a container image for Cellranger!")
}
} else {
throw new Exception("No container entry")
}

}
6 changes: 5 additions & 1 deletion src/cellranger/workflows/cellRangerCountWithLibraries.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import java.nio.file.Paths
include {
SC__CELLRANGER__COUNT_WITH_LIBRARIES;
} from './../processes/count' params(params)
include {
SC__CELLRANGER__PREFLIGHT;
} from './../processes/preflight' params(params)

//////////////////////////////////////////////////////
// Define the workflow
Expand Down Expand Up @@ -59,7 +62,8 @@ workflow CELLRANGER_COUNT_WITH_LIBRARIES {
)
}
.set { data }


SC__CELLRANGER__PREFLIGHT()
SC__CELLRANGER__COUNT_WITH_LIBRARIES( transcriptome, featureRef, data )

emit:
Expand Down
5 changes: 5 additions & 0 deletions src/cellranger/workflows/cellRangerCountWithMetadata.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ EMPTY_VALUES = ["n/a","n.a.","none","null"]
include {
SC__CELLRANGER__COUNT_WITH_METADATA;
} from './../processes/count' params(params)
include {
SC__CELLRANGER__PREFLIGHT;
} from './../processes/preflight' params(params)

//////////////////////////////////////////////////////
// Define the workflow
Expand Down Expand Up @@ -66,6 +69,8 @@ workflow CELLRANGER_COUNT_WITH_METADATA {
}
)
}

SC__CELLRANGER__PREFLIGHT()
SC__CELLRANGER__COUNT_WITH_METADATA( transcriptome, data )

emit:
Expand Down
5 changes: 5 additions & 0 deletions src/cellranger/workflows/cellranger_libraries.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import java.nio.file.Paths
include {
MKFASTQ
} from './mkfastq' params(params)
include {
SC__CELLRANGER__PREFLIGHT;
} from './../processes/preflight' params(params)
include {
SC__CELLRANGER__COUNT_WITH_LIBRARIES
} from './../processes/count' params(params)
Expand Down Expand Up @@ -65,6 +68,8 @@ workflow CELLRANGER_LIBRARIES {
.set { oldRunsData }

// Run MKFASTQ on current run
SC__CELLRANGER__PREFLIGHT()

data = MKFASTQ(mkfastq_csv, runFolder)

// Get Library info for MKFASTQ run from params
Expand Down
4 changes: 4 additions & 0 deletions src/cellranger/workflows/mkfastq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ nextflow.enable.dsl=2
include {
SC__CELLRANGER__MKFASTQ;
} from './../processes/mkfastq' params(params)
include {
SC__CELLRANGER__PREFLIGHT;
} from './../processes/preflight' params(params)

//////////////////////////////////////////////////////
// Define the workflow
Expand All @@ -20,6 +23,7 @@ workflow MKFASTQ {
mkfastq_csv
runFolder
main:
SC__CELLRANGER__PREFLIGHT()
SC__CELLRANGER__MKFASTQ(mkfastq_csv, runFolder)
.flatMap()
.map { fastq ->
Expand Down

0 comments on commit ec1fb30

Please sign in to comment.