Skip to main content

Fast, accurate BAM deduplication with intelligent UMI detection and correct fragment detection

Project description

MarkDup

Pypi Releases Downloads Development Status

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

  1. Auto-detect: UMI presence, sequencing type, and quality metrics
  2. Group fragments: By biological position and strand
  3. Cluster UMIs: Using edit distance and frequency-aware algorithms
  4. Select best: The highest quality read from each cluster
  5. 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

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


Download files

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

Source Distribution

markdup-0.0.17.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

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

markdup-0.0.17-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file markdup-0.0.17.tar.gz.

File metadata

  • Download URL: markdup-0.0.17.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for markdup-0.0.17.tar.gz
Algorithm Hash digest
SHA256 15e66c739f8f93f7fcba61ecfc10086cfd3641e004ddae4abd5fade226d19c90
MD5 d136f0de7aacb552615ab3607cf22bfe
BLAKE2b-256 4b2418a710f2e4692560fea3b2f415f018eb092ae3437c45d5208d97b00e68e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdup-0.0.17.tar.gz:

Publisher: publish.yml on y9c/markdup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file markdup-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: markdup-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for markdup-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 d3aa917802f27e65c1ed068608b9663824d30a0e90ba488f95a26bde6fc0b12a
MD5 7f422954b5123332fa983ee359d1177c
BLAKE2b-256 8eb9009d53623b2e3dafcbdf50be2f697fcfdfb0398d37d18e60c09b51a6f941

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdup-0.0.17-py3-none-any.whl:

Publisher: publish.yml on y9c/markdup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page