Biostar Beta. Not for public use.
Question: how to run STRUCTURE command n times for each K value?
1
Entering edit mode

I am running some STRUCTURE analysis and set k = {1..10} by using this command (only 1 run for each K):

for k in seq10
do
python /home/ubuntu/bin/fastStructure/structure.py -K $k --input=../file.snps --output=snpl525D --format=str
done

Instead of 1 run for each K, now I want to get 15 runs for each K, could you please help me to modify the code above to do this job! thanks

ADD COMMENTlink 2.6 years ago Ana • 170 • updated 2.6 years ago Zev.Kronenberg 11k
Entering edit mode
0

It seems to me you are overwriting the output at each loop iteration.

ADD REPLYlink 2.6 years ago
h.mon
25k
1
Entering edit mode

Nest a per-k for loop inside a parent for loop:

$ for k in `seq 1 10`; do for eachK in `seq 1 15`; do echo "$k : $eachK"; done; done
1 : 1
1 : 2
1 : 3
1 : 4
1 : 5
...
10 : 13
10 : 14
10 : 15

As a comment notes, you may be overwriting output on each iteration. You can use the values of k and eachK to uniquely name the result.

ADD COMMENTlink 2.6 years ago Alex Reynolds 28k
1
Entering edit mode

Since perl is still cool. Here's the gist,

perl -e 'print join "\n", (0..10)' | xargs -I {} -P 10 admixture -K {} -o {}.something

Edited:

   perl -e 'print join "\n", ((0..10) x 15)' | xargs -I {} -P 10 admixture -K {} -o {}.something
ADD COMMENTlink 2.6 years ago Zev.Kronenberg 11k
Entering edit mode
0

I think, but am not certain, that the question is asking how to run 15 trials on each of ten values, not necessarily how to run ten jobs in parallel.

ADD REPLYlink 2.6 years ago
Alex Reynolds
28k
Entering edit mode
0

Alex Reynolds No problem, see edited answer. I love how fast and sleazy perl is.

ADD REPLYlink 2.6 years ago
Zev.Kronenberg
11k
0
Entering edit mode
doit() {
  k="$1"
  n="$2"
  python /home/ubuntu/bin/fastStructure/structure.py -K "$k" --input=../file.snps --output=snpl525D-"$k"-"$n" --format=str
}
export -f doit
parallel doit ::: {1..10} ::: {1..15}
ADD COMMENTlink 2.6 years ago ole.tange ♦ 3.4k

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0