Skip to main content

DirectClean Logo

PyPI Python versions License: MIT Issues

DirectClean

Artifact-aware preprocessing and read rescue for Oxford Nanopore direct-cDNA sequencing.

DirectClean takes raw ONT direct-cDNA FASTQ and produces clean, 5′→3′ oriented reads for transcript quantification, isoform analysis, and fusion calling.

directclean -i raw_reads.fastq -r genome.fa -o results/ -t 8 -j gencode.v41.bed12

Why DirectClean?

Direct-cDNA libraries carry artifact classes that primer-based preprocessing does not resolve:

  • Foldback inversions — the sequenced strand folds back on itself.
  • Internal adapter concatemers — two molecules joined at a TSO/RTP junction.
  • Homopolymer-mediated RT template switching — reverse transcriptase detaches at an A/T-rich region and re-primes on an unrelated transcript. These read like genuine gene fusions at the alignment level.
  • Unclassified reads — reads that cannot be oriented from their termini, but whose internal sequence is still recoverable.

The usual response is to discard the whole read. In PCR-free protocols every read is a unique molecule, so that is expensive. DirectClean instead splits or trims at the artifact junction and keeps the usable sequence.

Pychopper handles orientation and terminal-primer-based rescue well. DirectClean keeps that logic and extends coverage to direct-cDNA-specific artifact classes:

Capability Pychopper DirectClean
Strand orientation Yes Yes
Internal adapter handling Terminal-primer based Terminal trimming and supported concatemer splitting
Chimera rescue scope Reads with valid terminal primers Extends to unclassified reads
Foldback inversion removal n/a Yes
Homopolymer RT template-switching detection n/a Yes

Pipeline

flowchart LR
    A(["Raw FASTQ"]) --> S1["<b>Stage 1</b><br/>Foldback removal"]
    S1 --> S2["<b>Stage 2</b><br/>Orientation"]
    S2 -->|oriented| S4["<b>Stage 4</b><br/>Adapter rescue"]
    S2 -->|unknowns| S3["<b>Stage 3</b><br/>Unknowns rescue"]
    S3 --> AL{{"minimap2<br/>splice-aware"}}
    S4 --> AL
    AL --> S5["<b>Stage 5</b><br/>Homopolymer rescue"]
    S5 --> OUT(["Cleaned FASTQ"])

    classDef io fill:#e8e8e8,stroke:#5a5a5a,stroke-width:2px,color:#1a1a1a
    classDef base fill:#cfe2f3,stroke:#2e6da4,stroke-width:2px,color:#1a1a1a
    classDef unk fill:#fce5cd,stroke:#c47d1a,stroke-width:2px,color:#1a1a1a
    classDef adp fill:#d9ead3,stroke:#3d8b52,stroke-width:2px,color:#1a1a1a
    classDef hom fill:#e6d5f2,stroke:#7b4fa3,stroke-width:2px,color:#1a1a1a
    classDef algn fill:#fff2cc,stroke:#b8933a,stroke-width:2px,color:#1a1a1a

    class A,OUT io
    class S1,S2 base
    class S3 unk
    class S4 adp
    class S5 hom
    class AL algn
Stage Tool / module What it does
1 Breakinator Removes foldback inversion artifacts
2 Restrander Orients reads 5′→3′, removes aberrant primer configurations, sets aside unorientable reads
3 Unknowns rescue Recovers orientable sub-reads from the unknowns pool via internal adapter detection
4 Adapter rescue Trims unsupported terminal residuals; splits supported internal concatemers
5 Homopolymer rescue Detects A/T-rich RT template-switching junctions and splits chimeras

A read is only split when the junction is supported by sequence evidence; fragments below the minimum length are dropped. Stage 5 requires both A/T density ≥ 85% and a consecutive A/T run ≥ 5 bp within a 10 bp window, so non-A/T junctions, including real fusions, pass through untouched.

Performance

Read and base retention across four ONT direct-cDNA datasets:

Dataset Input records Pychopper
records / bases
DirectClean
records / bases
A549 (SG-NEx) 1,158,921 64.2% / 56.4% 73.0% / 70.3%
VCaP 5,348,910 57.6% / 49.5% 65.2% / 65.4%
HCT116 (SG-NEx) 6,952,609 65.9% / 58.0% 73.5% / 73.3%
HEYA8 (SG-NEx) 10,799,478 51.4% / 42.8% 71.1% / 69.6%

On VCaP, where the additional reads come from:

Pychopper DirectClean
Adapter-derived segments rescued 103,388 287,328
Foldback inversions removed n/a 434,375
Homopolymer chimeras resolved n/a 46,957
Residual homopolymer junctions in output 70,140 0
Transcripts with read support 27,851 29,343

Chimeric read rate on VCaP: 30.9% raw → 26.8% Pychopper → 16.9% DirectClean.

Installation

pip

pip install directclean

External tools (minimap2, samtools, breakinator, restrander) must be available on PATH.

Developer installation

git clone https://github.com/ylab-hi/DirectClean.git
cd DirectClean
mamba env create -f environment.yml
mamba activate directclean
pip install -e .

Verify with:

directclean --help

Usage

DirectClean runs a splice-aware genome alignment internally. Allow ~24 GiB peak RAM; 32 GiB is recommended.

directclean \
  -i raw_reads.fastq \
  -r genome.fa \
  -o results/ \
  -t 8 \
  -j gencode.v41.bed12
Flag Default Description
-i, --input required Raw ONT direct-cDNA FASTQ
-r, --reference required Reference genome FASTA
-o, --output required Output directory
-t, --threads 4 Threads for minimap2, samtools, Breakinator
-j, --junc-bed none Junction BED12 for guided alignment (GENCODE recommended)

Detection thresholds and report options can be tuned as well, run directclean --help for the full list.

Output

File Content
directclean.cleaned.fastq Final artifact-resolved reads. Use this for downstream analysis; standard FASTQ, drop-in input for IsoQuant, FLAIR, FusionSeeker, or JAFFAL.
directclean.report.html Interactive per-stage statistics and read flow
directclean.homopolymer_report.tsv Per-read homopolymer junction calls
directclean.rescued.fastq Stage 5 sub-reads only
reports/directclean.rescue_report.tsv Per-read Stage 4 details
intermediates/ Per-stage FASTQ and the alignment BAM

DirectClean HTML Report Preview

Citation

To be updated on publication. Please also cite the integrated tools:

  • Breakinator: Heinz JM, Meyerson M, Li H. Detecting foldback artifacts in long reads. BMC Genomics (2026).
  • Restrander: Schuster J, Ritchie ME, Gouil Q. Restrander: rapid orientation and artefact removal for long-read cDNA data. NAR Genomics and Bioinformatics 5(4):lqad108 (2023).

Support

Bug reports and feature requests: open an issue.

License

MIT

Contact

Qingxiang Guo — qingxiang.guo@northwestern.edu · Rendong Yang Lab

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

directclean-1.1.2.tar.gz (63.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

directclean-1.1.2-py3-none-any.whl (73.8 kB view details)

Uploaded Python 3

File details

Details for the file directclean-1.1.2.tar.gz.

File metadata

  • Download URL: directclean-1.1.2.tar.gz
  • Upload date:
  • Size: 63.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.8 Darwin/23.6.0

File hashes

Hashes for directclean-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e1c3a0adb63876f6a02d306a23880b78b1dc28159e79ebd5c8d984d4feb79d21
MD5 0b7b1b60a976c5fe509367bd3834990d
BLAKE2b-256 4e9ca669c67a59cc73b78b46c409c685edf75aa6cc67300d3790b61a30b3f062

See more details on using hashes here.

File details

Details for the file directclean-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: directclean-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 73.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.8 Darwin/23.6.0

File hashes

Hashes for directclean-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b119f756cb7df30ed78a9929ae124581f68cd1e80a9bb427d174657207c4f4b1
MD5 a8e7734310039231108466327a5886c7
BLAKE2b-256 fd829e412cb3d116b01670bb84b25221761940e1a5451261ea921efca3c4c9fa

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 files

1.1.1

2 files

1.1.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page