I will try to explain it. I have a .sh file that do a gwas for each cromosome in bash. This .sh file works but I would like to do a loop to automatize it instead of changing the cromosome (from 1 to 22) each time I do it. I will put a part of a code as its not mine and idk if I can post it:
This is an example with chr 21 if I do:
#!/bin/bash -f
# Assuming run by chromosome so
# set to chromosome.
chr=21
# path to program
program=../programs/program
# path to genotype file
geno=../chr{chr}.1001.bin
# path to program phenotype file
pheno=../data/pheno.csv
Then from bash i do bash gwas.sh
and it works for 21 chromosome.
This is a part but it works. I tried this:
- change the file a little bit:
#!/bin/bash -f
# Assuming run by chromosome so
# set to chromosome.
chr=$CHR
# path to program
program=../programs/program
# path to genotype file
geno=../chr{chr}.1001.bin
# path to program phenotype file
pheno=../data/pheno.csv
And then from bash I did
for ((CHR=1; CHR<22; CHR++)); do
echo $CHR
bash gwas.sh
done
Thank you so much in advance
ANSWERD: (Verpous answered it)
- change the file:
#!/bin/bash -f
# Assuming run by chromosome so
# set to chromosome.
export chr=
# path to program
program=../programs/program
# path to genotype file
geno=../chr{chr}.1001.bin
# path to program phenotype file
pheno=../data/pheno.csv
then do:
for ((CHR=1; CHR<23; CHR++)); do
export chr=$CHR
bash ../scripts/gwas.sh
done
Answered: (Verpous answered it in the comments)
change the file:
then do: