By Liu Qirui, 20 March, 2026
Forums

全基因组选择的交叉验证,BWGS包会直接提供一个预测结果(rrBLUP包也会提供),可以用来绘制相关性散点图来直观显示模型的预测性能

library(stringr)
library(ggplot2)
library(tidyr)
library(dplyr)
library(moments)
library(patchwork)

#需要读取BWGS的结果,或者基于其他GS软件包的内容同理,只需要一个包含表型值和预测值的数据框即可

plot_data_P55 <- as.data.frame(P55_gs$bv_table)

#计算相关性(准确性)r值

all_values_P55 <- c(plot_data_P55$bv_predict_mean, plot_data_P55$pheno)

#提取表型值和预测值,如果直接做好了数据框只需要计算r值后直接输入

all_values_P55 <- c(plot_data_P55$bv_predict_mean, plot_data_P55$pheno)

#基于表型值确定最佳的横纵轴范围区间

common_limits_P55 <- range(all_values_P55, na.rm = TRUE)

#绘制散点图

plot_P55 <- ggplot(plot_data_P55, aes(x = bv_predict_mean, y = pheno)) +
  geom_point(color = "#E69F00", alpha = 0.6, size = 2) +
  geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "gray50", size = 0.8) +
  geom_smooth(method = "lm", color = "#e74c3c", se = TRUE, fill = "gray80") +
  coord_fixed(ratio = 1, xlim = common_limits_P55, ylim = common_limits_P55) +
  annotate("text", x = common_limits_P55[1], y = common_limits_P55[2],
           label = paste0("r = ", round(accuracy_r_P55, 3)),
           hjust = 0, vjust = 1, size = 6, fontface = "italic") +
  labs(title = "P5.5 (GBLUP)",
       x = "Predicted Value",
       y = "Observed Value") +
  theme(
    panel.grid.major.x = element_blank(),
    panel.grid.minor = element_blank(),
    axis.text = element_text(size = 14),
    axis.title = element_text(size = 18),
    legend.title = element_text(size = 18),
    legend.text = element_text(size = 16),
    plot.title = element_text(hjust = 0.5, size = 24, face = "bold"),
    legend.position = "none",
    strip.text = element_text(size = 12, face = "bold"),
    panel.background = element_rect(fill = "white"),
    panel.border = element_rect(color = "black", fill = NA, linewidth = 0.5)
  )