This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("phyloseq") | |
data("GlobalPatterns") | |
x10 = prune_taxa(tail(names(sort(taxa_sums(GlobalPatterns))), 10), GlobalPatterns) | |
# Fix the node labels for the sake of the tree at the end: | |
phy_tree(x10)$node.label <- gsub("\\.[[:alnum:]]+$", "", phy_tree(x10)$node.label) | |
# Add a new rank, Strain, with the OTU ids | |
tax_table(x10) <- cbind(tax_table(x10), Strain=taxa_names(x10)) | |
# Define the ranks you want to include | |
myranks = c("Genus", "Species", "Strain") | |
mylabels = apply(tax_table(x10)[, myranks], 1, paste, sep="", collapse="_") |