From 8abe31bb686e72e5073b6a132da07ded0ca0fcfd Mon Sep 17 00:00:00 2001 From: ch99l Date: Mon, 5 Oct 2026 10:45:53 +0800 Subject: [PATCH] v0.10.3: per-chemistry flexiplex edit distances and config file reorganisation --- CHANGELOG.md | 6 ++++-- .../barcode_coordinate_config.csv | 0 ...pter_seq_config.csv => cutadapt_config.csv} | 0 ...ank_seq_config.csv => flexiplex_config.csv} | 18 +++++++++--------- conf/dev.config | 3 --- main.nf | 8 ++++---- modules/preprocess_fastq.nf | 18 ++++++------------ 7 files changed, 23 insertions(+), 30 deletions(-) rename assets/{10x_config => }/barcode_coordinate_config.csv (100%) rename assets/{10x_config/adapter_seq_config.csv => cutadapt_config.csv} (100%) rename assets/{10x_config/flank_seq_config.csv => flexiplex_config.csv} (73%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74eb60a..55bb037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,17 @@ This file contains all notable changes to Bambu-Pipe. ### Changed - Increased the minimum adapter overlap in the `PREPROCESS_FASTQ` adapter re-search from the cutadapt default (3 bp) to 10 bp, reducing the number of valid reads discarded due to short chance matches at read ends -- Shortened the polyT right flank for 3' and Visium chemistries (`flank_seq_config.csv`) from 30 T to 9 T, matching the flexiplex presets; ONT reads rarely call the full 30 T homopolymer, so few reads matched the flank during barcode discovery +- Shortened the polyT right flank for 3' and Visium chemistries (`flexiplex_config.csv`) from 30 T to 9 T, matching the flexiplex presets; ONT reads rarely call the full 30 T homopolymer, so few reads matched the flank during barcode discovery - Visium samples (`visium-v*`) are now demultiplexed directly against the spot whitelist, as recommended by flexiplex; barcode discovery and flexiplex-filter are skipped, replacing the `-u 0` knee detection workaround - Updated the supported chemistry names in the README to the official 10x Genomics assay names, with a link to the 10x Genomics long-read compatibility article +- flexiplex flank (`-f`) and barcode (`-e`) edit distances are now set per chemistry in `flexiplex_config.csv` (`flank_max_edit_distance`, `barcode_max_edit_distance`), using the flexiplex preset defaults (`-f 8`, `-e 2`); this replaces the `flexiplex_f_5prime`, `flexiplex_f_3prime` and `flexiplex_e` developer parameters. The previous `-f 13` for 3' and Visium chemistries allowed too many errors for the shortened 9 T flank, causing spurious flank matches that slowed `PREPROCESS_FASTQ` considerably +- Moved the 10x config files out of `assets/10x_config/` into `assets/`, and renamed `adapter_seq_config.csv` to `cutadapt_config.csv` and `flank_seq_config.csv` to `flexiplex_config.csv` ### Removed - `visium-v4` and `visium-v5` (Visium CytAssist Spatial Gene Expression) chemistries, as these probe-based assays do not produce full-length transcripts ### Fixed -- Corrected the 10x3v3 and 10x3v4 end adapter (`rev_primer_f`/`rev_primer_r` in `adapter_seq_config.csv`) to `CCCATGTACTCTGCGTTGATACCACTGCTT`, matching 10x3v2 and Visium; the previous sequence does not occur in these reads, so the adapter was rarely trimmed +- Corrected the 10x3v3 and 10x3v4 end adapter (`rev_primer_f`/`rev_primer_r` in `cutadapt_config.csv`) to `CCCATGTACTCTGCGTTGATACCACTGCTT`, matching 10x3v2 and Visium; the previous sequence does not occur in these reads, so the adapter was rarely trimmed - Resolved an edge case where `PREPROCESS_FASTQ` failed if the input FASTQ filename had the same length as the barcode (16) or UMI (10/12) pattern; the unquoted `?` wildcards in the flexiplex pattern were expanded by the shell to match the filename, which was not intended ## [v0.10.2] - 2026-09-23 diff --git a/assets/10x_config/barcode_coordinate_config.csv b/assets/barcode_coordinate_config.csv similarity index 100% rename from assets/10x_config/barcode_coordinate_config.csv rename to assets/barcode_coordinate_config.csv diff --git a/assets/10x_config/adapter_seq_config.csv b/assets/cutadapt_config.csv similarity index 100% rename from assets/10x_config/adapter_seq_config.csv rename to assets/cutadapt_config.csv diff --git a/assets/10x_config/flank_seq_config.csv b/assets/flexiplex_config.csv similarity index 73% rename from assets/10x_config/flank_seq_config.csv rename to assets/flexiplex_config.csv index e81b390..8c6e9ea 100644 --- a/assets/10x_config/flank_seq_config.csv +++ b/assets/flexiplex_config.csv @@ -1,9 +1,9 @@ -technology,left_flank,barcode,umi,right_flank -10x3v2,CTACACGACGCTCTTCCGATCT,????????????????,??????????,TTTTTTTTT -10x3v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT -10x3v4,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT -10x5v2,CTACACGACGCTCTTCCGATCT,????????????????,??????????,TTTCTTATATGGG -10x5v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTCTTATATGGG -visium-v1,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT -visium-v2,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT -visium-v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT +technology,left_flank,barcode,umi,right_flank,flank_max_edit_distance,barcode_max_edit_distance +10x3v2,CTACACGACGCTCTTCCGATCT,????????????????,??????????,TTTTTTTTT,8,2 +10x3v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT,8,2 +10x3v4,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT,8,2 +10x5v2,CTACACGACGCTCTTCCGATCT,????????????????,??????????,TTTCTTATATGGG,8,2 +10x5v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTCTTATATGGG,8,2 +visium-v1,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT,8,2 +visium-v2,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT,8,2 +visium-v3,CTACACGACGCTCTTCCGATCT,????????????????,????????????,TTTTTTTTT,8,2 diff --git a/conf/dev.config b/conf/dev.config index 5bbf7eb..8937ec2 100644 --- a/conf/dev.config +++ b/conf/dev.config @@ -6,9 +6,6 @@ params { valid_quantification_modes = ['no_quant', 'EM', 'clusteredEM'] save_intermediates = false qfilter_threshold = 10 - flexiplex_f_5prime = 8 - flexiplex_f_3prime = 13 - flexiplex_e = 1 process_by_chromosome = true seurat_dim_single = 15 seurat_dim_multi = 30 diff --git a/main.nf b/main.nf index 9b69d40..7553f2d 100644 --- a/main.nf +++ b/main.nf @@ -65,9 +65,9 @@ workflow STANDARD { def ndrArg = ndr != null ? ndr : 'NULL' // load config files - ch_barcode_coordinate_config = file("${projectDir}/assets/10x_config/barcode_coordinate_config.csv", checkIfExists: true) - ch_adapter_seq_config = file("${projectDir}/assets/10x_config/adapter_seq_config.csv", checkIfExists: true) - ch_flank_seq_config = file("${projectDir}/assets/10x_config/flank_seq_config.csv", checkIfExists: true) + ch_barcode_coordinate_config = file("${projectDir}/assets/barcode_coordinate_config.csv", checkIfExists: true) + ch_cutadapt_config = file("${projectDir}/assets/cutadapt_config.csv", checkIfExists: true) + ch_flexiplex_config = file("${projectDir}/assets/flexiplex_config.csv", checkIfExists: true) ch_n_samples = ch_rows.count() @@ -79,7 +79,7 @@ workflow STANDARD { // process fastq samples ch_preprocess_fastq_in = ch_input_fastq.map { sample, path, meta -> [sample, path, meta, meta.barcode] } // add whitelist path to fastq input tuple - PREPROCESS_FASTQ(ch_preprocess_fastq_in, ch_flank_seq_config, ch_adapter_seq_config) + PREPROCESS_FASTQ(ch_preprocess_fastq_in, ch_flexiplex_config, ch_cutadapt_config) ALIGNMENT(PREPROCESS_FASTQ.out.fastq, ch_genome, ch_annotation) if (!params.bam_only) { diff --git a/modules/preprocess_fastq.nf b/modules/preprocess_fastq.nf index 0220967..9fc0ceb 100644 --- a/modules/preprocess_fastq.nf +++ b/modules/preprocess_fastq.nf @@ -11,8 +11,8 @@ process PREPROCESS_FASTQ { input: tuple val(sample), path(fastq), val(meta), path(whitelist) - path(flank_seq_config) - path(adapter_seq_config) + path(flexiplex_config) + path(cutadapt_config) output: tuple val(sample), path("${sample}_preprocessed_reads.fastq.gz"), val(meta), emit: fastq @@ -55,16 +55,10 @@ process PREPROCESS_FASTQ { } # Demultiplexing with flexiplex - # Arguments: 1=barcode list file generated by flexiplex-filter + # Arguments: 1=barcode list file (flexiplex-filter output, or the whitelist for visium chemistries) flexiplex_demux() { local barcode_list=\$1 - if [[ $meta.chemistry == 10x5* ]]; then - flexiplex_f=$params.flexiplex_f_5prime - else - flexiplex_f=$params.flexiplex_f_3prime - fi - - flexiplex -p $task.cpus -k \$barcode_list "\${flank_seq[@]}" -f \$flexiplex_f -e $params.flexiplex_e + flexiplex -p $task.cpus -k \$barcode_list "\${flank_seq[@]}" -f \$flank_max_edit_distance -e \$barcode_max_edit_distance } # Trims reverse primer with cutadapt @@ -101,8 +95,8 @@ process PREPROCESS_FASTQ { decompress | chopper_cmd | save_intermediate "${sample}_intermediate_qfilter.fastq.gz" > ${sample}_chopper_out.fastq # Extract chemistry specfic parameters from config files - IFS=',' read -r _ left_flank barcode umi right_flank < <(awk -F',' -v chem=$meta.chemistry '\$1 == chem' $flank_seq_config) - IFS=',' read -r _ fwd_primer_f fwd_primer_r rev_primer_f rev_primer_r TSO_f TSO_r < <(awk -F',' -v chem=$meta.chemistry '\$1 == chem' $adapter_seq_config) + IFS=',' read -r _ left_flank barcode umi right_flank flank_max_edit_distance barcode_max_edit_distance < <(awk -F',' -v chem=$meta.chemistry '\$1 == chem' $flexiplex_config) + IFS=',' read -r _ fwd_primer_f fwd_primer_r rev_primer_f rev_primer_r TSO_f TSO_r < <(awk -F',' -v chem=$meta.chemistry '\$1 == chem' $cutadapt_config) # Store flexiplex search pattern as an array so the '?' wildcards are not expanded as shell globs flank_seq=(-x "\$left_flank" -b "\$barcode" -u "\$umi" -x "\$right_flank")