You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-35Lines changed: 23 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
Just another minhash (jam). A high-performance FracMinHash implementation for genomic sequence similarity analysis, optimized for searching plasmids, phages, and other small genomic elements in large datasets.
10
10
11
-
jam uses a custom hash function ([jamhash](https://github.com/St4NNi/jamhash)) that provides lower collision rates, 2-10x higher speed and better uniformity than murmur3. It also includes a compact memory-mapped database format (`.jam`) for fast random access, and a bias filtering system based on Count-Min Sketches to selectively increase sensitivity for target sequences with either hard cutoffs or soft sigmoid filtering.
11
+
jam uses a custom hash function ([jamhash](https://github.com/St4NNi/jamhash)) that provides lower collision rates, 2-10x higher speed and better uniformity than murmur3. It also includes a compact memory-mapped database format (`.jam`) for fast random access, and a bias filtering system based on Count-Min Sketches to selectively increase sensitivity for target sequences with either hard cutoffs or a enrichment-based look up table (LUT) filtering.
Conda, Docker images and python bindings are planned for the future. In the meantime, you can use the CLI tool directly or call the Rust library from your own Rust code.
28
+
27
29
### Key Features
28
30
29
31
-**Custom hash function**: [jamhash](https://github.com/St4NNi/jamhash) provides lower collisions, better uniformity and is faster compared to murmur3
30
-
-**Bias-aware sketching**: Count-Min Sketch based compositional filtering with automatic background extraction and optional soft sigmoid filtering
32
+
-**Bias-aware sketching**: Count-Min Sketch based compositional filtering with automatic background extraction and optional per-bucket enrichment LUT filtering
31
33
-**Complexity filtering**: Shannon entropy threshold to exclude low-complexity k-mers
32
34
-**Memory-efficient**: External sorting for processing datasets larger than available RAM
33
35
-**Compact storage**: 256-bucket memory-mapped `.jam` format with binary fuse filters for fast random access
Bias tables allow compositional filtering to increase sensitivity for target sequences while suppressing background noise. They work by scoring k-mers based on their enrichment in a positive (target) set relative to a negative (background) set. By default, hashes are filtered with a hard threshold, but you can enable soft sigmoid filtering by supplying both `--positive-fscale` and `--negative-fscale` to smoothly vary retention by bias weight.
137
+
Bias tables allow compositional filtering to increase sensitivity for target sequences while suppressing background noise. They work by scoring k-mers based on their enrichment in a positive (target) set relative to a negative (background) set. By default, hashes are filtered with a hard threshold, but you can enable per-bucket enrichment LUT filtering by supplying both `--positive-fscale` and `--negative-fscale`.
136
138
137
-
The underlying data structure is a **Count-Min Sketch (CMS)**, a probabilistic structure that approximates k-mer frequencies using multiple independent hash functions mapped to a fixed-width table. This keeps memory usage constant regardless of the number of distinct k-mers. By default, the CMS uses 1,048,576 columns and 5 hash functions (~5 MB).
139
+
The underlying data structure is a **Count-Min Sketch (CMS)**, a probabilistic structure that approximates k-mer frequencies using multiple independent hash functions mapped to a fixed-width table. This keeps memory usage constant regardless of the number of distinct k-mers. By default, the CMS uses 1,048,576 columns and 5 hash functions (~5 MB), this should be increased if the expected number of distinct k-mers exceeds ~100 million.
138
140
139
141
**How it works:**
140
142
141
143
1. K-mer frequencies from both the positive and negative input sets are counted into separate CMS tables.
142
144
2.**Background extraction**: The positive counts are subtracted from the negative counts (floored at zero). This prevents k-mers naturally shared between target and background from being penalized.
143
145
3. A log-ratio weight is computed per CMS cell: `log((pos + alpha) / (adjusted_neg + alpha))`, where `alpha` is a smoothing parameter.
144
146
4. Weights are quantized to `i8` (-127 to +127) for compact storage.
145
-
5.**Threshold calibration**: All 255 possible thresholds are evaluated. The threshold that maximizes fold enrichment (positive retention / negative retention) is selected. If a target fold enrichment is specified, the closest achievable threshold is used instead.
146
-
6.**Soft filtering (optional)**: When `--positive-fscale` and `--negative-fscale` are set, the threshold defines the midpoint of a sigmoid that maps bias weights to an effective fscale. Higher weights retain hashes near `positive-fscale`, lower weights drift toward `negative-fscale` (or are dropped entirely if `negative-fscale` is `drop`).
147
-
148
-
```console
149
-
$ jam bias create --help
150
-
Create a bias table from positive (target) and negative (background) FASTA files.
151
-
Target signal is always subtracted from background before computing bias weights.
147
+
5.**Threshold calibration**: All 255 possible thresholds are evaluated. The threshold that maximizes fold enrichment (positive retention / negative retention) is selected.
148
+
6.**Enrichment LUT (optional)**: When `--positive-fscale` and `--negative-fscale` are set, each weight bucket independently gets an effective fscale derived from its empirical enrichment ratio (positive/negative hash frequency). The optimizer maximizes `pos_retention² / neg_retention` subject to a minimum positive retention floor (`--min-positive-retention`). The resulting response curve directly reflects the biological data, with no monotonicity or smoothness constraints imposed. Buckets with insufficient observations inherit from the nearest reliable neighbor.
149
+
7.**Unbiased fscale (optional)**: `--unbiased-fscale` sets a fixed effective fscale for weight-zero buckets (k-mers with equal positive and negative frequency), independent of the LUT optimizer.
**Effective fscale**: Because the LUT assigns different sampling rates per weight bucket, the overall sampling rate is not uniform. The calibration output reports three derived values:
152
+
-`eff. fscale (pos)`: effective fscale on the positive calibration population (`base_fscale / positive_retention`)
153
+
-`eff. fscale (neg)`: effective fscale on the negative calibration population (`base_fscale / negative_retention`)
154
+
-`eff. fscale (combined)`: geometric mean of the two, useful as a single summary (`base_fscale / sqrt(pos_ret × neg_ret)`)
154
155
155
-
Options:
156
-
--positive <POSITIVE> Positive (target) FASTA file(s)
157
-
--negative <NEGATIVE> Negative (background) FASTA file(s)
--alpha <ALPHA> Smoothing parameter for log-ratio [default: 1.0]
164
-
--fold-enrichment <FOLD_ENRICHMENT> Target fold enrichment (auto-maximized if not set)
165
-
--positive-fscale <POSITIVE_FSCALE> Effective fscale for positively biased hashes (soft filter)
166
-
--negative-fscale <NEGATIVE_FSCALE> Effective fscale for negatively biased hashes, or "drop"
167
-
--steepness <STEEPNESS> Sigmoid steepness (auto-derived if not set)
168
-
--threads <THREADS> Number of threads
169
-
-h, --help Print help
170
-
```
156
+
`jam stats` on a database with an embedded bias table also reports the combined effective fscale inline with the sample rate, e.g. `Sample rate: 1/100 (effective: 1/432)`.
171
157
172
158
Examples:
173
159
```bash
174
160
# Build a bias table to filter out host sequences
175
161
jam bias create --positive plasmids.fasta --negative host_genome.fasta -o host_filter.bias
0 commit comments