cmuts hmm¶
Purpose¶
Computing mismatch, insertion, deletion, and termination rates from alignment files.
Requires¶
One or more coordinate-sorted alignment files of single-end or merged reads. SAM, BAM, and CRAM formats are all supported
The FASTA library
Alignments must be single-end to avoid double-counting; a read carrying the paired flag causes the program to exit early. Please merge reads upstream before passing data to cmuts hmm.
Model Parameters¶
The pair HMM is configured by five internal parameters. --dump-params writes them in the form --params reads.
cmuts hmm --dump-params > params.txt
You may specify a subset of the parameters to modify only them.
Bandwidth¶
The --band argument sets the bandwidth of the pair HMM, which determines the length of the longest deletion the HMM can relocate. The runtime grows linearly with the bandwidth, on top of a fixed cost. At zero, the HMM degenerates and ambiguous deletions are counted wherever the aligner places them.
DMS data is insensitive to the bandwidth, since methylations mostly cause mismatches. On the other hand, SHAPE data requires a bandwidth of at least the default of 2 to locate ambiguous deletions correctly. Larger bandwidths lead to rapidly diminishing returns.
Error Checking¶
cmuts hmm verifies the FASTA against the alignment header, by comparing each sequence’s name and length, and its MD5 checksum when present. Any mismatch between the header and the FASTA ends the run early. This behavior is configurable via the --verify flag.
Note
The length check is required to avoid buffer overflows and cannot be disabled.
Both the DNA and the RNA forms of the FASTA sequence are accepted during the checksum comparison.
Rejected Reads¶
Reads which do not pass the configured filters are rejected, meaning they are not processed by the HMM and do not contribute to the final rates. A secondary alignment, a read with MAPQ 255, a read missing a sequence, or a read with no CIGAR is automatically rejected.
Warning
minimap2 and bowtie2 assign MAPQ scores differently. The default threshold of 20 is tuned for minimap2-aligned data, but often rejects high-quality reads for bowtie2-aligned data. A lower threshold of 10 is recommended for bowtie2.
A read to which the HMM cannot assign a nonzero alignment probability is also rejected; this can only occur if you set one or more transition probabilities to zero.
Unmapped reads are rejected by nature of having no reference with which to compute each rate.
Rate Computation¶
For each base \(b\), the pair HMM computes five expectations under the posterior distribution over alignments:
Symbol |
Expectation |
|---|---|
\(C_b\) |
coverage |
\(T_b\) |
terminations |
\(M_b\) |
mismatches |
\(I_b\) |
insertion openings |
\(D_b\) |
deletion openings |
Each of the four rates computed by cmuts hmm is the ratio of one expectation to the number of reads that could have produced the event.
Mismatches¶
The mismatch rate is the probability that the wrong base was incorporated at base \(b\), over every read pairing it.
Insertions¶
The insertion opening rate is the probability that one or more bases were inserted directly 5’ of base \(b\). A read that terminates at base \(b\) cannot open an insertion past it, so the denominator is the reads that pair base \(b\) and continue 5’.
Deletions¶
The deletion opening rate is the probability that base \(b\) is the 3’-most base of a run of one or more deleted bases. A deletion at base \(b\) is opened from base \(b+1\), so the denominator is the reads that pair base \(b+1\) and continue 5’.
Terminations¶
The termination hazard rate is the probability that a read ends at base \(b\), given that it reached it.
Error Computation¶
Each rate is accompanied by a per-base estimate for its error, computed as the binomial standard error of the rate at the depth of its denominator. This is purely the statistical error introduced by finite read depths; it does not account for experimental or systemic errors.
Output¶
Dataset |
Source |
|---|---|
Estimated by the HMM. |
|
The binomial standard error of the rate at the position’s depth. |
|
Estimated by the HMM. |
|
The binomial standard error of the rate at the position’s depth. |
|
Estimated by the HMM. |
|
The binomial standard error of the rate at the position’s depth. |
|
Estimated by the HMM. |
|
The binomial standard error of the rate at the position’s depth. |
|
Estimated by the HMM. |
|
Tokenized from the FASTA. |
|
The read length reported in the alignment. |
|
The mapping quality reported in the alignment. |
|
The number of primary reads the HMM successfully processed. |
|
The number of primary reads rejected by a filter or by the HMM. |
|
The number of supplementary reads the HMM successfully processed. |
|
The number of supplementary reads rejected by a filter or by the HMM. |
|
The number of unmapped reads in the alignment. |
|
Estimated by the HMM. |
|
Estimated by the HMM. |
|
Estimated by the HMM. |
CLI Options¶
Arguments¶
Argument |
Description |
|---|---|
|
coordinate-sorted alignments |
Input and output¶
Option |
Description |
|---|---|
|
reference sequences (required) |
|
write results to this file (required) |
|
replace the output file if it already exists |
|
identity checks to make against the FASTA (name, checksum, none; default name,checksum) |
Filtering¶
Option |
Description |
|---|---|
|
reject alignments below this mapping quality (0 to 254; default 20) |
|
reject reads shorter than this (default: no limit) |
|
reject reads longer than this (default: no limit) |
|
reject alignments not on these strands (forward, reverse; default forward,reverse) |
|
reject alignments not of these types (primary, supplementary; default primary) |
Counting¶
Option |
Description |
|---|---|
|
reference positions the pair HMM may look either side of the CIGAR (default 2) |
|
assign the maximum sequencing error to bases below this quality (0 to 255; default 0) |
|
write these statistics of how often two positions are modified together (correlation, conditional, none; default none) |
|
write NaN rates and errors for positions below this depth (default 1) |
|
write NaN rates and errors for this many bases at the 5’ end (default 0) |
|
write NaN rates and errors for this many bases at the 3’ end (default 0) |
|
read the pair HMM’s rates from this file (default: built in) |
Performance¶
Option |
Description |
|---|---|
|
threads running the processing step (default 1) |
|
htslib threads for BGZF decompression (default 0) |
Information¶
Option |
Description |
|---|---|
|
show this help and exit |
|
show the version and exit |
|
write the rates in the form –params reads and exit |
Advanced¶
Accepted, and left out of --help.
Option |
Description |
|---|---|
|
reads in transit at once (default 4096) |
|
reads transferred per queue operation (default 64) |
|
references in flight (default 64) |
|
describe every argument as JSON and exit |
|
describe the output format as JSON and exit |