-
Notifications
You must be signed in to change notification settings - Fork 0
/
importing_bivariate_mean_stats.do
222 lines (208 loc) · 4.94 KB
/
importing_bivariate_mean_stats.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
* Importing and tidying up input files:
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
insheet using out_pheno_bivar_`j'_`j2'.hsq, clear ;
sxpose, clear firstnames force ;
gen firstrec=1 in 1 ;
gen vg1_se= _var1[_n+1] if firstrec==1 ;
gen vg2_se= _var2[_n+1] if firstrec==1 ;
gen cg12_se= _var3[_n+1] if firstrec==1 ;
gen ve1_se= _var4[_n+1] if firstrec==1 ;
gen ve2_se= _var5[_n+1] if firstrec==1 ;
gen ce12_se= _var6[_n+1] if firstrec==1 ;
gen vp1_se= Vp_tr1[_n+1] if firstrec==1 ;
gen vp2_se= Vp_tr2[_n+1] if firstrec==1 ;
gen vg_vp1_se= _var9[_n+1] if firstrec==1 ;
gen vg_vp2_se= _var10[_n+1] if firstrec==1 ;
gen rg_se= rG[_n+1] if firstrec==1 ;
rename _var1 vg1 ;
rename _var2 vg2 ;
rename _var3 cg12 ;
rename _var4 ve1 ;
rename _var5 ve2 ;
rename _var6 ve12 ;
rename Vp_tr1 vp1 ;
rename Vp_tr2 vp2 ;
rename _var9 vg_vp1 ;
rename _var10 vg_vp2 ;
rename rG rg ;
rename logL logl ;
rename logL0 logl0 ;
rename LRT lrt ;
rename Pval p ;
drop in 2 ;
drop firstrec ;
gen trait1=`j' ;
gen trait2=`j2' ;
order trait1 trait2, first ;
save `j'_`j2'.dta, replace ;
} ;
else clear ;
} ;
} ;
#delimit cr
clear
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
append using `j'_`j2'.dta ;
} ;
else ;
} ;
} ;
#delimit cr
split p, p(" (")
drop p p2
rename p1 p
split logl0, p(" (")
drop logl0 logl02
rename logl01 log10
destring *, replace
* Erasing all temporary files:
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
erase `j'_`j2'.dta ;
} ;
else ;
} ;
} ;
#delimit cr
* Saving file:
save "bivariate_output\unadjusted_bivariate_heritabilities_means.dta", replace
* Creating rg & rg se files:
use "bivariate_output\unadjusted_bivariate_heritabilities_means.dta", clear
keep trait1 trait2 rg
rename rg _var
reshape wide _var, i(trait1) j(trait2)
rename trait1 trait
gen _var1=.
order _var1, after(trait)
set obs 24
drop trait
gen trait=_n
order trait, first
compress
save "bivariate_output\bivariate_rg_unadjusted_means.dta", replace
use "bivariate_output\unadjusted_bivariate_heritabilities_means.dta", clear
keep trait1 trait2 rg_se
rename rg_se _var
reshape wide _var, i(trait1) j(trait2)
rename trait1 trait
gen _var1=.
order _var1, after(trait)
set obs 24
drop trait
gen trait=_n
order trait, first
order trait, first
compress
save "bivariate_output\bivariate_rg_se_unadjusted_means.dta", replace
* Adjusted:
* Importing and tidying up input files:
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
insheet using out_pheno_adj_bivar_`j'_`j2'.hsq, clear ;
sxpose, clear firstnames force ;
gen firstrec=1 in 1 ;
gen vg1_se= _var1[_n+1] if firstrec==1 ;
gen vg2_se= _var2[_n+1] if firstrec==1 ;
gen cg12_se= _var3[_n+1] if firstrec==1 ;
gen ve1_se= _var4[_n+1] if firstrec==1 ;
gen ve2_se= _var5[_n+1] if firstrec==1 ;
gen ce12_se= _var6[_n+1] if firstrec==1 ;
gen vp1_se= Vp_tr1[_n+1] if firstrec==1 ;
gen vp2_se= Vp_tr2[_n+1] if firstrec==1 ;
gen vg_vp1_se= _var9[_n+1] if firstrec==1 ;
gen vg_vp2_se= _var10[_n+1] if firstrec==1 ;
gen rg_se= rG[_n+1] if firstrec==1 ;
rename _var1 vg1 ;
rename _var2 vg2 ;
rename _var3 cg12 ;
rename _var4 ve1 ;
rename _var5 ve2 ;
rename _var6 ve12 ;
rename Vp_tr1 vp1 ;
rename Vp_tr2 vp2 ;
rename _var9 vg_vp1 ;
rename _var10 vg_vp2 ;
rename rG rg ;
rename logL logl ;
rename logL0 logl0 ;
rename LRT lrt ;
rename Pval p ;
drop in 2 ;
drop firstrec ;
gen trait1=`j' ;
gen trait2=`j2' ;
order trait1 trait2, first ;
save `j'_`j2'.dta, replace ;
} ;
else clear ;
} ;
} ;
#delimit cr
clear
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
append using `j'_`j2'.dta ;
} ;
else ;
} ;
} ;
#delimit cr
split p, p(" (")
drop p p2
rename p1 p
split logl0, p(" (")
drop logl0 logl02
rename logl01 log10
destring *, replace
* Erasing all temporary files:
#delimit ;
forvalues j = 1/24 { ;
forvalues j2 = 1/24 { ;
if `j2'>`j' { ;
erase `j'_`j2'.dta ;
} ;
else ;
} ;
} ;
#delimit cr
* Saving file:
save "bivariate_output\adjusted_bivariate_heritabilities_means.dta", replace
* Creating rg & rg se files:
use "bivariate_output\adjusted_bivariate_heritabilities_means.dta", clear
keep trait1 trait2 rg
rename rg _var
reshape wide _var, i(trait1) j(trait2)
rename trait1 trait
gen _var1=.
order _var1, after(trait)
set obs 24
drop trait
gen trait=_n
order trait, first
compress
save "bivariate_output\bivariate_rg_adjusted_means.dta", replace
use "bivariate_output\adjusted_bivariate_heritabilities_means.dta", clear
keep trait1 trait2 rg_se
rename rg_se _var
reshape wide _var, i(trait1) j(trait2)
rename trait1 trait
gen _var1=.
order _var1, after(trait)
set obs 24
drop trait
gen trait=_n
order trait, first
compress
save "bivariate_output\bivariate_rg_se_adjusted_means.dta", replace