Skip to main content

CloneArmy

CloneArmy is a modern Python package for analyzing haplotypes from Illumina paired-end amplicon sequencing data. It provides a streamlined workflow for processing FASTQ files, aligning reads, identifying sequence variants, and performing comparative analyses between samples.

Features

  • Fast paired-end read processing using BWA-MEM
  • Quality-based filtering of bases and alignments
  • Haplotype identification and frequency analysis
  • Statistical comparison between samples with FDR correction
  • Interactive visualization of mutation frequencies
  • Rich command-line interface with progress tracking and tabular output
  • Comprehensive HTML reports
  • Multi-threading support
  • Support for full-length sequence analysis
  • Real-time progress monitoring with progress bars
  • Automatic downsampling of large FASTQ files
  • Exportable results in multiple formats (CSV, JSON, Excel)

Installation

pip install clonearmy

Requirements

  • Python ≥ 3.8
  • BWA (must be installed and available in PATH)
  • Samtools (must be installed and available in PATH)
  • Seqtk (must be installed and available in PATH)

You can install the required tools using conda:

conda install -c bioconda bwa samtools seqtk

Usage

Command Line Interface

Basic Analysis

# Basic usage with progress tracking
clonearmy run /path/to/fastq/directory reference.fasta

# With all options
clonearmy run /path/to/fastq/directory reference.fasta \
    --threads 8 \
    --output results \
    --min-base-quality 20 \
    --min-mapping-quality 30 \
    --min-read-count 10 \
    --max-file-size 100000000 \  # Target size for downsampling (100MB)
    --report  # Generate HTML report (default: true)

The --max-file-size option specifies the target size for downsampling large FASTQ files. If your input files are larger than this size, they will be automatically downsampled while maintaining paired-end relationships. This is useful for quick testing or when working with very large datasets. The size is specified in bytes (e.g., 100000000 for 100MB).

Comparative Analysis

# Compare two samples
clonearmy compare \
    /path/to/sample1/fastq \
    /path/to/sample2/fastq \
    reference.fasta \
    --threads 8 \
    --output comparison_results \
    --min-base-quality 20 \
    --min-mapping-quality 30 \
    --min-read-count 10 \
    --max-file-size 100000000 \  # Target size for downsampling (100MB)
    --full-length-only  # Only consider full-length sequences

Output Examples

Sample Analysis Results

╒════════════════╤══════════╤════════════╤══════════════╕
│ Sample         │ Reads    │ Haplotypes │ Mutations    │
╞════════════════╪══════════╪════════════╪══════════════╡
│ sample1        │ 10000    │ 45         │ 2.3 avg      │
│ sample2        │ 12000    │ 52         │ 1.8 avg      │
╘════════════════╧══════════╧════════════╧══════════════╛

Comparative Analysis Results

╒══════════╤════════════╤════════════╤═══════════╤═══════════╕
│ Position │ Sample 1 % │ Sample 2 % │ P-value   │ FDR       │
╞══════════╪════════════╪════════════╪═══════════╪═══════════╡
│ 123 A>T  │ 45.2      │ 12.3       │ 0.001     │ 0.003     │
│ 456 G>C  │ 33.1      │ 28.9       │ 0.042     │ 0.063     │
╘══════════╧════════════╧════════════╧═══════════╧═══════════╛

Python API

from pathlib import Path
from clone_army.processor import AmpliconProcessor
from clone_army.comparison import run_comparative_analysis

# Initialize processor with automatic downsampling
processor = AmpliconProcessor(
    reference_path="reference.fasta",
    min_base_quality=20,
    min_mapping_quality=30,
    min_read_count=10,
    max_file_size=100_000_000  # 100MB target size
)

# Process samples
results1 = processor.process_sample(
    fastq_r1="sample1_R1.fastq.gz",
    fastq_r2="sample1_R2.fastq.gz",
    output_dir="results/sample1",
    threads=4
)

results2 = processor.process_sample(
    fastq_r1="sample2_R1.fastq.gz",
    fastq_r2="sample2_R2.fastq.gz",
    output_dir="results/sample2",
    threads=4
)

# Perform comparative analysis
comparison_results = run_comparative_analysis(
    results1=results1,
    results2=results2,
    reference_seq=ref_seq,
    output_path="comparison_results.csv",
    full_length_only=False
)

Output Files

Single Sample Analysis

  • Sorted BAM file with alignments
  • {sample}_haplotypes.csv containing:
    • Sequence
    • Read count
    • Frequency
    • Number of mutations
    • Full-length status
    • Quality metrics
  • Interactive HTML report with:
    • Summary statistics
    • Mutation frequency plots
    • Position-based mutation diversity plots
    • Mutation spectrum analysis
  • Console output with summary statistics

Comparative Analysis

  • comparison_results.csv with statistical comparisons:
    • Mutation positions and types
    • Frequencies in each sample
    • Statistical significance (p-values)
    • FDR-corrected p-values
  • Interactive HTML plots:
    • Mutation frequency comparison
    • Position-based mutation diversity
  • Console output with significant mutations

Metadata

Release files for clonearmy 0.2.32

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clonearmy 0.2.32
File Size Uploaded
clonearmy-0.2.32.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clonearmy 0.2.32
File Interpreter ABI Platform
clonearmy-0.2.32-py3-none-any.whl Python 3 none any Details

Total release size: 53.0 kB

Release files / clonearmy-0.2.32.tar.gz

Download URL clonearmy-0.2.32.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
129c99453b0cb815bf64c3fd5bd671c0d9e43521d6fae06539703e39bda74abb
BLAKE2b-256 checksum
How to use checksums
6cdb6a2d9f9ada9a9dbb31909ef41ca2e091aedce9c66e0ec319e45da4b935cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / clonearmy-0.2.32-py3-none-any.whl

Download URL clonearmy-0.2.32-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e82b6b50e7dd3dbce73ee6e7075799c3fb911006d8f7933bfa21df859de949b9
BLAKE2b-256 checksum
How to use checksums
9e4c1c4114a23fd3e00167e7f786e50255295ea639a8207c56b2031e24c6080d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.2.32 This release

2 release files

0.2.30

2 release files

0.2.29

2 release files

0.2.28

2 release files

0.2.27

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.24

2 release files

0.2.23

2 release files

0.2.22

2 release files

0.2.21

2 release files

0.2.20

2 release files

0.2.19

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.10

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

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