Fast, accurate BAM deduplication with intelligent UMI detection and correct fragment detection
Project description
MarkDup
A fast, accurate BAM deduplication tool with intelligent UMI detection and correct fragment detection.
Why MarkDup?
Existing BAM deduplication tools suffer from buggy duplicate detection due to incorrect biological positioning and strand handling, poor performance especially with UMI-based deduplication, and inadequate UMI clustering that leads to over-merging. MarkDup solves these problems with correct fragment detection using proper strand-aware coordinate handling, significantly faster processing through optimized algorithms and parallel processing, smart UMI clustering that prevents over-merging with frequency-aware algorithms, and automatic detection that handles both UMI and non-UMI data without requiring different tools.
Key Features
- 🔬 UMI-based deduplication with intelligent extraction from query names or BAM tags
- 📍 Coordinate-based deduplication for files without UMIs
- 🧬 Correct fragment detection for strand-aware clustering (start-only, end-only, or full fragment)
- 🔄 Auto-detection of UMI presence and format
- 🧬 Strand awareness for forward/reverse strand reads
- 📏 CIGAR handling for reads with indels and complex alignments
- ⚖️ Frequency balancing to prevent over-clustering of high-frequency UMIs
- 🎯 Advanced clustering with edit distance and frequency-aware algorithms
- 🔧 Quality selection with multiple metrics and automatic fallback
- ⚡ Parallelized processing for multi-core performance
- 📊 Comprehensive statistics and progress tracking
Quick Start
# Install
pip install markdup
# Basic usage (auto-detects everything)
markdup input.bam output.bam
# With multiple threads
markdup input.bam output.bam --threads 8
# Force coordinate-based (no UMIs)
markdup input.bam output.bam --no-umi
Key Features
🧬 Correct Biological Positioning
- Strand-aware coordinates: Properly handles forward/reverse strand reads
- CIGAR-aware positioning: Correctly processes indels and complex alignments
- Biological start/end: Uses 5'/3' positions, not reference positions
⚡ High Performance
- 13-113x faster UMI clustering with optimized algorithms
- Parallel processing: Multi-core support for large files
- Memory efficient: Window-based processing for large datasets
🔄 Automatic Detection
- UMI auto-detection: Finds UMIs in read names or BAM tags
- Sequencing type: Automatically detects single-end vs paired-end
- Quality metrics: Selects best quality criteria automatically
🎯 Smart UMI Clustering
- Frequency-aware: Prevents over-clustering of high-frequency UMIs
- Edit distance: Configurable similarity thresholds
- Exact matching: Handles identical UMIs efficiently
Installation
# From PyPI
pip install markdup
# From source
git clone https://github.com/y9c/markdup.git
cd markdup
pip install .
Usage Examples
Basic Deduplication
# Auto-detect UMIs and process
markdup input.bam output.bam
# Force coordinate-based method
markdup input.bam output.bam --no-umi
Advanced Options
# Custom UMI settings
markdup input.bam output.bam --umi-tag UB --min-edit-dist-frac 0.15
# Start-only positioning (ChIP-seq)
markdup input.bam output.bam --start-only
# Keep duplicates and mark them
markdup input.bam output.bam --keep-duplicates
Performance Tuning
# Use 8 threads
markdup input.bam output.bam --threads 8
# Larger windows for better performance
markdup input.bam output.bam --window-size 200000
Command Line Options
| Option | Description | Default |
|---|---|---|
INPUT_BAM |
Input BAM file | Required |
OUTPUT_BAM |
Output BAM file | Required |
--threads |
Number of threads | 1 |
--no-umi |
Force coordinate-based | Auto-detect |
--umi-tag |
UMI BAM tag (e.g., UB) | Auto-detect |
--start-only |
Use start position only | False |
--end-only |
Use end position only | False |
--keep-duplicates |
Keep and mark duplicates | False |
--min-edit-dist-frac |
UMI edit distance threshold | 0.1 |
--min-frequency-ratio |
UMI frequency threshold | 0.1 |
Output Format
MarkDup adds BAM tags to track deduplication:
| Tag | Description |
|---|---|
cn |
Cluster name (chr:start-end:strand:UMI) |
cs |
Cluster size (number of reads) |
Performance
- 13-113x faster UMI clustering with optimized algorithms
- Multi-core processing for parallel performance
- Memory efficient window-based processing for large files
- Automatic optimization based on input data characteristics
How It Works
- Auto-detect: UMI presence, sequencing type, quality metrics
- Group fragments: By biological position and strand
- Cluster UMIs: Using edit distance and frequency-aware algorithms
- Select best: Highest quality read from each cluster
- Output: Deduplicated reads with cluster information
Documentation
- Installation Guide - How to install MarkDup
- Usage Guide - How to use MarkDup
- Algorithm Details - How MarkDup fixes existing problems
- FAQ - Frequently asked questions
- Contributing - How to contribute
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
MIT License - see LICENSE for details.
MarkDup: Fast, accurate BAM deduplication with intelligent UMI detection and correct fragment detection.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markdup-0.0.12.tar.gz.
File metadata
- Download URL: markdup-0.0.12.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
394f5aee7044e51227e1a5fe839e62e3e7c6db48129878cf5808ff8e6eac12bf
|
|
| MD5 |
94db296c5d6a08b312b07e201d5661f0
|
|
| BLAKE2b-256 |
fbc51979ab123d3910e241dec32b70bb8420be0486b63bb720fda93328a6651b
|
Provenance
The following attestation bundles were made for markdup-0.0.12.tar.gz:
Publisher:
publish.yml on y9c/markdup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdup-0.0.12.tar.gz -
Subject digest:
394f5aee7044e51227e1a5fe839e62e3e7c6db48129878cf5808ff8e6eac12bf - Sigstore transparency entry: 628515413
- Sigstore integration time:
-
Permalink:
y9c/markdup@814bd03a4f308d056bbdace5fa5aed35ee7ace6a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/y9c
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@814bd03a4f308d056bbdace5fa5aed35ee7ace6a -
Trigger Event:
push
-
Statement type:
File details
Details for the file markdup-0.0.12-py3-none-any.whl.
File metadata
- Download URL: markdup-0.0.12-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6a04368dd7fee7744eef7124ef42d94ae0d98a463cd48fdd19b512b8ade9ea9
|
|
| MD5 |
c4334046a31ba50110f8e02afc5c8798
|
|
| BLAKE2b-256 |
e010f78454b56edb4f8b8f9d2d7429c1c731020d1f297dbbd9e21b1b1bdb58c4
|
Provenance
The following attestation bundles were made for markdup-0.0.12-py3-none-any.whl:
Publisher:
publish.yml on y9c/markdup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdup-0.0.12-py3-none-any.whl -
Subject digest:
f6a04368dd7fee7744eef7124ef42d94ae0d98a463cd48fdd19b512b8ade9ea9 - Sigstore transparency entry: 628515448
- Sigstore integration time:
-
Permalink:
y9c/markdup@814bd03a4f308d056bbdace5fa5aed35ee7ace6a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/y9c
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@814bd03a4f308d056bbdace5fa5aed35ee7ace6a -
Trigger Event:
push
-
Statement type: