The merged workflow supports two input modes:
paired_fastqmode: discover paired FASTQ files matching*_R1.fq.gzand*_R2.fq.gz.demuxmode: preprocess primer and Tn5 annotation tables, normalize raw sciCUT&Tag FASTQ headers, and demultiplexR1/R2/I1/I2input files withsciCTextract.- Optionally exclude samples by filename using configurable patterns.
- Optionally rewrite FASTQ headers to replace
(s7, s5)barcode pairs withWell-ID. - Trim adapters with Cutadapt.
- Align paired reads with Bowtie2.
- Convert SAM to BAM.
- Convert BAM to a deduplicated BED-like fragment file and compress it with
bgzip. - Generate a normalized BigWig track from the BED file.
main.nf: Nextflow workflow definition.nextflow.config: defaults for resources and executors.bin/modify_scict_header.sh: generic header normalization used indemuxmode.bin/rewrite_fastq_barcodes: wrapper that prefers the compiled C++ binary.bin/rewrite_fastq_barcodes.py: barcode rewrite script extracted from the notebook.src/rewrite_fastq_barcodes.cpp: fast C++ implementation for barcode rewriting.tools/build_rewrite_fastq_barcodes.sh: build script for the C++ binary.envs/cuttag-preprocess.yml: Conda environment for all required tools.
The pipeline expects these commands to be available in your environment:
nextflow
If you use the conda profile, the workflow will create the software environment automatically from envs/cuttag-preprocess.yml.
The environment pins Python 3.10 for compatibility with Cutadapt 4.3.
For faster barcode rewriting, build the compiled helper once:
./tools/build_rewrite_fastq_barcodes.shThe wrapper used by Nextflow prefers the compiled binary and falls back to Python only if the binary is unavailable.
--input_mode:paired_fastqordemux.--input_dir: directory containing paired FASTQ files.--ref: Bowtie2 index basename.--chrom_sizes: chromosome sizes file for BigWig generation.
For demux mode, the required inputs are:
--primer_annot--tn5_annot--fastq1--fastq2--umi1--umi2--demux_min_reads--demux_swap_index_ends
The --tn5_annot input should be supplied as a CSV file.
Barcode rewriting is enabled by default and also requires:
--barcode_matrix: CSV with columnsPAGE-1-s7,PAGE-1-s5,PAGE-2-s7,PAGE-2-s5,Well-ID
For the current sciCUT&Tag data layout used in testing, the index reads are arranged as I1 = i7 ... j7 and I2 = j5 ... i5, while sciCTextract expects I1 = j7 ... i7 and I2 = i5 ... j5. The workflow therefore swaps the first and last 8 bases of I1/I2 by default before demultiplexing. Disable this only for data already matching the native sciCTextract layout:
--demux_swap_index_ends falseThe filename filter is enabled by default and excludes sample names containing: By default, no filename patterns are excluded.
Disable filename-based filtering entirely:
--enable_sample_filter falseOverride the default exclusion patterns with a comma-separated list:
--skip_patterns PosCtrl,NegCtrl,MyControlRun locally:
nextflow run main.nf \
--input_mode paired_fastq \
--input_dir /path/to/fastq \
--barcode_matrix /path/to/barcode_matrix.csv \
--ref /path/to/bowtie2/index_basename \
--chrom_sizes /path/to/genome.chrom.sizes \
--out_dir resultsRun with Conda:
nextflow run main.nf -profile conda \
--input_mode paired_fastq \
--input_dir /path/to/fastq \
--barcode_matrix /path/to/barcode_matrix.csv \
--ref /path/to/bowtie2/index_basename \
--chrom_sizes /path/to/genome.chrom.sizes \
--out_dir resultsRun on SLURM:
nextflow run main.nf -profile slurm \
--input_mode paired_fastq \
--input_dir /path/to/fastq \
--barcode_matrix /path/to/barcode_matrix.csv \
--ref /path/to/bowtie2/index_basename \
--chrom_sizes /path/to/genome.chrom.sizes \
--out_dir resultsRun on SLURM with Conda:
nextflow run main.nf -profile slurm,conda \
--input_mode paired_fastq \
--input_dir /path/to/fastq \
--barcode_matrix /path/to/barcode_matrix.csv \
--ref /path/to/bowtie2/index_basename \
--chrom_sizes /path/to/genome.chrom.sizes \
--out_dir resultsRun in demux mode:
nextflow run main.nf -profile slurm,conda \
--input_mode demux \
--primer_annot /path/to/Primer_Annotation.csv \
--tn5_annot /path/to/Tn5_Barcode_Annotation.csv \
--fastq1 /path/to/sample_R1.fastq.gz \
--fastq2 /path/to/sample_R2.fastq.gz \
--umi1 /path/to/sample_I1.fastq.gz \
--umi2 /path/to/sample_I2.fastq.gz \
--demux_min_reads 10000 \
--barcode_matrix /path/to/barcode_matrix.csv \
--ref /path/to/bowtie2/index_basename \
--chrom_sizes /path/to/genome.chrom.sizes \
--out_dir results- The pipeline keeps the same adapter sequence and Bowtie2 arguments used in the existing shell script.
- The merged workflow can run either from already demultiplexed paired FASTQs or from raw sciCUT&Tag demultiplexing inputs.
- The
demuxmode uses a generic FASTQ header normalizer instead of the previousModifyHeader.shlogic that depended on a specific instrument prefix. - The
demuxhandoff flattens thesciCTextractfile list and matches*_R1.fq.gzand*_R2.fq.gzoutputs explicitly before downstream processing. - The barcode rewrite step is a required part of the workflow and prefers a compiled C++ implementation for speed, while preserving the original Python code as a fallback.
- The alignment step preserves the original high-memory setting (
256 GB,16 CPUs,18h) but these can be changed innextflow.config. - Intermediate files are published into subdirectories under
--out_dir. - Sample-name filtering is configurable through
--enable_sample_filterand--skip_patterns, but no samples are excluded unless patterns are provided explicitly.