Bash loop, count for Chromopainter script
0
0
Entering edit mode
10 weeks ago

Hello,

I need to create a loop to make 2 variables (numerical) increase, one according to the other and all related to a job I have to send to a cluster.

Basically I have to create various groups, and these groups are defined by these 2 variables; for instance 1st group goes from 1 to 10 (1 would be the 1st variable, 10 the 2nd), the 2nd group 21-30 and so on...

I'm creating 169 groups because I have 1690 individuals, and I'm running a script for Chromopainter 169 times (one per each of these groups).

I want to tell my script:

given the initial variables 1 and 10, do the script, increment of 10 for each of the variable and do again the script (loop). I know that to increment the variables I can do this:

for i in {0..159..10}

for j in {10..169..10}


But I can't manage to apply it to the entire thing. This is what I wrote so far:

for count in {1..169};

do

sbatch -J estimate.chr1 -o estimate.chr1.out -e estimate.chr1.error --wrap="module load ChromoPainter/2;
ChromoPainterv2 -g filename.chr1.phase -r fil.recombfile -t IDFILE_FORMAT.txt -o filename.chr1._ChPestimate.$count -a$i $j -i 15 -in -iM"; done  If I want to send the script singularly, for the first group it would work like this: ChromoPainterv2 -g filename.chr1.phase -r fil.recombfile -t IDFILE_FORMAT.txt -o filename.chr1._ChPestimate.$count -a 1 10 -i 15 -in -iM


Any idea? Thank you in advance

script chromopainter bash loop • 332 views
0
Entering edit mode

Hi Giacomo, is there a reason why you are running the parameter estimation step for every groups you have? Typically you would only need to run it for a handful of individuals and a subset of the different chromosomes.

0
Entering edit mode

Hello,

I am doing it in order to infer the switch rate and global mutation probability. I will run Chromopainter with 4 chromosomes, for 15 iterations, painting each recipient (all individuals in the dataset) using all the donors (the rest of individuals in the dataset). I will then run ChromoPainter again in all the chromosomes fixing these parameters

I'm following the pipeline of this paper https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6779411/

0
Entering edit mode

Got it - I would suggest you only need to run it for 10%-20% of the total individuals, and you don't have to run separately for each group, you can run them all together. Running it for all of them is overkill, as that's generally what the authors of the program do e.g. in this paper.

0
Entering edit mode

Thank you very much, I will consider doing it this way. It sure looks easier and quicker