0

所以我创建了一个包含 12 个二进制文件的对象。作为我想做的分析的一部分,我将 12 个中的一个与其他 11 个进行比较,使用函数进行一些分析。

IE

在循环一中,object$1 与 object$1 比较 2:12,

循环二,object$2 对 object$ 1,3:12

...

循环 12,object$12 对 object$1[1:11]

我可以通过指定文件名手动进行小规模的操作。但是因为它涉及到将所有 12 个文件相互比较,并且我有很多组 12 个文件(总共 250 个文件)可以正常工作,我如何自动化呢?

最终输出是一个数据框,所以我希望在每个循环中也创建它(使用相关的文件名,如 object$1.csv 或其他东西)。

firstbatch <-bams[1:12] #bams is character vector of the files
bedfile <- "filename.bed"
my.counts <- getBamCounts(bed.file = bedfile, bam.files = firstbatch) #creates object
my.test <- firstbatch$1
my.ref.samples <- firstbatch$2...firstbatch$12
series of functions comparing $1 against 2:12
4

1 回答 1

1

也许你冷使用这个程序:

a <- combn(12,2)   # will give you all possible combinations 

for (i in 1:dim(a)[2]) {      #loops over all possible combinations

firstbatch[ a [1,i]]    # first sample name to compare
firstbatch[ a [2,i]]    # second sample name to compare against
...
} 
于 2012-05-25T12:34:51.103 回答