snakemake-workflows/single-cell-counts-preprocessing
A standardised Snakemake workflow for preprocessing of single-cell RNAseq count data following single-cell best practices.
Overview
Latest release: None, Last update: 2026-09-19
Quality control: linting: passed formatting: passed
Deployment
Step 1: Install Snakemake and Snakedeploy
Snakemake and Snakedeploy are best installed via the Conda package manager. It is recommended to install conda via Miniforge. Run
conda create -c conda-forge -c bioconda -c nodefaults --name snakemake snakemake snakedeploy
to install both Snakemake and Snakedeploy in an isolated environment. For all following commands ensure that this environment is activated via
conda activate snakemake
For other installation methods, refer to the Snakemake and Snakedeploy documentation.
Step 2: Deploy workflow
With Snakemake and Snakedeploy installed, the workflow can be deployed as follows. First, create an appropriate project working directory on your system and enter it:
mkdir -p path/to/project-workdir
cd path/to/project-workdir
In all following steps, we will assume that you are inside of that directory. Then run
snakedeploy deploy-workflow https://github.com/snakemake-workflows/single-cell-counts-preprocessing . --tag None
Snakedeploy will create two folders, workflow and config. The former contains the deployment of the chosen workflow as a Snakemake module, the latter contains configuration files which will be modified in the next step in order to configure the workflow to your needs.
Step 3: Configure workflow
To configure the workflow, adapt config/config.yml to your needs following the instructions below.
Step 4: Run workflow
The deployment method is controlled using the --software-deployment-method (short --sdm) argument.
To run the workflow using apptainer/singularity, use
snakemake --cores all --sdm apptainer
To run the workflow using a combination of conda and apptainer/singularity for software deployment, use
snakemake --cores all --sdm conda apptainer
To run the workflow with automatic deployment of all required software via conda/mamba, use
snakemake --cores all --sdm conda
Snakemake will automatically detect the main Snakefile in the workflow subfolder and execute the workflow module that has been defined by the deployment in step 2.
For further options such as cluster and cloud execution, see the docs.
Step 5: Generate report
After finalizing your data analysis, you can automatically generate an interactive visual HTML report for inspection of results together with parameters and code inside of the browser using
snakemake --report report.zip
Configuration
The following section is imported from the workflow’s config/README.md.
Workflow overview
This workflow is a best-practice workflow for preprocessing counts from single cell RNA sequencing data.
The workflow is built using snakemake and follows the Preprocessing and visualization section of the Single Cell Best Practices.
It consists of the following steps:
Convert input data to
zarrformat.Filter low-quality barcodes with
scanpy.Correct for ambient RNA contamination with
SoupX.Detect doublets with
scDblFinder.Normalize counts with
scanpy.
Running the workflow
To configure the workflow run, go through the provided config/config.yaml entry by entry and adjust them where necessary.
After an initial run, we recommend going through the quality control plots mentioned there and double-checking that the provided threshold values for filtering make sense.
Input data
To specify the input, provide a config/sample_sheet.tsv file with the following layout:
sample_id |
raw_counts_path |
format |
|---|---|---|
cellranger_1 |
../path/to/raw_feature_bc_matrix/ |
10x_mtx |
kallisto_bustools_1 |
../path/to/adata.h5ad |
h5ad |
alevin_fry_1 |
../path/to/quants_mat.mtx |
mtx |
Here, the columns are:
sample_id: An arbitrary string identifier of a a sample (or dataset).raw_counts_path: The path to a file or folder with the raw counts as determined by another tool, for exampleCellRanger,kallisto bustoolsoralevin-fry. We really recommend using the raw counts here (and not any pre-filtered counts), as they are instrumental in the correction for ambient RNA contamination. The workflow filters low-quality barcodes itself, and lets you transparently configure and check the filter thresholds (see the comments inconfig/config.yaml).format: Format of the input data given in columnraw_counts_path. Choose a format that scanpy can read, so any suffix in one of thescanpy.read_functions. See https://scanpy.scverse.org/en/stable/api/io.html or double-check the code at: https://github.com/scverse/scanpy/blob/a656a33b080a5c1f64b01e841daad76f35f5ec5f/src/scanpy/io/_read.py#L44-L61”
Workflow parameters
The following table is automatically parsed from the workflow’s config.schema.y(a)ml file.
Parameter |
Type |
Description |
Required |
Default |
|---|---|---|---|---|
sample_sheet |
string |
path to sample sheet, mandatory |
yes |
config/sample_sheet.tsv |
filtering |
yes |
|||
. counts_mads |
integer |
Median absolute deviation (MAD) of three counts quality control values, above which a cell is considered an outlier. |
yes |
5 |
. mt_percent |
integer |
Median absolute deviation (MAD) of mitochondrial counts percentage from all counts, above which a cell is considered an outlier. |
yes |
5 |
Linting and formatting
Linting results
All tests passed!
Formatting results
All tests passed!