对遗传力和育种值精度进行作图
- 载入数据
h2_r <- read.csv("D:/R/Spatial_Compete/results/che_reped/res/h2_r_huizong.csv")
str(h2_r)
## 'data.frame': 68 obs. of 6 variables:
## $ pr : Factor w/ 2 levels "npr","pr": 1 1 1 1 1 1 1 1 1 1 ...
## $ model: Factor w/ 4 levels "ar","base","spl",..: 2 3 4 1 2 3 4 1 2 3 ...
## $ trait: Factor w/ 9 levels "alfacel","d05",..: 1 1 1 2 2 2 2 3 3 3 ...
## $ h2 : num 0.397 0.398 0.389 0.109 0.109 ...
## $ rp : num 0.754 0.75 0.749 0.478 0.471 ...
## $ ri : num 0.877 0.875 0.872 0.394 0.397 ...
- 替换模型中各水平名称
h2_r$model <- plyr::mapvalues(h2_r$model, from = levels(h2_r$model), to = c("B-AR","B", "B-Spl","B-Spl-AR"))
# 改变因子水平的顺序
h2_r$trait <- factor(h2_r$trait ,levels=c("h05","d05","v05","h14","d14","v14","alfacel","lignin","holocel"))
h2_r$model <- factor(h2_r$model,levels=c("B", "B-AR","B-Spl","B-Spl-AR"))
- 作图
- plot h2
library(ggplot2)
p <- ggplot(h2_r, aes(model,h2)) + geom_point(aes(colour=pr))+geom_hline(yintercept=0,linetype="dashed",colour="grey",size=.1)+labs(y=expression(italic(h)^2))
p <- p+facet_grid(.~trait)+facet_wrap(~trait,nrow = 3, scales = "free_y")
p+theme_bw()+theme(axis.text.x = element_text(angle = 60,hjust = 1.1,vjust = 1), plot.margin=unit(x=c(.2,.2,.2,.2),units = "cm"))

# save
path_save_fig <- "D:/R/Spatial_Compete/results/che_reped/fig/"
name_save_h2_pdf <- paste(path_save_fig,"h2.pdf",sep = "")
name_save_h2_wmf <- paste(path_save_fig,"h2.wmf",sep = "")
ggsave(name_save_h2_pdf,width=5,height = 4,family = "serif")
ggsave(name_save_h2_wmf,width=5,height = 4,units = "in",family = "serif")
- 育种值精度
# rp
library(ggplot2)
p <- ggplot(h2_r, aes(model,rp)) + geom_point(aes(colour=pr))+geom_hline(yintercept=0,linetype="dashed",colour="grey",size=.1)+labs(y=expression(italic(r[p])))
p <- p+facet_grid(.~trait)+facet_wrap(~trait,nrow = 3)
p+theme_bw()+theme(axis.text.x = element_text(angle = 60,hjust = 1.1,vjust = 1), plot.margin=unit(x=c(.2,.2,.2,.2),units = "cm"))

# save
path_save_fig <- "D:/R/Spatial_Compete/results/che_reped/fig/"
name_save_rp_pdf <- paste(path_save_fig,"rp.pdf",sep = "")
name_save_rp_wmf <- paste(path_save_fig,"rp.wmf",sep = "")
ggsave(name_save_rp_pdf,width=5,height = 4,family = "serif")
ggsave(name_save_rp_wmf,width=5,height = 4,units = "in",family = "serif")
# ri
p <- ggplot(h2_r, aes(model,ri)) + geom_point(aes(colour=pr))+geom_hline(yintercept=0,linetype="dashed",colour="grey",size=.1)+labs(y=expression(italic(r[i])))
p <- p+facet_grid(.~trait)+facet_wrap(~trait,nrow = 3)
p+theme_bw()+theme(axis.text.x = element_text(angle = 60,hjust = 1.1,vjust = 1), plot.margin=unit(x=c(.2,.2,.2,.2),units = "cm"))

# save
path_save_fig <- "D:/R/Spatial_Compete/results/che_reped/fig/"
name_save_ri_pdf <- paste(path_save_fig,"ri.pdf",sep = "")
name_save_ri_wmf <- paste(path_save_fig,"ri.wmf",sep = "")
ggsave(name_save_ri_pdf,width=5,height = 4,family = "serif")
ggsave(name_save_ri_wmf,width=5,height = 4,units = "in",family = "serif")