sourmash plugin for improved output of containment search for metagenomes
Project description
sourmash_plugin_containment_search: improved containment search for genomes in metagenomes
This plugin provides a command sourmash scripts mgsearch
that
provides new & nicer output for searching genomes against metagenomes.
Installation
pip install sourmash_plugin_containment_search
Usage
This command:
sourmash scripts mgsearch query.sig metagenome.sig [ metagenome2.sig ...] \
[ -o output.csv ]
will search for the query genome query.sig
in one or more
metagenome.sig
files, producing decent human-readable output and
(optionally) useful CSV outputs.
For example,
sourmash scripts mgsearch ../sourmash/podar-ref/0.fa.sig ../sourmash/SRR606249.trim.k31.sig.gz
produces:
Loaded query signature: CP001472.1 Acidobacterium capsulatum ATCC 51196, com...
p_genome avg_abund p_metag metagenome name
-------- --------- ------- ---------------
100.0% 55.4 3.1% SRR606249
This plugin will work with all the standard sourmash database types, too.
Note that the metagenomes must have been sketched with -p abund
.
Backstory: Why this command?
sourmash search
supports sample search x sample search, broadly -
perhaps too
broadly. And the output formats aren't that helpful.
sourmash prefetch
supports metagenome overlap search against many
genomes, which is the reverse of this use case. Moreover,
prefetch doesn't provided weighted results
and its output isn't friendly.
sourmash gather
has friendly and useful output, but can't be used to
calculate the overlap between a single query genome and many subject
metagenomes.
There is also some interest in reverse containment search.
The manysearch
command of
the sourmash branchwater plugin
also does a nice containment search like this plugin, but it doesn't
provide nice human-readable output and it also doesn't provide
weighted results. (manysearch
is, however, much lower memory &
probably a fair bit faster because it's mostly in Rust.)
Advanced info: implementation details
This command is streaming, in the sense that it will load each metagenome, calculate the match, and then discard the metagenome. Hence its memory usage peaks with the largest metagenome, and its max should be driven by the size of the query + the size of the largest metagenome.
CSV output
Each row contains the following information.
Comparison details
intersect_bp
- overlap between genome and metagenome, estimated by multiplying the number of hashes by the scaled factor used.f_query
- fraction of query (genome) found, aka "detection"; roughly matches the number of bases that will be covered by mapped metagenome reads.f_match
- fraction of metagenome found, unweighted.f_match_weighted
- fraction of metagenome found, weighted. Roughly matches the fraction of metagenome reads that will map to this genome.sum_weighted_found
- sum of weights from intersecting hashes.average_abund
- average abundance of weights intersecting hashes.median_abund
- median abundance of weights from intersecting hashes.std_abund
- std dev of weights from intersecting hashes.jaccard
- (unweighted) Jaccard similarity between sketches.genome_containment_ani
- ANI estimated from the genome containment in the metagenome. Use this for genome ANI estimates.match_containment_ani
- ANI estimated from the metagenome containment in the genome.average_containment_ani
- ANI estimated from the average of the genome and metagenome containments.max_containment_ani
- ANI estimated from the max containment between genome/metagenome.potential_false_negative
- True if the sketch size(s) were too small to give a reliable ANI estimate. False if ANI estimate is reliable.
Sketch information
ksize
- ksize of comparison.moltype
- moltype of comparison.scaled
- scaled of comparison.
Query (genome) information:
query_filename
- genome filename from sketch.query_name
- genome name.query_md5
- genome md5.query_n_hashes
- total numbef of hashes in the genome.
Match (metagenome) information:
match_filename
- metagenome filename from sketch.match_name
- metagenome name.match_md5
- metagenome md5.match_n_hashes
- total number of hashes in the metagenome.match_n_weighted_hashes
- total number of weighted hashes in metagenome.
TODO
- write tests
- evaluate whether we should add more columns by looking at prefetch and gather output
Support
We suggest filing issues in the main sourmash issue tracker as that receives more attention!
Dev docs
containment_search
is developed at https://github.com/ctb/sourmash_plugin_containment_search.
Generating a release
Bump version number in pyproject.toml
and push.
Make a new release on github.
Then pull, and:
python -m build
followed by twine upload dist/...
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sourmash_plugin_containment_search-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 199755058a5df25f04812caf1b1405043cc9f3064896f2ef90354efbc9a9883b |
|
MD5 | 0c98bff6fc5e1db195303770f0777f7e |
|
BLAKE2b-256 | 8e9ce67c9312313c57672e80132c20f75e4c1fe2c06ce96678909902f9a8171d |
Hashes for sourmash_plugin_containment_search-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c85a5382deef425122f148d9aa76708d80b94be4f9e39503d5a221646bb2224 |
|
MD5 | f53ad9dbf1552338d79950d2ab54f118 |
|
BLAKE2b-256 | e6f8fc53da9c39b9c190cbb94f00574ada5493cb6bd7153697bcd33f158317a2 |