Debian Codegraph @

tests/manualtests/ms_vs_scrm-tmrca-wit-recomb_Tifs.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 #Compare summary statistics of ms and scrm for TMRCA with recombination events
4 mkdirscip-shell system . . mkdir. test-tmrca-recomb-Tifs
5 cd test-tmrca-recomb-Tifs
6
7
8 seqlen=100000
9
10 rep=1000
11
12
13 echoscip-shell system . . echo. -e "rm(list=ls());
14 for (i in (1:${rep})){
15 p=read.table(paste(\"xx\",i,\"Trees_freq\",sep=\"\"))\$V1/${seqlen};
16 T=read.table(paste(\"xx\",i,\"Trees_tmrca\",sep=\"\"));
17 bl=read.table(paste(\"xx\",i,\"Trees_bl\",sep=\"\"));
18 cat(paste(sum(T*p),sum(T^2*p),sum(T^3*p),sum(T^4*p),sep=\"\t\") ,file=\"tmrca_moments\",append=TRUE);
19 cat(\"\n\",file=\"tmrca_moments\",append=TRUE);
20 cat(paste(sum(bl*p),sum(bl^2*p),sum(bl^3*p),sum(bl^4*p),sep=\"\t\") ,file=\"bl_moments\",append=TRUE);
21 cat(\"\n\",file=\"bl_moments\",append=TRUE);
22 }" > compute_moments.r
23
24 msNsample=(2 3 4 7 10 20)
25 msr=(10 20 10 50 100)
26 mst=(10 20 50 100 10)
27
28 #msNsample=(3)
29 #msr=(10)
30 #mst=(10)
31
32
33 ## compare TMRCA
34 compareTMRCA=compareTMRCA-RECOMB
35 rmscip-shell system . . rm. ${compareTMRCA}
36
37 ## compare total branch length
38 compareBL=compareBL-RECOMB
39 rmscip-shell system . . rm. ${compareBL}
40
41 rmscip-shell system . . rm. *pdf
42 #theta=10
43 echoscip-shell system . . echo. -e "compare TMRCA for ${rep} replicates \n\t\t\t|\t1st\t\t\t|\t2nd\t\t\t|\t3rd\t\t\t|\t4th\t\t\t
44 \t\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t" > ${compareTMRCA}
45
46 echoscip-shell system . . echo. -e "compare total branch length for ${rep} replicates \n\t\t\t|\t1st\t\t\t|\t2nd\t\t\t|\t3rd\t\t\t|\t4th\t\t\t
47 \t\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t|\tstats\tp-value\t\t" > ${compareBL}
48 rmscip-shell system . . rm. tmrca_moments
49 rmscip-shell system . . rm. bl_moments
50
51
52 for t in "${mst[@]}"
53 do
54 for r in "${msr[@]}"
55 do
56 for nsam in "${msNsample[@]}"
57 do
58 rmscip-shell system . . rm. ms_tmrca_moments
59 rmscip-shell system . . rm. scrm_tmrca_moments
60
61 rmscip-shell system . . rm. ms_bl_moments
62 rmscip-shell system . . rm. scrm_bl_moments
63
64 prefix=${nsam}sample${r}rho${t}theta
65 out=${prefix}out
66 segrecomb=${prefix}segRecomb
67
68 ms ${nsam} ${rep} -t ${t} -r ${r} ${seqlen} -T | tailscip-shell system . . tail. -n +4 | gawkscip-shell system . . gawk. '/^\/\//{f="xx"++d} f{print > f} scip-shell filesystem . . `/^\/\//{f="xx"++d} f{print > f} `.'
69 for file in $(seqscip-shell system . . seq. 1 1 ${rep})
70 do
71 grepscip-shell system . . grep. ";" xx${file} | sedscip-shell system . . sed. -e 's/\[.*\]//g' > xxTrees
72 hybrid-Lambda -gt xxTrees -tmrca xx${file}Trees_tmrca
73 hybrid-Lambda -gt xxTrees -bl xx${file}Trees_bl
74 grepscip-shell system . . grep. ";" xx${file} | sedscip-shell system . . sed. -e 's/\[//g' -e 's/\].*;//g' > xx${file}Trees_freq
75
76 done
77 R CMD BATCH compute_moments.r
78 findscip-shell system . . find. . -name "xx*" -print0 | xargsscip-shell system . . xargs. -0 rm
79 mvscip-shell system . . mv. tmrca_moments ms_tmrca_moments
80 mvscip-shell system . . mv. bl_moments ms_bl_moments
81
82
83 scrm ${nsam} ${rep} -t ${t} -r ${r} ${seqlen} -Tifs | tailscip-shell system . . tail. -n +4 | gawkscip-shell system . . gawk. '/^\/\//{f="xx"++d} f{print > f} scip-shell filesystem . . `/^\/\//{f="xx"++d} f{print > f} `.'
84 for file in $(seqscip-shell system . . seq. 1 1 ${rep})
85 do
86 grepscip-shell system . . grep. ";" xx${file} | sedscip-shell system . . sed. -e 's/\[.*\]//g' > xxTrees
87 hybrid-Lambda -gt xxTrees -tmrca xx${file}Trees_tmrca
88 hybrid-Lambda -gt xxTrees -bl xx${file}Trees_bl
89 grepscip-shell system . . grep. ";" xx${file} | sedscip-shell system . . sed. -e 's/\[//g' -e 's/\].*;//g' > xx${file}Trees_freq
90
91 done
92 R CMD BATCH compute_moments.r
93 findscip-shell system . . find. . -name "xx*" -print0 | xargsscip-shell system . . xargs. -0 rm
94 mvscip-shell system . . mv. tmrca_moments scrm_tmrca_moments
95 mvscip-shell system . . mv. bl_moments scrm_bl_moments
96
97 echoscip-shell system . . echo. "rm(list=ls());
98 msdata=read.table(\"ms_tmrca_moments\");
99 scrmdata=read.table(\"scrm_tmrca_moments\");
100 m1test=ks.test(msdata\$V1,scrmdata\$V1)
101 m2test=ks.test(msdata\$V2,scrmdata\$V2)
102 m3test=ks.test(msdata\$V3,scrmdata\$V3)
103 m4test=ks.test(msdata\$V4,scrmdata\$V4)
104 pdf(paste($nsam,\"sampleTMRCAmut\",${t},\"recomb\",${r},\"-KStest.pdf\",sep=\"\"));
105 par(mfrow=c(2,2))
106 plot(ecdf(msdata\$V1), xlim=range(c(msdata\$V1, scrmdata\$V1)),col=\"red\", main=\"1st Moment\")
107 plot(ecdf(scrmdata\$V1), add=TRUE, lty=\"dashed\", col=\"blue\")
108 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m1test\$statistic,sep=\"\"), paste(\"p-value = \",format(m1test\$p.value,scientific = TRUE),sep=\"\")))
109 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
110 ####
111 plot(ecdf(msdata\$V2), xlim=range(c(msdata\$V2, scrmdata\$V2)),col=\"red\", main=\"2nd Moment\")
112 plot(ecdf(scrmdata\$V2), add=TRUE, lty=\"dashed\", col=\"blue\")
113 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m2test\$statistic,sep=\"\"), paste(\"p-value = \",format(m2test\$p.value,scientific = TRUE),sep=\"\")))
114 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
115 ####
116 plot(ecdf(msdata\$V3), xlim=range(c(msdata\$V3, scrmdata\$V3)),col=\"red\", main=\"3rd Moment\")
117 plot(ecdf(scrmdata\$V3), add=TRUE, lty=\"dashed\", col=\"blue\")
118 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m3test\$statistic,sep=\"\"), paste(\"p-value = \",format(m3test\$p.value,scientific = TRUE),sep=\"\")))
119 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
120 ####
121 plot(ecdf(msdata\$V4), xlim=range(c(msdata\$V4, scrmdata\$V4)),col=\"red\", main=\"4th Moment\")
122 plot(ecdf(scrmdata\$V4), add=TRUE, lty=\"dashed\", col=\"blue\")
123 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m4test\$statistic,sep=\"\"), paste(\"p-value = \",format(m4test\$p.value,scientific = TRUE),sep=\"\")))
124 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
125 ####
126 dev.off();
127 cat(paste(${nsam},${t},${r},\"|\",
128 format(m1test\$statistic,digits=4),format(m1test\$p.value,scientific = TRUE),\"|\",
129 format(m2test\$statistic,digits=4),format(m2test\$p.value,scientific = TRUE),\"|\",
130 format(m3test\$statistic,digits=4),format(m3test\$p.value,scientific = TRUE),\"|\",
131 format(m4test\$statistic,digits=4),format(m4test\$p.value,scientific = TRUE),
132 sep=\"\t\"),file=\"${compareTMRCA}\",append=TRUE);cat(\"\n\",file=\"${compareTMRCA}\",append=TRUE);
133
134 rm(list=ls());
135 msdata=read.table(\"ms_bl_moments\");
136 scrmdata=read.table(\"scrm_bl_moments\");
137 m1test=ks.test(msdata\$V1,scrmdata\$V1)
138 m2test=ks.test(msdata\$V2,scrmdata\$V2)
139 m3test=ks.test(msdata\$V3,scrmdata\$V3)
140 m4test=ks.test(msdata\$V4,scrmdata\$V4)
141 pdf(paste($nsam,\"sampleBLmut\",${t},\"recomb\",${r},\"-KStest.pdf\",sep=\"\"));
142 par(mfrow=c(2,2))
143 plot(ecdf(msdata\$V1), xlim=range(c(msdata\$V1, scrmdata\$V1)),col=\"red\", main=\"1st Moment\")
144 plot(ecdf(scrmdata\$V1), add=TRUE, lty=\"dashed\", col=\"blue\")
145 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m1test\$statistic,sep=\"\"), paste(\"p-value = \",format(m1test\$p.value,scientific = TRUE),sep=\"\")))
146 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
147 ####
148 plot(ecdf(msdata\$V2), xlim=range(c(msdata\$V2, scrmdata\$V2)),col=\"red\", main=\"2nd Moment\")
149 plot(ecdf(scrmdata\$V2), add=TRUE, lty=\"dashed\", col=\"blue\")
150 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m2test\$statistic,sep=\"\"), paste(\"p-value = \",format(m2test\$p.value,scientific = TRUE),sep=\"\")))
151 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
152 ####
153 plot(ecdf(msdata\$V3), xlim=range(c(msdata\$V3, scrmdata\$V3)),col=\"red\", main=\"3rd Moment\")
154 plot(ecdf(scrmdata\$V3), add=TRUE, lty=\"dashed\", col=\"blue\")
155 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m3test\$statistic,sep=\"\"), paste(\"p-value = \",format(m3test\$p.value,scientific = TRUE),sep=\"\")))
156 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
157 ####
158 plot(ecdf(msdata\$V4), xlim=range(c(msdata\$V4, scrmdata\$V4)),col=\"red\", main=\"4th Moment\")
159 plot(ecdf(scrmdata\$V4), add=TRUE, lty=\"dashed\", col=\"blue\")
160 legend(\"bottomright\",c(paste(\"Tests Statistics = \",m4test\$statistic,sep=\"\"), paste(\"p-value = \",format(m4test\$p.value,scientific = TRUE),sep=\"\")))
161 legend(\"topleft\",c(\"ms\",\"scrm\"), col=c(\"red\",\"blue\"), pch=16)
162 ####
163 dev.off();
164 cat(paste(${nsam},${t},${r},\"|\",
165 format(m1test\$statistic,digits=4),format(m1test\$p.value,scientific = TRUE),\"|\",
166 format(m2test\$statistic,digits=4),format(m2test\$p.value,scientific = TRUE),\"|\",
167 format(m3test\$statistic,digits=4),format(m3test\$p.value,scientific = TRUE),\"|\",
168 format(m4test\$statistic,digits=4),format(m4test\$p.value,scientific = TRUE),
169 sep=\"\t\"),file=\"${compareBL}\",append=TRUE);cat(\"\n\",file=\"${compareBL}\",append=TRUE);
170 " > dummy.r
171 R CMD BATCH dummy.r
172 done
173 done
174 done
175
176