Giter Site home page Giter Site logo

Comments (1)

microsud avatar microsud commented on June 1, 2024

Hi @najibveto ,
The plot_taxa_heatmap is only for OTU/ASV level data. It does not support aggregated data. If you want to have genus-level data with clustering you can try our new TreeSE based tools here: https://microbiome.github.io/OMA/viz-chapter.html#viz-chapter.
If you want to do it in phyloseq, then I have an in-house set of tools which are focused for our data analysis but should work widely.
https://github.com/RIVM-IIV-Microbiome/biomeUtils and https://github.com/RIVM-IIV-Microbiome/biomeViz are under development.
This plot function relies on TidyHeatmap and ComplexHeatmap

# install two tools
devtools::install_github("RIVM-IIV-Microbiome/biomeUtils")
devtools::install_github("RIVM-IIV-Microbiome/biomeViz")
# load 
library(biomeUtils)
library(biomeViz)
library(microbiome)
library(dplyr)
data("FuentesIliGutData") # example data
ps <- FuentesIliGutData
# ps <- phyloseq
# tax_tb <- as(tax_table(ps),"matrix") %>% 
#   as.data.frame() %>% 
#   rownames_to_column("ASV") %>% 
#   mutate(Genus.Species = ifelse(!is.na(Species), paste0(Genus, ".", Species), Species)) %>% 
#   select(-Species)   %>% 
#   rename(Species = Genus.Species)
# 
# #tax_tb[1:30, 5:9]
# rownames(tax_tb) <- tax_tb$ASV
# tax_tb <- tax_tb[,-1]
# 
# tax_table(ps) <- tax_table(as.matrix(tax_tb))
# you can input your phyloseq here
top_genera_w_mean_relabund <-  ps |> 
  aggregate_taxa("Genus") |> 
  microbiome::transform("compositional") |> 
  findTopTaxa(top= 30, method="mean")
# check the top five
top_genera_w_mean_relabund[1:5]
# For CLR-based plot
ps.clr <- ps %>%
  aggregate_taxa("Genus") |> 
  microbiome::transform("clr")
# Select top taxa to plot 
ps.clr.top.30 <- phyloseq::prune_taxa(top_genera_w_mean_relabund, ps.clr)

plotTidyHeatmap(ps.clr.top.30, 
                select_taxa = top_genera_w_mean_relabund,
                group_samples_by = "ILI",
                add_taxa_label = FALSE,
                cluster_rows = FALSE,
                .scale = "none",
                transform = NULL,
                palette_value = c("red", "white", "blue"),
                # Adjust taxa name size
                row_names_gp = grid::gpar(fontsize = 6, fontface="italic"))

image

Hope this helps.
PS: You should think of cleaning your taxa table for cleaner and clearer outputs.
Cheers,
Sudarshan

from microbiomeutilities.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.