Skip to content

Relative abundance in heat tree #357

Open
@SimonMorvan

Description

Hello Metacoder devs,

It must be pretty straight forward but I'm having a hard time trying to plot relative abundance of the taxa in the whole dataset instead of OTU count as node_size in the heat tree. I guess I have to change n_obs to something but I couldn't find the right parameter to replace it by.

Have a good day,

Simon

library(phyloseq)
library(metacoder)

data(GlobalPatterns)
# Subsetting the dataset to keep only 2 sample types
GP_sub <- subset_samples(GlobalPatterns, (SampleType=='Ocean' | SampleType=='Soil'))
GP_sub <- prune_taxa(taxa_sums(GP_sub)>0, GP_sub)

# Agglomerating the dataset to Class 
GP_sub_class_glom <- tax_glom(GP_sub,taxrank="Class",NArm = F)
  


meta_obj <- parse_phyloseq(GP_sub_class_glom) 

meta_obj$data$otu_relab <- calc_obs_props(meta_obj, "otu_table")  

meta_obj$data$tax_relab <- calc_taxon_abund(meta_obj, "otu_relab") 

meta_obj$data$diff_table <- compare_groups(meta_obj, data = "tax_relab",
                                           cols = meta_obj$data$sample_data$sample_id,
                                           groups = meta_obj$data$sample_data$SampleType)

heat_tree(meta_obj,
          node_size = n_obs , 
          node_label = taxon_names,
          node_color = log2_median_ratio, # A column from `obj$data$diff_table`
          node_color_range = diverging_palette(), # The built-in palette for diverging data                 
          node_color_axis_label = "Log2 ratio median proportions",
          repel_labels = TRUE,
          layout = "davidson-harel", # The primary layout algorithm
          initial_layout = "reingold-tilford") # The layout algorithm that initializes node locations

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions