0

我有一个包含 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")
4

1 回答 1

0

我认为这就是你想要的:

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
}
于 2013-08-17T13:05:00.317 回答