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

Allow grouping of heatmap elements by metadata #172

Merged
merged 2 commits into from
Jan 15, 2019
Merged

Allow grouping of heatmap elements by metadata #172

merged 2 commits into from
Jan 15, 2019

Conversation

polyatail
Copy link
Contributor

@polyatail polyatail commented Jan 14, 2019

This PR addresses the following issues:

#136 I broke the box plot and dendrogram plotting functions out into their own viz/_primitives.py file. This will make it easier to re-use these bits of code.
#151 By user request, plot_heatmap now takes a categorical metadata field (or tuple containing multiple metadata fields), and performs clustering (with user-specified metric and linkage) on a per-category basis.

This code will generate clustered heatmaps at each taxonomic rank:

ranks = ['species', 'genus', 'family', 'class', 'order', 'phylum']
plts = {}

for r in ranks:
    plts[r[0]] = samples.plot_heatmap(
        metric='weighted_unifrac', linkage='median',
        haxis='fish', threshold=0.1, rank=r,
        return_chart=True
    )

plts['p'] & plts['o'] & plts['c'] & plts['f'] & plts['g'] & plts['s']

In the below example plot, the value of metadata field 'fish' is reported above the heatmap.

image

@coveralls
Copy link

coveralls commented Jan 15, 2019

Coverage Status

Coverage increased (+0.05%) to 84.038% when pulling 35fbe9f on roo-kiwi3 into 78f9dca on master.

@boydgreenfield
Copy link
Contributor

Why does this decrease test coverage in _heatmap.py by 50%? Can we add a test to address that?

image

@polyatail
Copy link
Contributor Author

polyatail commented Jan 15, 2019 via email

@boydgreenfield
Copy link
Contributor

@polyatail Works for me!

* Track df normalization via flag in ClassificationsDataFrame
* New methods _cluster_by_sample and _cluster_by_taxa
* Fix bug where dendrogram didn't line up with heatmap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants