问题描述
我正在尝试将t检验应用于RNAseq数据的TPM值矩阵,但是我的代码出现错误。我是R的新手,所以我仍在学习编写脚本。我的文件有7列-第一个是基因列表,2:4是group1中的重复项,而5:7是group2中的重复项。该错误是找不到函数“ matrix.t.test”。如何解决?
# Read file
T <- read.table("./rnaseq_tpm_matrix_S_24v0.csv",sep=",",header=TRUE)
# Assign groups of data
x <- T[i,grep('^Sample_S_0',names(T))]
y <- T[i,grep('^Sample_S_24',names(T))]
# Calculate average of each group for each gene
group1_avg <- as.matrix(sum(x)/length(x))
group2_avg <- as.matrix(sum(y)/length(y))
# Calculate log2 (TPM +1)
x <- log2(as.matrix(group1_avg)+1)
y <- log2(as.matrix(group2_avg)+1)
dat <- data.frame(values=c(x,y),vars = rep(c("Sample_SKOV3_0","Sample_SKOV3_24"),times = c(length(x),length(y))))
# Apply t-test
matrix.t.test(dat,MARGIN = 1,n1 = if (MARGIN == 1) floor(ncol(dat)/2)
else floor(nrow(dat)/2),n2 = if (MARGIN == 1) ncol(dat) - n1 else
nrow(dat) - n1,pool = TRUE,pOnly=TRUE,tOnly = FALSE)
Error in matrix.t.test(dat,n1 = if (MARGIN == 1) floor(ncol(dat)/2) else floor(nrow(dat)/2),:
Could not find function "matrix.t.test"
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)