对于4个基因中的每一个基因(每个基因都在列上),我需要测试其在稳定期和进展期患者中的平均表达是否相同,并存储相应的p值。Someone can help me please ? The language is in R.Here picture of my dataframe:
假设这是你的数据框。
df = data.frame(y=sample(c("progres.","stable"),100,replace=TRUE),matrix(rnorm(100*4),ncol=4))
colnames(df)[-1] = c("X1000_at","X1001_at","X1002_at","X1003_at")
如果你只是需要p值,你可以做。
apply(df[,-1],2,function(i)t.test(i ~ df$y)[["p.value"]])
X1000_at X1001_at X1002_at X1003_at
0.14861795 0.11653459 0.01820033 0.41873270
在上面,你迭代通过基因列, t. 检验组之间的分界线由the y
列,并只捕获p值。