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 several critical issues: 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
- Automatic detection that handles both UMI and non-UMI data without requiring different tools
Quick Start
# Installation
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 Fragment Detection
- Strand-aware coordinates: Properly handles forward/reverse strand reads
- CIGAR-aware positioning: Correctly processes indels and complex alignments
- Biological positioning: Uses 5'/3' positions, not reference positions
⚡ High Performance
- Significantly 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 detection: Automatically detects single-end vs paired-end
- Quality metrics: Selects the 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
Performance
- Significantly 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, and quality metrics
- Group fragments: By biological position and strand
- Cluster UMIs: Using edit distance and frequency-aware algorithms
- Select best: The highest quality read from each cluster
- Output: Deduplicated reads with cluster information
Documentation
Usage Examples
Basic Deduplication
# Auto-detect UMIs and process
markdup input.bam output.bam
# Force coordinate-based method (no UMIs)
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 (useful for 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
# Use larger windows for better performance
markdup input.bam output.bam --window-size 200000
Detailed Documentation
- Installation Guide - How to install MarkDup
- Usage Guide - How to use MarkDup
- Algorithm Details - How MarkDup works and fixes existing problems
- FAQ - Frequently asked questions
- Contributing - How to contribute
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 method | 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 |
--max-dist-frac |
UMI edit distance threshold | 0.1 |
--max-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) |
License
MIT License - see LICENSE for details.
Copyright © 2025-present Chang Y
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.21.tar.gz.
File metadata
- Download URL: markdup-0.0.21.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c6e88f52b22119f82718f72d9a07e0a694b1b9880911a84b5e00d024bbb7cd8
|
|
| MD5 |
2aeb5f0b5eca98fe17b056cfc5b0c449
|
|
| BLAKE2b-256 |
d62f53a6932ff1434e9c324a90d77c226853cb8b02a2396dcf7a5d8cedc885ca
|
Provenance
The following attestation bundles were made for markdup-0.0.21.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.21.tar.gz -
Subject digest:
5c6e88f52b22119f82718f72d9a07e0a694b1b9880911a84b5e00d024bbb7cd8 - Sigstore transparency entry: 662140082
- Sigstore integration time:
-
Permalink:
y9c/markdup@00317dc6641ee7c6754b4ea441cc860f566b5b8b -
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@00317dc6641ee7c6754b4ea441cc860f566b5b8b -
Trigger Event:
push
-
Statement type:
File details
Details for the file markdup-0.0.21-py3-none-any.whl.
File metadata
- Download URL: markdup-0.0.21-py3-none-any.whl
- Upload date:
- Size: 26.2 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 |
201d604d528830ae1fd4f1e4ed63633c08f3551b4ebf0b695e71f10377761f1c
|
|
| MD5 |
f856174e49eb8d7c57ab8384530d082a
|
|
| BLAKE2b-256 |
2f646492edd7db3175bdd1a804895c1ca9dc07e70448d3d41cefdd3543dc6520
|
Provenance
The following attestation bundles were made for markdup-0.0.21-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.21-py3-none-any.whl -
Subject digest:
201d604d528830ae1fd4f1e4ed63633c08f3551b4ebf0b695e71f10377761f1c - Sigstore transparency entry: 662140083
- Sigstore integration time:
-
Permalink:
y9c/markdup@00317dc6641ee7c6754b4ea441cc860f566b5b8b -
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@00317dc6641ee7c6754b4ea441cc860f566b5b8b -
Trigger Event:
push
-
Statement type: