|
setwd("C:\\Users\\Administrator\\Desktop\\tree")
library("ggtree")
library("ggplot2")
tree <- read.tree("species.tree")
ggtree(tree,layout = "circular")
ggtree(tree, layout="fan", ladderize = FALSE, branch.length = "none")+
geom_tiplab2(size=3)+
theme(legend.position = "right")
ggtree(tree) + geom_text(aes(label=node), hjust=-.3) + geom_tiplab(size=3)
MRCA(tree, tip=c("Pelobacter_carbinolicus", "uncultured_nitrogen-fixing_bacterium"))
ggtree(tree) +
geom_cladelabel(node=40, label="Some random clade", color="red")
ggtree(tree) +
geom_tiplab() +
geom_cladelabel(node=5, label="Some random clade",
color="red2", offset=-.3, align=TRUE) +
geom_cladelabel(node=30, label="A different clade",
color="blue", offset=-.3, align=TRUE) +
theme_tree2() +
# xlim(0, 1) +
theme_tree()
ggtree(tree) +
geom_tiplab() +
geom_hilight(node=38, fill="gold") +
geom_hilight(node=17, fill="purple")
ggtree(tree) +
geom_tiplab() +
geom_taxalink("Pelobacter_carbinolicus", "uncultured_nitrogen-fixing_bacterium", color="blue3") +
geom_taxalink("Dysgonomonas_gadei", "uncultured_low_G+C_Gram-positive_bacterium", color="orange2", curvature=-.9)
library("ggstance")
library("vegan")
abun<-read.table("otu_table_group.s.relative.mat.draw",header = T)
colnames(abun)
library("reshape2")
mydata<-melt(abun,id=colnames(abun)[1],measure=colnames(abun)[2:length(colnames(abun))],
variable.name = "group",value.name = "value")
p <- ggtree(tree)+geom_tiplab(size=3) #+geom_text(aes(label=node), hjust=-.3,size=3) + xlim(0,2)
p2 <- facet_plot(p, panel="Stacked Barplot", data=mydata, geom = geom_barh,offset = .15,scales="free",
mapping = aes(x = decostand(value ,"log"), fill = as.factor(group)),
stat='identity' )+theme_tree2(legend.position="right") #+ theme(legend.position="right") #+theme(legend.position=c(.1, .8))#
p2
p <- ggtree(tree,layout = "fan",ladderize = TRUE)+geom_tiplab2(size=5, align = TRUE, offset = 0.5)
otu_table = read.delim("otu_table_group.s.relative.mat.draw", row.names= 1, header=T, sep="\t")
otu_table<-log(otu_table+0.0000001)
p3<-gheatmap(p, otu_table, offset = -.010, width=0.5, font.size=3,low = "green",
high = "red", color = "white", colnames_level=c("S","R","SN","H","K","KN","HN"),
hjust = 0)#, colnames_angle=-45, hjust=-.1)
p3
p <- ggtree(tree)+geom_tiplab(size=5, align = TRUE)
p
otu_table = read.delim("otu_table_group.s.relative.mat.draw", row.names= 1, header=T, sep="\t")
otu_table<-log(otu_table+0.0000001)
p3<-gheatmap(p, otu_table, offset = 0.6, width=0.5, font.size=3,low = "green",
high = "red", color = "white", colnames_level=c("S","R","SN","H","K","KN","HN"),
hjust = 0)#, colnames_angle=-45, hjust=-.1)
p3
Visualizing and Annotating Phylogenetic Trees with R+ggtree
facet_plot: a general solution to associate data with phylogenetic tree
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-2 01:20
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社