数据库代码公开:Zscore标准化
作者:半步博导 时间:2024年6月30日 03:59
阅读量:54
data = read.table("data.txt",sep="\t",header=TRUE,check.names=FALSE)
data = as.matrix(data)
rownames(data) = data[,1]
data = data[,-1]
class(data) = "numeric"
data[1:3,1:3]
#行为基因,列为样本,现在对基因进行标准化
standardize <- function(x) {
rowmean <- apply(x, 1, mean)
rowsd <- apply(x, 1, sd)
rv <- sweep(x, 1, rowmean,"-") #表达量-均值
rv <- sweep(rv, 1, rowsd, "/") #再除以标准差
return(rv)
}
zscore = standardize(data)
上一篇:数据库代码公开:卡方检验免疫亚型