79 points · by yarapavan · 9y ago · 8 comments
When you sequence a genome with a sequencing machine in tiny pieces you get the same piece several times, it's not even coverage, some pieces show up a lot, some pieces show up rarely so that you have to sequence the genome several times, so to speak (30 to 80 times is the norm).
A lot of that data is redundant to get to those rare pieces, so 'data sketching' is getting more popular.
Examples:
- The Abyss genome assembler has (experimentally) a Bloom filter to decrease memory requirements and run time at the expense of accuracy and having to fiddle with the Bloom filter parameters. The paper assembles a genome using 35GB o RAM instead of a few hundred GB.
- The khmer package contains many functions to downsample sequencing runs using, again, Bloom filters. It also has a HyperLogLog implementation to quickly count k-mers (similar to n-grams, but with ATGC instead of words)
- MinHash sketching is a popular first step in aligning messy PacBio reads (implemented for example in the Canu assembler). People also use this to map population structure using sequencing reads directly, and to quickly assign a taxon to the data of an unknown species.
- There are some approaches with the Oxford Nanopore sequencer (that tiny thing you can hook up to your laptop) where you stream the incoming data directly into the assembler or other program and tell the sequencer to stop sequencing once you found what you're looking for, or your coverage is high enough
Etc. pp. It's a goldmine for fast algorithms, I haven't seen people use a Cuckoo filter, for example
This article introduces the ideas behind sketching, with a focus on algorithmic innovations. It describes some algorithmic developments in the abstract, followed by the steps needed to put them into practice, with examples. The article also looks at four novel algorithmic ideas and discusses some emerging areas.
An interesting thing is that you can find some of these concepts implemented in apache spark (count approx) and into BlinkDB. While, from a theoretical point of view many result are relate d to statistical bound like Chernoff bound and Chebyshev inequality. During my phd I found this topic interesting and promising to answer to mine data with a verified error bound for precision/recall and elapsed time.
To go deeply into this topic I suggest the book Knowledge Discovery from Data Streams http://www.liaad.up.pt/area/jgama/DataStreamsCRC.pdf and other books written by Joao Gama.
Basically a Count-Min Sketch is the same thing as an undersized counting Bloom filter, but it's used quite differently. This allows for loads of interesting operations. First, there's the estimated number of occurrences of an element (how often has it been added?), but it can do more complex things as well, such as quantiles and heavy hitters.
Is your data a stream? Use reservoir sampling for O(n) vs O(n log n).
Sorting a collection of values in order to sample from it doesn't make any sense.
Reservoir sampling can be done much faster than O(n). It's possible in Θ(k log(N/k)). This is a tight bound, so things like O(k) are impossible, because every position in the reservoir will be replaced approximately log(N/k) times. See https://www.researchgate.net/profile/Jeffrey_Vitter/publicat... for a proof.
But you're right in that sorting in order to draw a sample is not particularly efficient most of the time. Not to mention that a selection algorithm would be sufficient as well, and requires expected time O(N): https://en.wikipedia.org/wiki/Quickselect