kmer_spectrum
k-mer counting on DNA reads or one sequence (canonical or not, linear or circular): spectrum histogram, distinct and unique k-mers, Shannon entropy, linguistic complexity, genome-size estimate from the spectrum peak, most over-represented k-mers against a base-composition model. Reads from a list, FASTA/FASTQ text, a staged file, or a seeded shotgun simulator.
- Field
- Genomics
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 1 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001homopolymer A x 50, k = 5 (closed form): one distinct k-mer counted L - k + 1 = 46 times, entropy 0, linguistic complexity 5/161 (Trifonov, sum of min(4^w, L - w + 1) over w = 1..5 is 161)passed
total_kmers= 4646lockedexact matchdistinct_kmers= 11lockedexact matchmax_multiplicity= 4646lockedexact matchunique_kmers= 00lockedexact matchentropy_bits0 ± 1e-120lockedunder 0.01 % of the tolerance usedlinguistic_complexity0.0310559 ± 3.1e-110.0310559lockedunder 0.01 % of the tolerance usedr0002de Bruijn B(4,3) read cyclically, k = 3 (de Bruijn 1946): every one of 4^3 = 64 k-mers exactly once, entropy 2k = 6 bits, linguistic complexity 1passed
total_kmers= 6464lockedexact matchdistinct_kmers= 6464lockedexact matchunique_kmers= 6464lockedexact matchmax_multiplicity= 11lockedexact matchentropy_bits6 ± 6e-126lockedunder 0.01 % of the tolerance usedentropy_relative1 ± 1e-121lockedunder 0.01 % of the tolerance usedlinguistic_complexity1 ± 1e-121lockedunder 0.01 % of the tolerance usedr0003total k-mers = sum (L_i - k + 1) (counting identity): lengths 10, 25, 7, 3 at k = 4 give 7 + 22 + 4 + 0 = 33, one sequence shorter than kpassed
windows= 3333lockedexact matchtotal_kmers= 3333lockedexact matchshort_sequences= 11lockedexact matchtotal_bases= 4545lockedexact matchr0004canonical merge (Watson-Crick pairing): AAACG and its reverse complement CGTTT are one canonical 5-mer seen twice; 4^5/2 = 512 canonical 5-mers possiblepassed
total_kmers= 22lockedexact matchdistinct_kmers= 11lockedexact matchmax_multiplicity= 22lockedexact matchpossible_kmers= 512512lockedexact matchentropy_bits0 ± 1e-120lockedunder 0.01 % of the tolerance usedr0005same pair not canonical: AAACG and CGTTT stay two k-mers, entropy log2 2 = 1 bit, 4^5 = 1024 possiblepassed
distinct_kmers= 22lockedexact matchunique_kmers= 22lockedexact matchpossible_kmers= 10241024lockedexact matchentropy_bits1 ± 1e-121lockedunder 0.01 % of the tolerance usedr0006even-k palindrome ACGT is its own reverse complement: one canonical 4-mer; (4^4 + 4^2)/2 = 136 canonical 4-mers possible (palindrome count 4^(k/2))passed
total_kmers= 11lockedexact matchdistinct_kmers= 11lockedexact matchpossible_kmers= 136136lockedexact matchr0007genome size from the spectrum peak (exact construction): circular B(4,3) genome G = 64 bp read 3 times plus one circular error read ACGTA whose five 5-mers are absent from the genome; k = 5 gives peak 3, error k-mers 5, G = 192/3 = 64passed
total_kmers= 197197lockedexact matchdistinct_kmers= 6969lockedexact matchunique_kmers= 55lockedexact matcherror_kmers= 55lockedexact matchpeak_multiplicity= 33lockedexact matchsolid_kmer_occurrences= 192192lockedexact matchgenome_size_estimate_bp64 ± 6.4e-1164lockedunder 0.01 % of the tolerance usedcoverage_peak_found= truetruelockedexact match
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
k | 1 | 21 | Word length in bases (packed two bits per base, so at most 31). 21 is usual for read sets. |
canonical | true | Count a k-mer and its reverse complement as one (reads from both strands). | |
circular | false | Read every sequence as a circle: L windows instead of L - k + 1 (plasmids, de Bruijn sequences). | |
sequences | Reads or sequences as strings of A, C, G, T (U read as T; N and IUPAC codes break the k-mers that span them). | ||
sequence_text | FASTA ('>' headers), FASTQ (four lines per read) or one read per line. | ||
sequence_file | Staged FASTA, FASTQ or one-read-per-line file, e.g. "@r0003/reads.fa". | ||
top_n | 1 | 10 | How many of the most frequent k-mers to list. |
min_multiplicity | 1 | 0 | k-mers seen fewer times are treated as sequencing errors; 0 finds the error valley of the spectrum. |
sim_genome_bp | 1 | 0 | Length in base pairs of a simulated random circular genome; 0 turns the simulator off. Use it instead of giving sequences. |
sim_read_bp | 1 | 150 | Simulated read length in base pairs. |
sim_coverage | 1 | 30.0 | Read bases over genome bases. |
sim_error_rate | 1 | 0.0 | Chance that a simulated base is read wrong (uniform substitution). |
sim_seed | 1 | 1 | Seed of the SplitMix64 draws: the same seed gives the same reads. |
sim_both_strands | true | Half the simulated reads come from the reverse strand. |
Readings
| Name | Unit | Meaning |
|---|---|---|
k | 1 | |
sequences | 1 | |
total_bases | 1 | bases read (base pairs) |
gc_fraction | 1 | |
windows | 1 | sum over sequences of L - k + 1 (L when circular) |
total_kmers | 1 | windows counted (those with no ambiguous base) |
skipped_kmers | 1 | |
short_sequences | 1 | |
possible_kmers | 1 | 4^k, or the canonical count (4^k + 4^(k/2))/2 for even k and 4^k/2 for odd k |
distinct_kmers | 1 | |
unique_kmers | 1 | k-mers seen exactly once |
unique_fraction | 1 | |
max_multiplicity | 1 | |
mean_multiplicity | 1 | |
entropy_bits | 1 | Shannon entropy of the k-mer distribution, bits |
entropy_relative | 1 | entropy over log2(min(possible, total)) |
vocabulary_usage | 1 | distinct over min(possible, total) at word length k |
linguistic_complexity | 1 | Trifonov: sum of distinct words over sum of min(possible, windows), word lengths 1..k |
error_cutoff_multiplicity | 1 | |
error_kmers | 1 | |
distinct_solid_kmers | 1 | |
solid_kmer_occurrences | 1 | |
peak_multiplicity | 1 | k-mer depth at the spectrum peak |
peak_distinct_kmers | 1 | |
coverage_peak_found | true when the spectrum (above the error cutoff) peaks at multiplicity 2 or more | |
genome_size_estimate_bp | 1 | solid k-mer occurrences over peak multiplicity, base pairs |
top_kmers | ||
spectrum | ||
simulation |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.