# Read clustering

> Group long transcriptome reads by the gene they came from, without a reference genome. Reads are visited from most to least reliable. Each read either joins the first representative whose minimizers cover most of it, or becomes a new representative and adds its minimizers to the index. This private workload runs that greedy loop over four minimizer index layouts, one of them built from `knotkit/inverted-index`, and checks every assignment against an independent reference.

Group long transcriptome reads by the gene they came from, without a reference genome. Reads are visited from most to least reliable. Each read either joins the first representative whose minimizers cover most of it, or becomes a new representative and adds its minimizers to the index. This private workload runs that greedy loop over four minimizer index layouts, one of them built from `knotkit/inverted-index`, and checks every assignment against an independent reference.

## Result

> inline-singleton clusters in 300.1 ms and retains 5,367,998 bytes per index; map-of-sets takes 322.5 ms and retains 26,328,798

## Modules

* [`knotkit/inverted-index`](/modules/inverted-index/): Indexes records by exact keys and scans sorted record IDs for one key or the union of several, using packed posting lists
* [`knotkit/deque`](/modules/deque/): Queues elements at both ends in O(1) amortized time, over array and Float64Array ring buffers, with an optional fixed capacity that turns the queue into a sliding window

## Figures

* Pinned synthetic fixture: 4000 reads and 910 representatives.
* 73.4% of 74391 index keys hold one posting.
* The inline-singleton layout stores one representative ID directly for those keys.

Hover or focus a chart for exact values. Drawn by [`demo.ts`](https://github.com/jkomyno/knotkit/blob/main/problems/read-clustering/demo.ts) at build time, from the fixtures the benchmark uses; it reproduces the README figure.

## Reproduce

```bash
git clone https://github.com/jkomyno/knotkit.git && cd knotkit && bun install
bun run demo:problem:read-clustering
```

[`problems/read-clustering/README.md`](https://github.com/jkomyno/knotkit/blob/main/problems/read-clustering/README.md) states the fixture, the seed, and the result table.
