## ----opts, include = FALSE---------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE ) ## ----setup-------------------------------------------------------------------- library(ape) library(phylobar) library(phyloseq) library(miaViz) library(scater) ## ----phyloseq-phylo----------------------------------------------------------- data(GlobalPatterns, package = "phyloseq") chlamydiae <- subset_taxa(GlobalPatterns, Phylum == "Chlamydiae") x_phylo <- t(otu_table(chlamydiae)) ## ----handle-zeros------------------------------------------------------------- tree_phylo <- phy_tree(chlamydiae) x_phylo <- x_phylo[rowSums(x_phylo) > 0, ] x_phylo <- x_phylo / rowSums(x_phylo) ## ----phylobar-phyloseq-------------------------------------------------------- phylobar(x_phylo, tree_phylo, width = 900) ## ----phyloseq-taxonomy-------------------------------------------------------- taxa <- tax_table(chlamydiae) |> as.data.frame() taxa$ASV <- rownames(taxa) taxa <- phylobar::add_prefix(taxa) ## ----construct_taxonomy------------------------------------------------------- tax_tree <- taxonomy_to_tree(taxa) plot(tax_tree) ## ----phylobar-taxon----------------------------------------------------------- phylobar(x_phylo, tax_tree, width = 900) ## ----tse-data-prep------------------------------------------------------------ data(GlobalPatterns, package = "mia") prev_species <- getPrevalent(GlobalPatterns, rank = "Species", detection = 0.01) GlobalPatterns_tse <- GlobalPatterns[ rowData(GlobalPatterns)$Species %in% prev_species, ] GlobalPatterns_tse <- transformAssay( GlobalPatterns_tse, method = "relabundance" ) ## ----tse-phylobar-x----------------------------------------------------------- x_tse <- t(assay(GlobalPatterns_tse, "relabundance")) x_tse <- x_tse[, colSums(x_tse) > 0] tree_tse <- rowTree(GlobalPatterns_tse) |> keep.tip(colnames(x_tse)) ## ----phylobar-tse------------------------------------------------------------- phylobar(x_tse, tree_tse, width = 900) ## ----session-info------------------------------------------------------------- sessionInfo()