fgumi simulate CLI Reference

April 14, 2026 ยท View on GitHub

Generate synthetic sequencing data for testing and benchmarking the fgumi pipeline.

Requires: cargo build --features simulate

Commands Overview

CommandOutputPipeline StageReference FASTA
fgumi simulate fastq-readsR1/R2 FASTQ.gzInput for extractRequired
fgumi simulate mapped-readsTemplate-coord sorted BAMInput for groupRequired
fgumi simulate grouped-readsTemplate-coord sorted BAM with MI tagsInput for simplex/duplex/codecRequired
fgumi simulate consensus-readsMapped BAM with consensus tagsInput for filterRequired
fgumi simulate correct-readsUnmapped BAM + includelistInput for correctNot used

Note: All simulate subcommands (except correct-reads) require --reference / -r pointing to a reference FASTA file. Positions are sampled from real chromosomes, template sequences are extracted from the reference, and BAM headers contain actual contig names and lengths. Read orientations are a 50/50 mix of F1R2 and R1F2 (strand coin flip per molecule).


fgumi simulate fastq-reads

Generate paired-end FASTQ files with UMI sequences for input to fgumi extract.

Usage

fgumi simulate fastq-reads \
    --r1 output_R1.fastq.gz \
    --r2 output_R2.fastq.gz \
    [OPTIONS]

Required Arguments

OptionTypeDescription
-1, --r1PATHOutput R1 FASTQ.gz file
-2, --r2PATHOutput R2 FASTQ.gz file
--truthPATHOutput truth TSV file (for validation)
-r, --referencePATHReference FASTA file (sequences sampled from here)

Simulation Options

OptionTypeDefaultDescription
-n, --num-moleculesINT1000Number of unique molecules to simulate
-l, --read-lengthINT150Length of each read in bases
-u, --umi-lengthINT8Length of UMI sequence in bases
--read-structure-r1STRING8M+TRead structure for R1 (fgbio notation)
--read-structure-r2STRING+TRead structure for R2 (fgbio notation)
--seedINT(random)Random seed for reproducibility

Quality Model Options

OptionTypeDefaultDescription
--warmup-basesINT10Number of bases before peak quality is reached
--warmup-qualityINT25Starting quality score during warmup phase
--peak-qualityINT37Peak quality score (Phred)
--decay-startINT100Position where quality decay begins
--decay-rateFLOAT0.08Quality drop per base after decay starts
--quality-noiseFLOAT2.0Standard deviation of quality noise
--r2-quality-offsetINT-2Quality offset for R2 reads (typically negative)

Family Size Options

OptionTypeDefaultDescription
--family-size-distSTRINGlognormalDistribution: lognormal, negbin, or path to histogram
--family-size-meanFLOAT3.0Mean family size (for lognormal)
--family-size-stddevFLOAT2.0Family size standard deviation (for lognormal)
--family-size-rFLOAT2.0r parameter (for negative binomial)
--family-size-pFLOAT0.5p parameter (for negative binomial)
--min-family-sizeINT1Minimum reads per family

Insert Size Options

OptionTypeDefaultDescription
--insert-size-meanFLOAT300.0Mean insert size
--insert-size-stddevFLOAT50.0Insert size standard deviation
--insert-size-minINT50Minimum insert size
--insert-size-maxINT800Maximum insert size

Methylation Options

OptionTypeDefaultDescription
--methylation-modeem-seq or taps(disabled)Methylation chemistry mode; disabled by default
--cpg-methylation-rateFLOAT0.75Fraction of CpG cytosines that are methylated [0.0-1.0]
--conversion-rateFLOAT0.98Enzymatic conversion efficiency for target cytosines [0.0-1.0]

Truth File Format

The truth TSV file contains ground truth for validation:

ColumnDescription
read_nameRead name (matches FASTQ header)
true_umiThe true UMI sequence (before any errors)
molecule_idUnique molecule identifier
family_idFamily within the molecule
strandStrand (A or B)
chromChromosome/contig name
pos0-based genomic position

Example

# Generate 10,000 molecules with 8bp UMIs
fgumi simulate fastq-reads \
    --r1 sim_R1.fastq.gz \
    --r2 sim_R2.fastq.gz \
    --truth sim_truth.tsv \
    --reference hg38.fa \
    --num-molecules 10000 \
    --umi-length 8 \
    --read-structure-r1 "8M142T" \
    --read-structure-r2 "150T" \
    --seed 42

fgumi simulate mapped-reads

Generate template-coordinate sorted BAM with paired alignments for input to fgumi group.

Usage

fgumi simulate mapped-reads \
    --output output.bam \
    [OPTIONS]

Required Arguments

OptionTypeDescription
-o, --outputPATHOutput BAM file (template-coordinate sorted)
--truthPATHOutput truth TSV file (for validation)
-r, --referencePATHReference FASTA file (sequences sampled from here)

Simulation Options

OptionTypeDefaultDescription
-n, --num-moleculesINT1000Number of unique molecules to simulate
-l, --read-lengthINT150Length of each read in bases
-u, --umi-lengthINT8Length of UMI sequence in bases
--seedINT(random)Random seed for reproducibility
-t, --threadsINT1Number of writer threads

Positions are sampled from real chromosomes (weighted by length), read sequences are extracted from the reference, and the BAM header contains actual contig names and lengths.

Alignment Options

OptionTypeDefaultDescription
--mapqINT60Mapping quality for aligned reads
--unmapped-fractionFLOAT0.0Fraction of reads to leave unmapped

Position Distribution Options

OptionTypeDefaultDescription
--num-positionsINT(derived)Number of genomic positions to use (default: num-molecules)
--umis-per-positionINT1Number of unique UMIs per position

By default, each molecule gets a unique position. For high-depth benchmarking (testing MIH optimization in group), use fewer positions with many UMIs per position.

Quality Model Options

(Same as fastq-reads)

OptionTypeDefaultDescription
--warmup-basesINT10Number of bases before peak quality
--warmup-qualityINT25Starting quality during warmup
--peak-qualityINT37Peak quality score
--decay-startINT100Position where decay begins
--decay-rateFLOAT0.08Quality drop per base
--quality-noiseFLOAT2.0Quality noise std dev
--r2-quality-offsetINT-2R2 quality offset

Family Size Options

(Same as fastq-reads)

Insert Size Options

(Same as fastq-reads)

Methylation Options

(Same as fastq-reads)

Output Tags

TagTypeDescription
RXStringRaw UMI sequence
RGStringRead group (default: "A")

Truth File Format

ColumnDescription
read_nameRead name (matches BAM QNAME)
true_umiThe true UMI sequence (before any errors)
molecule_idUnique molecule identifier
chromChromosome/contig name
position0-based genomic position
strandStrand (+ or -)

Example

# Generate mapped reads from a reference FASTA
fgumi simulate mapped-reads \
    --output sim_mapped.bam \
    --truth sim_truth.tsv \
    --reference hg38.fa \
    --num-molecules 5000 \
    --seed 42 \
    --threads 4

# High-depth mode: many UMIs at few positions (for MIH/group benchmarking)
fgumi simulate mapped-reads \
    --output sim_high_depth.bam \
    --truth sim_truth.tsv \
    --reference hg38.fa \
    --num-molecules 50000 \
    --num-positions 100 \
    --umis-per-position 500 \
    --seed 42

fgumi simulate grouped-reads

Generate template-coordinate sorted BAM with MI (molecule ID) tags for input to consensus callers (simplex, duplex, codec).

Usage

fgumi simulate grouped-reads \
    --output output.bam \
    [OPTIONS]

Required Arguments

OptionTypeDescription
-o, --outputPATHOutput BAM file (template-coordinate sorted)
--truthPATHOutput truth TSV file (for validation)
-r, --referencePATHReference FASTA file (sequences sampled from here)

Simulation Options

OptionTypeDefaultDescription
-n, --num-moleculesINT1000Number of unique molecules to simulate
-l, --read-lengthINT150Length of each read in bases
-u, --umi-lengthINT8Length of UMI sequence in bases
--seedINT(random)Random seed for reproducibility
-t, --threadsINT1Number of writer threads

Duplex Options

OptionTypeDefaultDescription
--duplexFLAGfalseGenerate duplex-style MI tags (e.g., "1/A", "1/B")
--strand-alphaFLOAT5.0Beta distribution alpha for A/B strand ratio
--strand-betaFLOAT5.0Beta distribution beta for A/B strand ratio

Quality Model Options

(Same as fastq-reads)

Family Size Options

(Same as fastq-reads)

Insert Size Options

(Same as fastq-reads)

Methylation Options

(Same as fastq-reads)

Output Tags

TagTypeDescription
RXStringRaw UMI sequence
MIStringMolecule ID (integer for simplex, "N/A" or "N/B" for duplex)
RGStringRead group (default: "A")

Truth File Format

ColumnDescription
read_nameRead name (matches BAM QNAME)
true_umiThe true UMI sequence (before any errors)
molecule_idUnique molecule identifier
expected_miExpected MI tag value after grouping
chromChromosome/contig name
position0-based genomic position
strandStrand (+ or -)

Example

# Generate simplex grouped reads
fgumi simulate grouped-reads \
    --output sim_grouped.bam \
    --truth sim_truth.tsv \
    --reference hg38.fa \
    --num-molecules 5000 \
    --seed 42

# Generate duplex grouped reads with strand bias
fgumi simulate grouped-reads \
    --output sim_duplex_grouped.bam \
    --truth sim_truth.tsv \
    --reference hg38.fa \
    --num-molecules 5000 \
    --duplex \
    --strand-alpha 5.0 \
    --strand-beta 5.0 \
    --seed 42

fgumi simulate consensus-reads

Generate mapped BAM with consensus tags (cD, cM, cE, etc.) for input to fgumi filter.

Usage

fgumi simulate consensus-reads \
    --output output.bam \
    --reference ref.fa \
    [OPTIONS]

Required Arguments

OptionTypeDescription
-o, --outputPATHOutput BAM file (mapped)
-r, --referencePATHReference FASTA file (sequences sampled from here)

Simulation Options

OptionTypeDefaultDescription
-n, --num-readsINT1000Number of consensus read pairs to generate
-l, --read-lengthINT150Length of each read in bases
--seedINT(random)Random seed for reproducibility
-t, --threadsINT1Number of writer threads

Consensus Tag Options

OptionTypeDefaultDescription
--min-depthINT1Minimum consensus depth (cM tag)
--max-depthINT10Maximum consensus depth (cD tag)
--depth-meanFLOAT5.0Mean depth for sampling
--depth-stddevFLOAT2.0Depth standard deviation
--error-rate-meanFLOAT0.01Mean error rate (cE tag)
--error-rate-stddevFLOAT0.005Error rate standard deviation

Duplex Options

OptionTypeDefaultDescription
--duplexFLAGfalseGenerate duplex consensus tags (aD, bD, aM, bM, aE, bE)
--strand-alphaFLOAT5.0Beta distribution alpha for A/B depth ratio
--strand-betaFLOAT5.0Beta distribution beta for A/B depth ratio

Quality Options

OptionTypeDefaultDescription
--consensus-qualityINT40Base quality for consensus reads

Methylation Options

OptionTypeDefaultDescription
--methylation-modeem-seq or taps(disabled)Methylation chemistry mode; disabled by default
--cpg-methylation-rateFLOAT0.75Fraction of CpG cytosines that are methylated [0.0-1.0]
--conversion-rateFLOAT0.98Enzymatic conversion efficiency for target cytosines [0.0-1.0]
--methylation-depth-meanFLOAT5.0Mean depth for methylation count sampling (cu + ct per position)

Output Tags (Simplex)

TagTypeDescription
cDIntMaximum per-base depth
cMIntMinimum per-base depth
cEFloatConsensus error rate
cdIntArrayPer-base depth array
ceIntArrayPer-base error count array

Output Tags (Duplex, in addition to above)

TagTypeDescription
aDIntA-strand maximum depth
aMIntA-strand minimum depth
aEFloatA-strand error rate
bDIntB-strand maximum depth
bMIntB-strand minimum depth
bEFloatB-strand error rate
adIntArrayA-strand per-base depth
bdIntArrayB-strand per-base depth

Example

# Generate simplex consensus reads
fgumi simulate consensus-reads \
    --output sim_consensus.bam \
    --reference hg38.fa \
    --num-reads 10000 \
    --min-depth 2 \
    --max-depth 20 \
    --seed 42

# Generate duplex consensus reads
fgumi simulate consensus-reads \
    --output sim_duplex_consensus.bam \
    --reference hg38.fa \
    --num-reads 10000 \
    --duplex \
    --seed 42

fgumi simulate correct-reads

Generate unmapped BAM and UMI includelist for input to fgumi correct.

Usage

fgumi simulate correct-reads \
    --output output.bam \
    --includelist umis.txt \
    [OPTIONS]

Required Arguments

OptionTypeDescription
-o, --outputPATHOutput BAM file (unmapped)
-i, --includelistPATHOutput UMI includelist file (one UMI per line)
--truthPATHOutput truth TSV file (for validation)

Simulation Options

OptionTypeDefaultDescription
-n, --num-readsINT10000Number of reads to generate
--num-umisINT1000Number of unique UMIs in includelist
-u, --umi-lengthINT8Length of UMI sequence in bases
--read-lengthINT100Length of template sequence
--seedINT(random)Random seed for reproducibility
-t, --threadsINT1Number of writer threads

Error Distribution Options

OptionTypeDefaultDescription
--exact-fractionFLOAT0.4Fraction with exact UMI match (0 edits)
--edit1-fractionFLOAT0.3Fraction with 1 edit distance
--edit2-fractionFLOAT0.2Fraction with 2 edit distance
--multi-fractionFLOAT0.1Fraction with 3+ edits (should not correct)

Quality Options

OptionTypeDefaultDescription
--qualityINT30Base quality for all bases

Output Tags

TagTypeDescription
RXStringObserved (possibly erroneous) UMI sequence

Includelist Format

The includelist is a plain text file with one UMI per line, sorted alphabetically:

AAAACCCC
AAAACCCT
AAAACCGG
...

Truth File Format

ColumnDescription
read_nameRead name (matches BAM QNAME)
true_umiThe correct UMI from the includelist
observed_umiThe (possibly erroneous) UMI in the RX tag
expected_correctionExpected UMI after correction
edit_distanceEdit distance between observed and true
error_typeType: exact, edit1, edit2, or multi

Example

# Generate correction test data
fgumi simulate correct-reads \
    --output sim_correct.bam \
    --includelist sim_umis.txt \
    --truth sim_truth.tsv \
    --num-reads 100000 \
    --num-umis 5000 \
    --umi-length 12 \
    --exact-fraction 0.5 \
    --edit1-fraction 0.3 \
    --edit2-fraction 0.15 \
    --multi-fraction 0.05 \
    --seed 42

Shared Concepts

Read Structure Notation

Uses fgbio-style read structure notation:

  • M = Molecular barcode (UMI)
  • T = Template
  • S = Skip (ignored bases)
  • B = Sample barcode
  • + = Variable length (consumes remaining bases)

Examples:

  • 8M142T = 8bp UMI followed by 142bp template
  • 8M+T = 8bp UMI followed by variable-length template
  • +T = All template (no UMI)

Family Size Distributions

Three distribution types are supported:

  1. Log-normal (default): Natural for PCR amplification

    • Parameters: --family-size-mean, --family-size-stddev
  2. Negative binomial: Alternative PCR model

    • Parameters: --family-size-r, --family-size-p
  3. Empirical: Load from fgumi group -f histogram output

    • Parameter: --family-size-dist /path/to/histogram.tsv

Quality Score Model

Quality scores follow a three-phase model:

  1. Warmup (positions 0 to warmup-bases): Quality ramps from warmup-quality to peak-quality
  2. Peak (positions warmup-bases to decay-start): Quality stays at peak-quality
  3. Decay (positions after decay-start): Quality decreases by decay-rate per base

R2 reads have an additional offset (r2-quality-offset, typically -2) applied.

Template-Coordinate Sorting

For mapped-reads and grouped-reads, output is sorted by template coordinate:

  • Primary sort: 5' position of the leftmost read in the pair
  • Secondary sort: Read name (for determinism)

BAM header includes: SO:unsorted, GO:query, SS:template-coordinate

High-Depth Benchmarking

To benchmark the MIH (Multiple Identical Hits) optimization in fgumi group, use the position distribution options to create data with many UMIs at few positions:

# 100 positions, each with 500 unique UMIs, ~10 reads per UMI = 500,000 reads
fgumi simulate mapped-reads \
    --output high_depth.bam \
    --truth high_depth_truth.tsv \
    --reference hg38.fa \
    --num-molecules 500000 \
    --num-positions 100 \
    --umis-per-position 500 \
    --family-size-mean 10 \
    --seed 42

This creates the kind of position-clustered data that stresses the UMI assignment algorithm and tests the MIH optimization path in group.