gmteunisse / fantaxtic

Fantaxtic - Nested Bar Plots for Phyloseq Data
26 stars 3 forks source link

Relative abundance with others #18

Closed mafbio closed 1 year ago

mafbio commented 1 year ago

This code needs a data_matrix to work, is there another way to work it without, with only otu_table and taxa_table?

data(GlobalPatterns) top_asv <- top_taxa(GlobalPatterns, n_taxa = 10) plot_nested_bar(ps_obj = top_asv$ps_obj, top_level = "Phylum", nested_level = "Species")

gmteunisse commented 1 year ago

I'm assuming that you have a phyloseq object without sample_data. Fantaxtic requires sample_data, however, so I suggest to create some dummy data like below:

# Load packages
require('phyloseq')

# Create ps without sample data
data("GlobalPatterns")
ps <- GlobalPatterns
ps@sam_data <- NULL

# Create dummy sample_data and add to ps
sam_dat <- data.frame(row.names = sample_names(ps),
                      sample_id = sample_names(ps))
sample_data(ps) <- sam_dat