使用R中具有三位数的多输入算法循环遍历多个文件 [英] Looping over multiple files using a multi input algorithm with three digit numbers in R
问题描述
我正在使用一种名为SAIGE-GENE的基因解释软件.该算法看起来像这样(完整算法位于
I am using a genetic interpretation software called SAIGE-GENE. The algorithm looks like this (full algorithm at https://github.com/weizhouUMICH/SAIGE/wiki/Genetic-association-tests-using-SAIGE#step-2--performing-the-region--or-gene-based-association-tests): It involves multiple different files being entered with chromosome numbers in their file names (1 to 22).
SPAGMMATtest = function(
vcfFile = "",
vcfFileIndex = "",
vcfField = "DS",
groupFile ="",
savFile = "",
savFileIndex = "",
sampleFile = "",
idstoExcludeFile = "",
idstoIncludeFile = "",
rangestoExcludeFile = "",
rangestoIncludeFile = "",
chrom = "",
start = 1,
end = 250000000,
IsDropMissingDosages = FALSE,
minMAC = 0.5,
minMAF = 0,
maxMAFforGroupTest = 0.5,
minInfo = 0,
GMMATmodelFile = "",
varianceRatioFile = "",
SPAcutoff=2,
SAIGEOutputFile = "",
numLinesOutput = 10000,
IsSparse=TRUE,
......
我没有把所有内容都放在这里,因为这无关紧要.我正在将此算法输入一些其他文件,通常我将文件命名为chr1_file_name.txt .... chr22_file_name.txt.
I haven't put the whole thing here as it isn't relevant. I am inputting a few different files into this algorithm and normally I name my files chr1_file_name.txt....chr22_file_name.txt.
然后我在整个算法中使用for循环在R中使用粘贴功能按染色体编号输入不同的文件名:
I then use a for loop in R on the whole algorithm using the paste function to input the different file names by chromosome number:
for(i in 1:22){SPAGMMATtest = function(
vcfFile = paste("chr",i,"_file_name.txt", sep=""),
vcfFileIndex = "",
vcfField = "DS",
savFile = "",
groupFile ="paste("chr",i,".group_file.txt", sep="")",
等
这很好,但是,我认为我会很聪明,并为该实验的文件名使用三位数字命名:chr001_file_name.txt ... chr022_file_name.txt.
This works fine however, I thought I would be clever and use three digit naming for my file names for this experiment: chr001_file_name.txt...chr022_file_name.txt.
我以前的循环现在不起作用,如果我将循环的开始更改为for(001:022中的i),它也将不起作用.
My previous loop now does not work and if I change the start of the loop to for(i in 001:022) it doesn't work either.
我在做什么错?如何在不重命名所有文件的情况下解决此问题?
What am I doing wrong and how can I fix this without renaming all my files?