joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
586 stars 186 forks source link

Facet Taxa axis in Phyloseq heatmap #1735

Open jrb772 opened 8 months ago

jrb772 commented 8 months ago

I'm trying to plot a heatmap of ASV composition, but I would like to group all the taxa with the same name in the x-axis to simplify visualization. I managed to do it with the y-axis categorical variable. But I cannot do it with the taxa axis...

Apreciate any help =D

Example script:

library(phyloseq)
library(ggplot2)
library(ggpubr)
library(ggh4x)

data("GlobalPatterns")
gpac <- subset_taxa(GlobalPatterns, Phylum=="Crenarchaeota")
gpac = prune_samples(sample_sums(gpac) > 50, gpac)

plot_heatmap(gpac, method=NULL, sample.label="SampleType", low="yellow", high="red", 
             taxa.label="Family", taxa.order="Phylum", na.value="white") +
  facet_grid2(cols=vars(SampleType), scales="free_x", independent = "x") +
  rremove("x.text") + rremove("xlab")

jJ2tL