Open mpricketts opened 8 years ago
When I execute this (notice I used Family instead of Genus for taxrank):
data_Gen <- tax_glom(data, taxrank="Family") plot_heatmap(data_Gen, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Genus")
, it correctly labels the y-axis title with "Genus", but does not label each individual Genera. And obviously the heatmap produced is for Family level, not Genus.
Is it possible something is wrong with my tax_table at the Genus level??
Also when I try to do this at the Species level:
data_Spec <- tax_glom(data, taxrank="Species") plot_heatmap(data_Spec, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Species")
,it produces the appropriate figure ("Species" as the y-axis title w/ each row labeled correctly), BUT there are VERY few rows, probably only around 100 when there should be thousands! Wondering if it has something to do with OTU's that could only be classified to a certain phylogenetic level. When I run: head(tax_table(data)), I see a lot of NA's in the genus and species columns.
Ideally, in the I would still like to include OTU's that could only be classified at the Order level in the heatmaps for Family, Genus, and Species.
Is there a workaround to deal with this?
Thanks in advance!
After playing more with this, I noticed that the same problems I am having also occur with the GlobalPatterns dataset when you subset Proteobacteria instead of Crenarchaeota:
data("GlobalPatterns")
Prot <- subset_taxa(GlobalPatterns, Phylum=="Proteobacteria")
colnames(tax_table(Prot))
Now when I try to plot_heatmap at ANY taxonomic level, it results in "OTU" on the y-axis, instead of the associated taxonomic level:
plot_heatmap(Prot, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Genus")
plot_heatmap(Prot, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Family")
plot_heatmap(Prot, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Order")
plot_heatmap(Prot, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Class")
plot_heatmap(Prot, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Phylum")
However, if I agglomerate taxa using tax_glom (as suggested by michberr in Issue #600), it works fine for Family, Order, Class, etc., but not for Genus:
Prot_Gen <- tax_glom(Prot, taxrank="Genus")
plot_heatmap(Prot_Gen, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Genus")
Prot_Fam <- tax_glom(Prot, taxrank="Family")
plot_heatmap(Prot_Fam, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Family")
Prot_Ord <- tax_glom(Prot, taxrank="Order")
plot_heatmap(Prot_Ord, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Order")
Prot_Class <- tax_glom(Prot, taxrank="Class")
plot_heatmap(Prot_Class, "NMDS", "bray", sample.label="SampleType", sample.order="SampleType", taxa.label="Class")
I hope this helps explain the problem I'm having. Please let me know if there is a workaround for this. Thank you!!
Please post a MRE. Try using the GlobalPatterns
example dataset to reproduce your error, or share a very small subset of your data that reproduces the error. saveRDS
is your friend for saving/sending the object with fidelity.
Please also post your system info (especially package version numbers).
Hi Joey! Thanks for getting back to me.
You'll have to excuse my ignorance, but I don't know what a MRE is, or how to make one.
Regarding using the GlobalPatterns
example to reproduce my error, please see above. I encounter the same problems when I subset Proteobacteria instead of Crenarchaeota (like is done in the tutorial).
Below is a list of system info I'm using:
Mac OS X El Capitan 10.11.4 RStudio - Version 0.98.1091
Packages: phyloseq - Version 1.14.0 ggplot2 - Version 2.0.0 vegan - Version 2.3-3 RColorBrewer - Version 1.1-2 grid - Version 3.2.3 gridExtra - Version 2.0.0
Thank again for your help!!
Hi all,
did this ever get resolved? I seem to be having the same problem at the Family level - the axis is labelled by OTU (and thus, all are labelled NA). Code below:
heatmap.family = merge_samples(relative.abundance.roots, "Treatment_detail")
sample_data(heatmap.family)$Treatment_detail <- levels(sample_data(relative.abundance.roots)$Treatment_detail)
family = tax_glom(heatmap.family, "Family")
heatmap = transform_sample_counts(family, function(x) 100 * x/sum(x))
q <- plot_heatmap(heatmap, "Family", taxa.label = "Family")
Many thanks
Unfortunately, no... I ended up just giving up on the heatmap...
Hmm ok thanks. I can't seem to get any taxonomic labelling at all now, not even at OTU level!
I have the same issue with Genus level.
Same here too! The tax.label works for some of my phyloseq obj, but not all of them.
In my case, it didn't work for all taxonomy levels. No matter what taxa.label I specify, it only shows OTU as ylab, and all tick labels are "NA". I checked both phyloseq objects (the one works and didn't), they all have proper rank names.
session info:
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] phyloseq_1.32.0 seqinr_4.2-5 yingtools2_0.0.1.42 rtracklayer_1.48.0
[5] GenomicRanges_1.40.0 GenomeInfoDb_1.24.2 IRanges_2.22.2 S4Vectors_0.26.1
[9] BiocGenerics_0.34.0 reshape2_1.4.4 lubridate_1.7.10 RPostgreSQL_0.6-2
[13] DBI_1.1.1 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.5
[17] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.0
[21] ggplot2_3.3.3 tidyverse_1.3.0 readxl_1.3.1
Not sure why #600 got closed after I reopened it, but please see below for background: https://github.com/joey711/phyloseq/issues/600#issuecomment-212714424
Ok. This just keeps getting weirder. As worked out above, using tax_glom worked for Order. It also works for Family, Class and Phylum. However, it does NOT work for Genus. Again, it defaults back to just OTU. Here is the code I am using:
rm(list = ls()) setwd("~/Box Sync/Work/Professional/R/Phyloseq")
require(grid) library(phyloseq) require(ggplot2) require(vegan) require(RColorBrewer) require(gridExtra)
biom <- import_biom("otu_table.biom", parseFunction = parse_taxonomy_greengenes) map <- import_qiime_sample_data("MPR_map4.txt") data <- merge_phyloseq(biom, map)
data_Gen <- tax_glom(data, taxrank="Genus") plot_heatmap(data_Gen, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Genus")
data_Fam <- tax_glom(data, taxrank="Family") plot_heatmap(data_Fam, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Family")
data_Ord <- tax_glom(data, taxrank="Order") plot_heatmap(data_Ord, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Order")
data_Class <- tax_glom(data, taxrank="Class") plot_heatmap(data_Class, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Class")
data_Phylum <- tax_glom(data, taxrank="Phylum") plot_heatmap(data_Phylum, "NMDS", "bray", sample.label="Treatment", sample.order="Treatment", taxa.label="Phylum")
I have no idea why the Genus level doesn't act like the other levels. Any help would be appreciated.
Thanks!