我有一个1200个探测器的数据框(行)和两组九列的数组。前九列命名为“正”,后九列命名为“负”。我想通过使用箱形图选择12个随机探针来表明该表达是正常的。我的代码如下所示:
f<-c(rep("positive", 9), rep("negative", 9))
for(i in seq(from=1, to=1200, by=10)){
boxplot(probes[i]~f,col="lightblue",main="Expression of genes studied Cells")
}
但是我收到以下错误:
Error in model.frame.default(formula = probes[i] ~ f) :
variable lengths differ (found for 'f')
如果我将箱形图用于单个探针,则可以正常工作。我得到两个框,一个对应于“正”,另一个对应于“负”:
f<-c(rep("positive", 9), rep("negative", 9))
genex<-as.numeric(dat.fp.labeled["NM_139321.1_psr1_at",])
boxplot(genex~f,col="lightblue",main="Expression of NM_139321.1_psr1_at samples")
我想这就是您想要的:
set.seed(1)
probes <- data.frame(matrix(rnorm(1200*18),ncol=18))
f<-c(rep("positive", 9), rep("negative", 9))
myrows <- sample(1:1200,12,FALSE)
boxplot(unlist(probes[myrows[1],])~f) # first plot
for(i in myrows){
boxplot(unlist(probes[i,])~f)
Sys.sleep(1) # wait for each plot for 1 sec
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句