Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

nf-quantseq

Nextflow pipeline for QuantSeq REV / 3' end sequencing: polyA site (PAS) discovery with internal priming removal, per-sample PAS counts, coverage tracks and alternative polyadenylation (APA) quantification.

Entry points

Entry point What it does Flow schema
main.nf Full QuantSeq analysis flow/schema.json
wrappers/prepare_genome/main.nf Genome preparation only: uncompress FASTA/GTF, samtools faidx, STAR index flow/prepare_genome.json

The genome preparation steps live in one subworkflow, subworkflows/local/prepare_genome.nf (PREPARE_GENOME). The main pipeline calls it too, and skips every step whose output is supplied (--star_index, --fasta_fai), so on Flow the genome is prepared once by the wrapper and its outputs are picked up by the main pipeline's from_execution genome section.

Usage

The genome preparation wrapper needs the main nextflow.config passed with -c (not included from the wrapper's config), because nf-core's check_max() is not visible to tasks when it comes from an included config. On Flow the version's config paths are nextflow.config,wrappers/prepare_genome/nextflow.config. --save_reference true is needed on the command line for the genome files to be published to --outdir (Flow collects them from the tasks either way).

# 1. Prepare the genome once
nextflow run wrappers/prepare_genome/main.nf -profile docker \
    -c nextflow.config -c wrappers/prepare_genome/nextflow.config \
    --save_reference true \
    --fasta GRCh38.primary_assembly.genome.fa.gz \
    --gtf gencode.v44.annotation.gtf.gz \
    --outdir genome_prep

# 2. Run QuantSeq, reusing the prepared genome
nextflow run main.nf -profile docker \
    --input samplesheet.csv \
    --fasta GRCh38.primary_assembly.genome.fa.gz \
    --gtf gencode.v44.annotation.gtf.gz \
    --star_index genome_prep/genome/index/star \
    --fasta_fai genome_prep/genome/GRCh38.primary_assembly.genome.fa.fai \
    --outdir results

--input is either a samplesheet CSV with columns sample,fastq_1[,fastq_2] (the format Flow generates) or a FASTQ glob such as 'testdata/*.fastq.gz'. QuantSeq REV is processed single-end, so fastq_2 is ignored with a warning.

Internal priming removal (bin/remove_random_priming.py) reads the sequence around each polyA site from the genome FASTA given with --fasta (and its index), so any assembly and chromosome naming works, e.g. GRCh38 or GRCm39 from Ensembl or GENCODE. It is a Python port of the original remove_random_priming.R and writes the same BED files byte for byte (checked on human and mouse data and on synthetic edge cases); --org is no longer used.

Read structure

The pipeline works on read 1 of single-end (or the first read of paired-end) 3' end libraries. It calls polyA sites from reads that end at the site, and counts all reads. Set the options that match how read 1 is built:

Library Read 1 Options
QuantSeq FWD, other sense oligo-dT protocols transcript ... AAAAA none
QuantSeq FWD-UMI UMI(6) TATA transcript ... AAAAA --umi_length 6 --clip_5p 4
QuantSeq REV, standard Illumina read 1 primer (most public REV data) (1-3 nt) TTTTT ... antisense transcript --reverse_complement
QuantSeq REV, Lexogen custom sequencing primer antisense transcript, starting at the polyA site --pas_at_read_start
UMI and/or inline barcode before the poly(T) UMI barcode TTTTT ... antisense transcript --umi_length N --clip_5p M --reverse_complement

After adapter trimming, bin/prepare_reads.py (step PREPARE_READS) does, in order:

  1. --umi_length N: moves the first N bases into the read name (name_UMI). After alignment, bin/umi_dedup.py (step UMI_DEDUP) removes PCR duplicates before polyA sites are called, and again before coverage and per-PAS counts. It clusters UMIs with umi_tools' directional method, like umi_tools dedup, but groups reads on the start of original read 1: the aligned 5' end for sense reads (fixed by the priming site) and the aligned 3' end, the polyA site, for reverse-complemented reads, whose other end moves with trimming. STAR's gene counts (ReadsPerGene.out.tab, used for genes detected and strandedness in the QC summary) are made during alignment and keep duplicates. pct_duplication in the QC summary is the share of aligned reads removed.
  2. --clip_5p M: removes the next M bases (inline sample barcode, spacer, linker).
  3. --reverse_complement: removes up to 3 bases, none of them T, before a leading run of at least 5 T, then reverse-complements every read, so antisense reads end in poly(A).
  4. --pas_at_read_start: reverse-complements every read without looking for a poly(T); reads then end at the polyA site. Every read is used to call sites, instead of only reads that end in AAAAA.

A quick check of orientation: in sense data many reads end in AAAAA; in antisense data with a poly(T), many start with TTTTT or GTTTTT. Antisense reads without a poly(T) (custom primer) look like ordinary reads; if a run with --reverse_complement gives few polyA sites but strand specificity near 1, try --pas_at_read_start.

Before polyA sites are called, the first 12 nt of each read are always cut (the random-primer region in FWD libraries). For reverse-complemented REV reads these are the original read's last bases. Keeping them was tested on GSE164958 and mapped fewer reads uniquely (18% vs 26%), because they are the lowest-quality bases, so the cut stays for every library type.

Poly-G trimming

Two-colour Illumina instruments (NextSeq, NovaSeq, MiniSeq, iSeq) read cycles with no signal as high-quality G, so a read whose signal dies, for example after a long poly(T), ends in a long G run or is G throughout. -q 10 leaves these bases, and the reads map to many C/G-rich places. Set --nextseq_trim true for such data: adapter trimming then uses cutadapt --nextseq-trim=10, which treats trailing Gs as low quality. On GSE164958 (NextSeq 500, mouse QuantSeq REV) about a quarter of reads were mostly G; with the option, unique mapping rose from 44% to 51% and multimapping fell from 32% to 22%, with almost no loss of other reads.

Key parameters

Parameter Default Description
--minreads 2 Min reads for a PAS cluster
--clusterdist 200 Distance (nt) for merging PAS and assigning reads
--pas / --apa / --nopas 0.5 / 0.4 / 0.3 Internal priming A-content thresholds
--reverse_complement false Reads are antisense and start with poly(T); see Read structure
--pas_at_read_start false Reads are antisense and start at the polyA site (REV, custom primer)
--umi_length 0 UMI bases at the read 1 start; duplicates removed after alignment
--clip_5p 0 Bases removed from the read 1 start after the UMI (barcode, spacer)
--nextseq_trim false Data from a two-colour instrument (NextSeq, NovaSeq); see Poly-G trimming
--ensembl false GTF is Ensembl rather than GENCODE
--save_reference false Publish genome preparation outputs (always on in the wrapper)
--skip_apa false Skip APA quantification
--apa_min_pas_reads 10 Min reads per PAS summed over samples
--apa_min_gene_reads 10 Min reads per gene per sample for gene-level metrics
--apa_utr3_only true Gene-level APA metrics from 3' UTR PAS only
--qc_min_unique_reads / --qc_min_pct_unique / --qc_min_strand_frac / --qc_min_genes 1M / 60 / 0.8 / 8000 QC pass thresholds

QC summary

QC_SUMMARY (bin/qc_summary.R) writes results/qc/quantseq.qc_summary.tsv, one row per sample, using the metadata-schema column names where they exist: raw reads (cutadapt), reads after trimming, uniquely mapped reads, pct_mapped, pct_uniquely_mapped, pct_multimapped, pct_rRNA (reads on rRNA/Mt_rRNA genes as a % of gene-assigned reads), genes detected, strand specificity and inferred_strandedness (from STAR ReadsPerGene.out.tab), reads in PAS clusters, qc_pass and qc_notes.

qc_pass is true only if all of these hold (defaults, all settable): --qc_min_unique_reads 1000000, --qc_min_pct_unique 60, --qc_min_strand_frac 0.8, --qc_min_genes 8000.

Caveats: STAR keeps uniquely mapped reads only (--outFilterMultimapNmax 1), so multi-copy rRNA is under-counted in pct_rRNA. pct_duplication is reported as NA: without UMIs, duplicate rates on 3' end data mostly reflect expression, not PCR duplication.

APA quantification

APA_QUANTIFY (modules/local/apa_quantify.nf, bin/apa_quantify.R) combines the per-sample PAS counts from GENERATE_COUNT_TABLE and writes to results/apa/:

  • apa.pas_counts.tsv: PAS x sample raw counts with gene/region annotation
  • apa.pas_cpm.tsv: the same as CPM of PAS-assigned reads
  • apa.pas_usage.tsv: relative usage of each PAS within its gene (genes with at least 2 PAS), with PAS ranked 5' to 3'
  • apa.gene_apa.tsv: per gene and sample, the proximal and distal reads, distal_usage = distal / (proximal + distal), log2_distal_proximal, and the read-weighted mean PAS position relative to the proximal PAS (absolute and scaled 0-1)
  • apa.apa_summary.tsv: per-sample summary

Differential APA between conditions is not done in the pipeline yet; the count matrix is designed to feed DEXSeq/DRIMSeq-style tests downstream.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages