Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proportion plots #234

Merged
merged 19 commits into from
Oct 13, 2017
Merged

Proportion plots #234

merged 19 commits into from
Oct 13, 2017

Conversation

mortonjt
Copy link
Collaborator

This will summarize the mean proportions for each of the balances

You can use this module as follows

import pandas as pd
from gneiss.plot._decompose import proportion_plot

table = pd.DataFrame({
    'A': [1, 1.2, 1.1, 2.1, 2.2, 2],
    'B': [9.9, 10, 10.1, 2, 2.4, 2.1],
    'C': [5, 3, 1, 2, 2, 3],
    'D': [5, 5, 5, 5, 5, 5],
}, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6'])

feature_metadata = pd.DataFrame({
    'A': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'],
    'B': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'],
    'C': ['k__poo', 'p__tar', 'c__', 'o__', 'f__', 'g__', 's__'],
    'D': ['k__poo', 'p__far', 'c__', 'o__', 'f__', 'g__', 's__']
}, index=['kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species']).T

metadata = pd.DataFrame({'groups': ['X', 'X', 'X', 'Y', 'Y', 'Y'],
                         'dry': [1, 2, 3, 4, 5, 6]}, 
                        index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6'])

num_features = ['A', 'B']
denom_features = ['C', 'D']
ax1, ax2 = proportion_plot(table, metadata, num_features, denom_features, 
                           feature_metadata, 'groups', 'X', 'Y', taxa_level='phylum')

image

@wasade @cuttlefishh do you have any thoughts on the current API? Do you think it is intuitive, or should this be simplified?


Parameters
----------
table : pd.DataFrame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you concerned about requiring dense matrices for the table data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 96.403% when pulling ec99a0b on mortonjt:proportion_plots into 0f1d7df on biocore:master.

@cuttlefishh
Copy link

The API looks pretty good to me. For the plots, I have some suggestions to make them clearer:

  • Change x-axis from "proportion -- proportion" to "Denominator proportion -- Numerator proportion". Alternatively, give the user the option to edit these axis labels manually. Title labels should be editable too.
  • Would it be useful for the y-axis labels (currently taxa) to be more flexible? I'm thinking these could be OTU identifiers instead of (or in addition to) taxon names. OTU identifiers make more sense for reference-based methods, but one could imagine assigning identifiers to Deblur sequences and wanting to use those.

The more customizable the plots are, the better people can get what they want, and the more likely they are to use the plots.

@mortonjt
Copy link
Collaborator Author

mortonjt commented Oct 6, 2017

Thanks for taking a look over it Luke!

The user actually already has full control to modify the underlying plots -- this function is returning a full matplotlib figure. But maybe it would be useful to have some clear cut examples in the documentation about how to modify these labels. What do you think?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 96.403% when pulling a6bc991 on mortonjt:proportion_plots into 0f1d7df on biocore:master.

@mortonjt
Copy link
Collaborator Author

Since the comments have been addressed, and this PR has been outstanding for a while, I'm going to go ahead and merge this in so that we can start integrating this functionality into the q2-gneiss plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants