0

I have a table with two columns (x1 and x2), and each having values like this:

Mytable
x1      x2
rs345  rs459
rs298  rs112
rs665  rs555 
.       .
.       .
.       .
n       n

I want to calculate the r2 (pearson correlation) for every pair side by side in Mytable, let's say for rs345 and rs459 by using Plink (a command line genetic program). Typically yo have to enter manually every single pair:

plink --bifile genetic.data --r2 rs345 rs459 --out first_pair

But I want to get an easy way to loop the command over all the pairs and save time. I'll appreciate any comment!

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • 1
    Surely [this](http://stackoverflow.com/questions/1521462/looping-through-the-content-of-a-file-in-bash) and [this](http://stackoverflow.com/questions/15442220/pipe-file-line-by-line-into-multiple-read-variables) get you there? – Benjamin W. Apr 28 '16 at 21:32
  • Thanks for the post, it's working well when the comman runs, although it is not saving all the results, just the latest one. At the end of the command I put : --out snp1_snp2 ..... – Angel Criollo Rayo Apr 28 '16 at 22:08
  • I guess your command overwrites in each loop what was previously there; you have to dynamically rename your output files with something like `--out "${var1}${var2}"` where `var1` and `var2` are the parameters you store your pair in. – Benjamin W. Apr 28 '16 at 22:15
  • thanks, it worked well! – Angel Criollo Rayo Apr 29 '16 at 00:31

0 Answers0