Data input

library(ggtree)
## ggtree v2.5.2  For help: https://yulab-smu.top/treedata-book/
## 
## If you use ggtree in published research, please cite the most appropriate paper(s):
## 
## 1. Guangchuang Yu. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics, 2020, 69:e96. doi:10.1002/cpbi.96
## 2. Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution 2018, 35(12):3041-3043. doi:10.1093/molbev/msy194
## 3. Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
tree = read.tree('yuanhe_otu_phylo.tre')
# 筛选出top100
# 先读入用于筛选top100的文件,另外此文件中OTU已按phylum(门)归类,便于后期着色
group = read.csv("otu_taxon_yuanhe_top100_phylum!!!.csv")

Select top100

reserve_tip<-group$OTU.ID
to_drop<-tree$tip.label[-match(reserve_tip,tree$tip.label)]
tree_reduced<-treeio::drop.tip(tree,to_drop)

Add group information

gg = data.frame(group$taxonomy)
rownames(gg) = group[,1]
groupInfo <- split( row.names(gg), gg$group.taxonomy )
tree <- groupOTU(tree_reduced, groupInfo)

Plot the tree!

mycolors = c("#1B9E77", "royalblue1", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666", "palevioletred2", "paleturquoise2", "#D95F02", "black")
a = ggtree(tree, size = 0.75, alpha = 0.8, branch.length = 'none', aes(color = group) ) + geom_tiplab(size=2.4) + geom_nodepoint(color="orange", alpha=0.8, size=1) + geom_tippoint(aes(color = group) , size = 1, alpha = 0.8) + scale_color_manual(values = mycolors ) 
a

# circular型
ggtree(tree, size = 0.75, alpha = 0.8, layout = "circular", branch.length = 'none', aes(color = group) ) + geom_tiplab(size=2.4) + geom_nodepoint(color="orange", alpha=0.8, size=1) + geom_tippoint(aes(color = group) , size = 1, alpha = 0.8) + scale_color_manual(values = mycolors ) 

Add something!

# 准备热图
heat = data.frame(group)
heat = heat[,-15]
heat = heat[,-15]
heat1 = heat
rownames(heat1) = heat1[,1]
heat1 = heat1[,-1]
colnames(heat1) = c("SW",     "M 7",    "PC 7",   "PET 7",  "PP 7",   "M 14",   "PC 14",  "PET 14", "PP 14",  "M 21",   "PC 21",  "PET 21", "PP 21")
library(viridis)
## Loading required package: viridisLite
gheatmap(a, heat1, width = 1.8) + scale_fill_viridis(option="magma", direction = -1)  
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.