R 在linux中使用多个输入文件在多个文件上运行算法
我正在运行此代码(从): 我想在22个染色体文件上运行它,这样vcfFile、vcfFileindex、chrom、SAIGEOUtputFile和groupFile输入将不同,例如。R 在linux中使用多个输入文件在多个文件上运行算法,r,arrays,bash,shell,bioinformatics,R,Arrays,Bash,Shell,Bioinformatics,我正在运行此代码(从): 我想在22个染色体文件上运行它,这样vcfFile、vcfFileindex、chrom、SAIGEOUtputFile和groupFile输入将不同,例如。 chromosome1.vcf.gz/chromosome1.vcf.gz.tbi/chrom=1/chromosome1\u output.txt/chromosome1\u groupfile.txt 将是第一个输入,chromosome22.vcf.gz/chromosome22.vcf.gz.tbi/ch
chromosome1.vcf.gz/chromosome1.vcf.gz.tbi/chrom=1/chromosome1\u output.txt/chromosome1\u groupfile.txt
将是第一个输入,chromosome22.vcf.gz/chromosome22.vcf.gz.tbi/chrom=22/chromosome22\u output.txt/chromosome22\u groupfile.txt
将是最后一个输入
这些是巨大的文件,需要很长时间才能运行,所以我真的不想以前太多次出错。如果我以染色体数字顺序提供一个文件列表作为输入和所需输出(SAIGEoutput),算法是否会以这种方式运行,即每个输入是否会同步通过1..22
#all files are in a chromosome order from 001 to 022
vcfFiles = $(<vcflist.txt)
vcFileIndex = $(<vcfindex.txt)
chrom=${1..22}
SAIGEoutputFile=$(<outputlist.txt)
Groupfile=$(<groupfile_list.txt)
Rscript step2_SPAtests.R \
--vcfFile=${vcfFiles} \
--vcfFileIndex=${vcFileIndex}\
--vcfField=GT \
--chrom=${chrom} \
--minMAF=0 \
--minMAC=0.5 \
--maxMAFforGroupTest=0.01 \
--sampleFile=./input/samplelist.txt \
--GMMATmodelFile=./output/example_quantitative.rda \
--varianceRatioFile=./output/example_quantitative_cate.varianceRatio.txt \
--SAIGEOutputFile=${SAIGEoutputFile} \
--numLinesOutput=1 \
--groupFile=${Groupfile} \
--sparseSigmaFile=./output/example_quantitative_cate.varianceRatio.txt_relatednessCutoff_0.125.sparseSigma.mtx \
--IsSingleVarinGroupTest=TRUE
#所有文件的染色体顺序为001到022
vcfFiles=$(您需要一个循环来完成此操作。请看以下内容:
for i in {1..22}; {
echo $i
}
输出将是:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
您的命令也可以执行同样的操作:
for i in {1..22}; {
Rscript step2_SPAtests.R \
--vcfFile=chromosome$i.vcf.gz \
--vcfFileIndex=chromosome$i.vcf.gz.tbi \
--vcfField=GT \
--chrom=$i \
--minMAF=0 \
--minMAC=0.5 \
--maxMAFforGroupTest=0.01 \
--sampleFile=./input/samplelist.txt \
--GMMATmodelFile=./output/example_quantitative.rda \
--varianceRatioFile=./output/example_quantitative_cate.varianceRatio.txt \
--SAIGEOutputFile=chromsome${i}_output.txt \
--numLinesOutput=1 \
--groupFile=chromosome${i}_groupfile.tx \
--sparseSigmaFile=./output/example_quantitative_cate.varianceRatio.txt_relatednessCutoff_0.125.sparseSigma.mtx \
--IsSingleVarinGroupTest=TRUE
}
请注意,$i
包含在{}
这是因为$i_uu
-有效的变量名,但我们的变量是$i
,感谢您花时间回答Ivan!效果很好。将阅读循环!下一个问题可能是如何在HPC上作为数组运行…@tacrolimus很乐意提供帮助。最简单的解决方法是在scr末尾添加&
像这样的ipt…upTest=TRUE&
它将在后台一次运行所有22个实例。是的,否则整个循环将在后台运行,并逐个启动实例。
for i in {1..22}; {
Rscript step2_SPAtests.R \
--vcfFile=chromosome$i.vcf.gz \
--vcfFileIndex=chromosome$i.vcf.gz.tbi \
--vcfField=GT \
--chrom=$i \
--minMAF=0 \
--minMAC=0.5 \
--maxMAFforGroupTest=0.01 \
--sampleFile=./input/samplelist.txt \
--GMMATmodelFile=./output/example_quantitative.rda \
--varianceRatioFile=./output/example_quantitative_cate.varianceRatio.txt \
--SAIGEOutputFile=chromsome${i}_output.txt \
--numLinesOutput=1 \
--groupFile=chromosome${i}_groupfile.tx \
--sparseSigmaFile=./output/example_quantitative_cate.varianceRatio.txt_relatednessCutoff_0.125.sparseSigma.mtx \
--IsSingleVarinGroupTest=TRUE
}