表型数据的处理,一直是困扰许多同学的问题。面对大规模的表型数据,如果不会编程,纯用Excel的话,往往会消耗大量精力。
为了解决大规模表型数据难以处理的问题,小编开发了R包"Phenotype",用于剔除表型中的异常值、计算统计指标和遗传力、绘制直方图和进行BLUP分析。
安装R包
该包已在CRAN发布,可以直接安装。
install.packages("Phenotype")
"Phenotype"一共包含4个函数,分别为"outlier"、"stat"、"histplot"和"blup"。
outlier:利用boxplot剔除数据中的异常值
在之前的推送中,小编教过大家使用boxplot剔除异常值。
基于上述原理,开发了outlier函数,使用方法如下:
## 加载R包
library("Phenotype")
## 加载数据
df <- read.table("brix.txt", header = T,sep = "\t")

outlier包含8个参数。sample/year/loc/rep/phe这5个参数用来设置输入文件的列名,fold指IQR前的倍数,mode设置异常值剔除模式,"normal"表示按照样本剔除异常值,"blup"表示根据环境型和样本剔除异常值。
## 按照样本剔除异常值
inlier <- outlier(df, sample = "Line", loc = "Loc", rep = "Rep", year = "Year", phe = "Brix", fold = 1.5, mode = "normal")

## 按照环境型和样本剔除异常值
inlier <- outlier(df, sample = "Line", loc = "Loc", rep = "Rep", year = "Year", phe = "Brix", fold = 1.5, mode = "blup")

stat:计算表型数值的统计指标
该函数可以用来计算每个材料的平均值、中位数、标准差、标准偏差和样本数量。
## 计算统计指标
stat_out <- stat(x = inlier, sample = "Sample", phe = "inlier")

histplot:绘制正态分布直方图并进行正态分布检验
wheatph <- read.table("wheatph.txt", header = T,sep = "\t")
inlier <- outlier(wheatph, sample = "Line", loc = "Env", rep = "Rep", phe = "DS", mode = "blup")
stat_out <- stat(x = inlier, sample = "Sample", phe = "inlier")
histplot(x = stat_out$mean,xlab = "Plant height",ylab = "Number")

图中右上角的P值是Shapiro-Wilk normality test结果,P值小于0.05代表数据不符合正态分布。
blup:计算多年多点表型数据的BLUP值
最佳线性无偏预测(Best Linear Unbiased Prediction,简称BLUP)可以对多环境数据进行整合,去除环境效应,得到个体稳定遗传的表型。
该函数可以自动完成异常值剔除、遗传力计算和BLUP分析,共包含7个参数。sample/year/loc/rep/phe这5个参数用来设置输入文件的列名,fold指IQR前的倍数。
## 进行BLUP分析
blup_out <- blup(df, sample = "Line", loc = "Loc", rep = "Rep", year = "Year", phe = "Brix", fold = 1.5)
Heritability = 0.82019463339184

执行完毕后,我们可以得到遗传力0.82及每个样本的平均值、BLUP值及校正后的平均值(平均值-BLUP值),用于GWAS分析。
写在最后
包中所有函数的具体参数,均可通过在R语言中输入?函数名来查看。
## 查看outlier函数的参数
?outlier

这是我第一个发布在CRAN上的R包,也是"Phenotype"的第一个公开版本,由于本人水平有限,难免有些Bug存在。如大家在使用过程中遇到问题,请随时与我联系。
网友评论