生产树状、圆圈状高清DPI图片

#42个点练手论文,区域聚类,昆虫聚类,输出300DPI高清图
install.packages("BiocManager")
ls()
rm(list=ls())

library("BiocManager")
install.packages("ggtree")
BiocManager::install("phyloseq")

library("phyloseq")
library(readxl)
df2 <- read_xlsx("49Tree.xlsx",sheet="Sheet2",head=T,rownames=1)
df <- read_xlsx("49Tree.xlsx",sheet="Sheet1")
head(df)
hc<-hclust(dist(df))
plot(hc)
install.packages("rtool")



df <-read.csv("49Tree.csv",head=T,row.names = 1)
head(df)
hc<-hclust(dist(df))
plot(hc)
#install.packages("BiocManager")
install.packages("ggtree")
library("BiocManager")
library("ggtree")
ggtree(hc)
ggtree(hc,layout = "circular")+
  geom_tiplab()


ggtree(hc)+geom_tiplab()+
  xlim(-250,80)+
  theme_tree2()

ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)


ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))
 
ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")


ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red",alpha=1)

ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")

ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 43,fill="green")

ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")

ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 45,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 47,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 48,fill="pink")


ggtree(hc,layout = "circular")+
  geom_tiplab()+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1")

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2.5)+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")


ggtree(hc,layout = "circular")+
  geom_tiplab(size=2.5)+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 2,barsize = 2,color = "red")

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2.5)+
  xlim(-250,80)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 20,barsize = 2,color = "red")

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red")

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)


ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 49,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 2,label ="cluster3",offset = 160,barsize = 3,color = "pink",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 44,label ="cluster4",offset = 160,barsize = 3,color = "green",
                  hjust = 2,vjust=-1)




ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+
  geom_text(aes(label=node))+geom_hilight(node = 50,fill="red")+
  geom_text(aes(label=node))+geom_hilight(node = 49,fill="steelblue")+
  geom_text(aes(label=node))+geom_hilight(node = 2,fill="pink")+
  geom_text(aes(label=node))+geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 49,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 2,label ="cluster3",offset = 160,barsize = 3,color = "pink",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 44,label ="cluster4",offset = 160,barsize = 3,color = "green",
                  hjust = 2,vjust=-1)
  

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+geom_hilight(node = 50,fill="red")+
  geom_hilight(node = 49,fill="steelblue")+
  geom_hilight(node = 2,fill="pink")+
  geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 49,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 2,label ="cluster3",offset = 160,barsize = 3,color = "pink",
                  hjust = 0.3,vjust=-5)+
  geom_cladelabel(node = 44,label ="cluster4",offset = 190,barsize = 3,color = "green",
                  hjust = 0.5,vjust=-4)

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+geom_hilight(node = 50,fill="red")+
  geom_hilight(node = 49,fill="steelblue")+
  geom_hilight(node = 2,fill="pink")+
  geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 49,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 2,label ="cluster3",offset = 160,barsize = 3,color = "pink",
                  hjust = 0.3,vjust=-5)+
  geom_cladelabel(node = 44,label ="cluster4",offset = 190,barsize = 3,color = "green",
                  hjust = 0.5,vjust=-4)

png(filename = "42dian.png",width = 3000,
    
    height = 3000,units = "px",bg="white",res=300)#创作画布

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-250,190)+geom_hilight(node = 50,fill="red")+
  geom_hilight(node = 49,fill="steelblue")+
  geom_hilight(node = 2,fill="pink")+
  geom_hilight(node = 44,fill="green")+
  geom_cladelabel(node = 50,label ="cluster1",offset = 160,barsize = 3,color = "red",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 49,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = 2,vjust=-1)+
  geom_cladelabel(node = 2,label ="cluster3",offset = 160,barsize = 3,color = "pink",
                  hjust = 0.3,vjust=-5)+
  geom_cladelabel(node = 44,label ="cluster4",offset = 190,barsize = 3,color = "green",
                  hjust = 0.5,vjust=-4)#拓印画布



dev.off()



df <-read.csv("42.csv",head=T,row.names = 1)
head(df)
hc<-hclust(dist(df))
plot(hc)
#install.packages("BiocManager")
install.packages("ggtree")
library("BiocManager")
library("ggtree")
ggtree(hc)
ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-350,350)+
  geom_hilight(node = 54,fill="brown")+
  geom_hilight(node = 55,fill="steelblue")+
  geom_hilight(node = 57,fill="red")+
  geom_hilight(node = 58,fill="green")+
  geom_cladelabel(node = 54,label ="cluster1",offset = 160,barsize = 3,color = "brown",
                  hjust = -0.4,vjust=-0.4)+
  geom_cladelabel(node = 55,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = -0.6,vjust=-1)+
  geom_cladelabel(node = 57,label ="cluster3",offset = 160,barsize = 3,color = "red",
                  hjust = 1.5,vjust=-5)+
  geom_cladelabel(node = 58,label ="cluster4",offset = 190,barsize = 3,color = "green",
                  hjust = 0.3,vjust=-1.3)


png(filename = "42dian.png",width = 3000,
    
    height = 3000,units = "px",bg="white",res=300)#创作画布

ggtree(hc,layout = "circular")+
  geom_tiplab(size=2)+
  xlim(-350,350)+
  geom_hilight(node = 54,fill="brown")+
  geom_hilight(node = 55,fill="steelblue")+
  geom_hilight(node = 57,fill="red")+
  geom_hilight(node = 58,fill="green")+
  geom_cladelabel(node = 54,label ="cluster1",offset = 160,barsize = 3,color = "brown",
                  hjust = -0.4,vjust=-0.4)+
  geom_cladelabel(node = 55,label ="cluster2",offset = 160,barsize = 3,color = "steelblue",
                  hjust = -0.6,vjust=-1)+
  geom_cladelabel(node = 57,label ="cluster3",offset = 160,barsize = 3,color = "red",
                  hjust = 1.5,vjust=-5)+
  geom_cladelabel(node = 58,label ="cluster4",offset = 190,barsize = 3,color = "green",
                  hjust = 0.3,vjust=-1.3)#拓印画布



dev.off()


df <-read.csv("49Tree.csv",head=T,row.names = 1)
head(df)
hc<-hclust(dist(df))
plot(hc)
#install.packages("BiocManager")
install.packages("ggtree")
library("BiocManager")
library("ggtree")
ggtree(hc)
ggtree(hc)+geom_tiplab()+ xlim(-250,80)

png(filename = "42dianshu.png",width = 3000,
    
    height = 3000,units = "px",bg="white",res=300)#创作画布

ggtree(hc)+geom_tiplab()+ xlim(-250,80)#拓印画布



dev.off()


ggtree(hc)+geom_tiplab()+
  xlim(-250,80)+
  theme_tree2()

你可能感兴趣的:(聚类,机器学习,r语言)