qiime/American-Gut — pull request #26 by wasade (2013-11-07 03:31:17+00:00)
Title: methods for fetching unique/rare taxa

New methods for determining rare and unique taxa from a BIOM ``TaxonTable`` (e.g., from ``summarize_taxa.py``). New tree objects were required since cogent is GPL, but this fell together pretty well.

@JWDebelius, I think this should be good to go for your uses. The tables are optionally filtered, as filtering out the rare/unique taxa from a BIOM table does add a fair amount of overhead. See the main block for an example of how to use the code, and of course do not hesitate to send questions.

@gregcaporaso @rob-knight, this may be generally useful for QIIME as well. It's threshold based, and is not doing any stats, but the framework is a much more natural way to deal with taxonomy in these datasets. The tree could easily be further annotated as well. The central idea, given some tax strings:

```python
tax_strings = ["k__foo; p__bar; c__123",
"k__foo; p__bar; c__",
"k__foo; p__bar; c__456",
"k__foo; p__other; c__789"
```

The method constructs the tree:

```python
(((c__123,c__456)p__bar,(c__789)p__other)k__foo)root"
```

Taking this a little further, the method accepts taxon strings per sample, which allows you to annotate the tree to determine how many samples a particular node was observed in. It handles unclassified samples cleanly as well. It does not currently check for contested Greengenes groups, though that could be added easily.