biocore / my-microbes

A set of tools for delivering personal microbiome results to individuals participating in microbiome sequencing studies.
7 stars 5 forks source link

add alpha diversity box plot at single rarefaction depth #7

Closed gregcaporaso closed 11 years ago

gregcaporaso commented 11 years ago

A boxplot would probably be good here showing, on a per-body-site basis, other (in a box) with self as a single point next to the box. This might involve some custom code, but @jrrideout is the box-plot-master, so best to check with him on that (e.g., it might be possible to hack using the existing code by just providing each self value as a "single value distribution" which might then only plot the median of that "distribution").

jairideout commented 11 years ago

Here's what a matplotlib boxplot looks like with a single-value distribution (with a value of 2). This was generated with generate_box_plots() as follows:

>>> from qiime.pycogent_backports.distribution_plots import generate_box_plots
>>> fig = generate_box_plots([[1, 2, 3, 4], [2]])
>>> fig.savefig('foo.png')
gregcaporaso commented 11 years ago

OK - that's what I was guessing. It's a little bit of a hack, but I'd be OK going with this as a first pass.

wasade commented 11 years ago

What about axis labels?

On Dec 4, 2012, at 15:54, Jai Ram Rideout notifications@github.com wrote:

Here's https://dl.dropbox.com/u/43778879/foo.png what a matplotlib boxplot looks like with a single-value distribution (with a value of 2). This was generated with generate_box_plots() as follows:

from qiime.pycogent_backports.distribution_plots import generate_box_plots fig = generate_box_plots([[1, 2, 3, 4], [2]]) fig.savefig('foo.png')

— Reply to this email directly or view it on GitHubhttps://github.com/qiime/personal-microbiome-delivery/issues/7#issuecomment-11019590.

gregcaporaso commented 11 years ago

Yes, with labels of course (see help(generate_box_plots) for how to set those). I meant that a plot that looks like this will work for the first pass and we can improve from there as necessary.

gregcaporaso commented 11 years ago

We'll generate these plots from the collated alpha data (same input as to make_rarefaction_plots.py). To get that data for a single rarefaction depth, you can do the following:

from qiime.parse import parse_rarefaction
from qiime.compare_alpha_diversity import extract_rarefaction_scores_at_depth
extract_rarefaction_scores_at_depth(10,parse_rarefaction(open('alpha_div_collated/observed_species.txt','U')))

For the first-delivery milestone, we'll generate these data at 10k sequences/sample, but this value should be a parameter to the command line script.

jairideout commented 11 years ago

Looking at this now- wouldn't there be distributions for both self and other, since there are multiple iterations and samples at a particular body site? Or am I misunderstanding what you're wanting to be plotted?

From what I can tell from the description, we're needing a figure for each body site, with two boxplots per figure (one for self, one for other), with each distribution made up of the alpha diversity metric values. Is that right?

gregcaporaso commented 11 years ago

You're right - we will have a distribution for each (I realized that after this conversation and forgot to follow up). I'd actually like to have all of these in a single box plot so it's easy to tell which sites are most/least diverse relative to each other.

jairideout commented 11 years ago

Great, thanks for explaining. Will put all body sites in a single plot.