Question: Looping over plink files
1
gravatar for paolo002
23 months ago by
paolo002160
paolo002160 wrote:

Hi, I have .bed .bim. fam files for various chromosomes of some individuals and I would like merge with other plink files of some other individuals again for each chromosomes I would like to write a loop that does the merging automatically for all the files in just one command line Something like this:

for file in /home/users/chrs/*.{bed,bid,fam};
do plink --bfile filename1.chr$ --bmerge filename2.chr$.bed filename2.chr$.bim filename2.chr$.fam --out filename1_filename2_merged;
done

Here $ means any number from 1 to 22 for each files of the chromosomes.

Any help will be highly appreciated,thanks

linux bash shell • 1.5k views
ADD COMMENTlink modified 23 months ago • written 23 months ago by paolo002160

you need another inner loop: for j in seq 1 22

ADD REPLYlink written 23 months ago by Santosh Anand5.1k

I see, but about the $ sign, it is ok to write like this?will it take any number from 1 to 22 ?

ADD REPLYlink written 23 months ago by paolo002160
for j in $(seq 1 22); do echo chr$j; done
ADD REPLYlink written 23 months ago by Santosh Anand5.1k

Hi, sorry, I tried the two loops but it did not work, can you be more specific please?

ADD REPLYlink written 23 months ago by paolo002160

Could you write what did you try?

ADD REPLYlink written 23 months ago by Santosh Anand5.1k

I see,I have got it Thanks

ADD REPLYlink written 23 months ago by paolo002160

Did you try --merge-list option from plink ? You can merge all the chormosomes for one file using this and do a for loop to merge with other files. http://zzz.bwh.harvard.edu/plink/dataman.shtml#mergelist

ADD REPLYlink modified 23 months ago • written 23 months ago by Inquisitive8995170
1

I see, yes, I know about that option but I have not tried it. I will do that then. Cheers

ADD REPLYlink written 23 months ago by paolo002160
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1639 users visited in the last hour