Commit eb8f3068 authored by Hanna  JULIENNE's avatar Hanna JULIENNE

Corrected causal simultation

parent 7b31ec08
Pipeline #10191 failed with stage
in 1 minute and 11 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -28,10 +28,12 @@ def compute_Y(beta, X, sig=1.0):
return Y
def compute_Zscore(Y, X):
nind = X.shape[0]
Zscores = np.zeros(X.shape[1])
for i in range(X.shape[1]):
Zscores[i] = X.iloc[:,i].dot(Y) / X.iloc[:,i].dot(X.iloc[:,i])
Zscores = (Zscores - Zscores.mean()) / np.std(Zscores)
Zscores[i] = X.iloc[:,i].corr(Y)# X.iloc[:,i].dot(Y) / X.iloc[:,i].dot(X.iloc[:,i])
Zscores = Zscores*nind**0.5
#Zscores = (Zscores - Zscores.mean()) / np.std(Zscores)
return Zscores
def generate_one_causal(amplitude, LD_cor, X):
......@@ -76,7 +78,6 @@ def best_rd(zscore, LD_cor, ids_known, ids_masked):
"rcond":np.argmax(cor_perf)})
if __name__=="__main__":
os.chdir("/home/hjulienn/Project/raiss/Simulation/")
#get genotype
X = pd.read_csv("./data/genotype.csv", sep="\t")
nsnp = X.shape[1]
......@@ -89,11 +90,11 @@ if __name__=="__main__":
ids_known = np.setdiff1d(np.array(range(100)), ids_masked)
amplitude_effect = pd.Series(index=np.arange(0,50,1))
tag = "one_positive"
tag = "two_opposite"
for amp in amplitude_effect.index:
print('search of best rd for amplitude {}'.format(amp))
signal = generate_one_causal(amp, LD_cor, X)
signal = generate_two_opposite(amp, LD_cor, X)
Zscore = signal["Zscore"]
beta = signal["causal"]
......
0,-0.20391320410738456
1,0.5896547542873918
2,0.37144892788629014
3,0.650166489107797
4,-1.131375436310386
5,-0.9259078813459047
6,-0.2921084599419763
7,2.358943196845763
8,0.655846455683395
9,-0.032651495636440306
10,1.7444149724575428
11,-0.17465089932412567
12,0.7455382421872849
13,0.4061550191519106
14,1.169240241340028
15,-0.6997191617580774
16,0.4562797418557831
17,-0.9847662456325408
18,-0.70852865470202
19,1.2532631616315257
20,1.5264408428998801
21,0.6390942980567169
22,-1.3819083221459831
23,-0.6279196193054853
24,2.1044160492820345
25,-1.4106730322153502
26,-0.5596232009058112
27,0.015084115790351602
28,-0.523769971153434
29,0.2504540330303369
30,1.5375623196897161
31,-2.1992111169860635
32,0.6461588859841236
33,-1.1686415494934692
34,-0.368027564860922
35,0.3382711622177748
36,0.9737621871339831
37,-1.6704089787725418
38,0.9418891475554247
39,-0.03532618066933436
40,0.3076837095114559
41,-1.2952275499591008
42,0.8369640288245084
43,1.2399546642780792
44,-0.6993308912776207
45,-0.3801253263788971
46,-0.87234537510688
47,0.10984394854588932
48,0.5312882614592922
49,-0.12075249295635776
0,0.2016377799398516
1,-0.23956339054698406
2,-0.3700543125262412
3,1.2883875129382878
4,1.0168474584994045
5,-1.6935824085777835
6,-0.5945245993106516
7,0.9175843262450301
8,1.2001530054569196
9,1.405027463409759
10,0.508589161475325
11,-0.7119874534844054
12,1.2568076682663307
13,0.06771699233922973
14,1.6750907013802072
15,0.7778126782150848
16,-0.583447704581133
17,-0.6440083904036444
18,0.20275541877344633
19,0.018836154852348158
20,0.3029498903844815
21,0.2918876943249339
22,-1.4127792913751096
23,-0.16324425579639565
24,0.1947176581733396
25,0.17136451092146207
26,-0.9325235546964339
27,-1.209939536193847
28,-0.579867398193668
29,0.5879393009072935
30,-1.0940418612892289
31,1.7140470962427214
32,0.6453326193513653
33,-0.6648756237348025
34,0.6502483907392919
35,-0.7876960555110518
36,-0.292883561468536
37,0.3077671230288082
38,-0.7764928070781968
39,-0.9743202608484821
40,1.1655354748167268
41,-0.25805097499828716
42,-0.3125629921194079
43,-1.1254315159202966
44,-0.1404046301991856
45,0.4748212508476614
46,0.11673478654395598
47,-2.1476110024385586
48,1.4381875484969986
49,0.439525481311141
50,25.0
51,0.08399744589024126
52,-1.1046283845325797
53,0.5045901114297241
54,-0.7588817903077129
55,-1.7719059545761675
56,1.3512155856771575
57,0.07806179912151762
58,0.3041633372748736
59,-1.2758123124705802
60,-1.4404388172667104
61,1.4149070426057877
62,-3.1326132887602283
63,-0.6868928210506422
64,-2.1601056346493306
65,0.18636884839422
66,-0.9599884510734886
67,0.7553418701928796
68,-0.5801832181632969
69,0.7052561842516794
70,0.12383211677909362
71,-0.4835840816652854
72,-1.864494918674018
73,1.8677344551470052
74,-1.9008480778383947
75,0.6349959721978555
76,-1.4977901654729286
77,-0.39961356443361107
78,-0.8642360822301626
79,0.4156180728721907
80,0.8785800518453744
81,-0.26231877969107925
82,-0.37219707167695176
83,0.7447627076891659
84,-0.11710847466322802
85,0.7096945389518131
86,-0.8741936106047762
87,-1.4105819311420367
88,-0.5322861324525582
89,-0.07324981118981488
90,-0.3131723037475416
91,-0.6591520692639076
92,-0.212193394502751
93,0.1983576597482148
94,0.4553584120853499
95,0.7409328660513057
96,-0.6354978719313896
97,1.525947470875792
98,0.3588239775668098
99,1.234744442878398
51,-0.5772146866900971
52,0.904264541510397
53,-0.7254171988140745
54,-1.7909089262364415
55,0.3577225271398779
56,0.8455190497298464
57,-1.1772223500033352
58,-0.29308383920052106
59,0.6420469571537142
60,-1.6071504304396036
61,-1.0790023118057162
62,0.2252740836744891
63,-1.5836504660283919
64,2.184970828949332
65,1.0378467691493196
66,-0.17650550815004604
67,0.5025534457429092
68,-0.4934343415201663
69,-0.004249567733526177
70,-0.4143739616540804
71,-0.6893772489488418
72,-0.034517314225151016
73,1.331177340525821
74,0.05605618502897344
75,-0.407645990137354
76,-0.24017172305846193
77,1.7153389957168956
78,-0.38286441530646304
79,-1.2158984648907323
80,-0.030192188805567313
81,-0.6403055328146741
82,0.16243126152067344
83,0.6437397059231363
84,-0.9277610650580729
85,-0.9700477066974225
86,-0.3247057998247632
87,0.543497637826619
88,-1.0217562126576034
89,-2.1365747340313916
90,-2.5263131549341686
91,0.06964727469982308
92,-0.5407347594549238
93,-1.3855386404392622
94,1.6059507268526467
95,0.5882776493681982
96,-0.7512182557751672
97,-0.5339636388288116
98,-0.7464353029820785
99,-0.20509739745259778
0,-0.2833015557539734
1,1.1137193487298573
2,-0.5751020136949129
3,0.25092718459231605
4,-0.9231607328579114
5,-0.5282440465750906
6,0.8966397340387556
7,1.025137710975423
8,2.1545806809282317
9,0.7405209368866464
10,0.6835216263324101
11,0.6103050930728369
12,-0.1334374102833025
13,1.4198265246470219
14,-0.025425675136311564
15,-0.44907078365314856
16,-1.5468635674187794
17,-0.5331544970182626
18,0.2194942000732836
19,0.6472502923604606
20,0.05283022559676286
21,1.3045418778933164
22,-0.9714238416084638
23,0.5559887318273533
24,-0.7992569512233562
0,-0.06659720915619761
1,2.577625602858331
2,1.1469867719537352
3,0.9648555901995858
4,-1.3924370603747185
5,0.5455878821217037
6,-0.015622357293898374
7,-0.9057201946209114
8,-1.5259318735326657
9,-0.10667869455962699
10,-1.2700916420885089
11,-1.046906321057954
12,0.7942163337022433
13,-0.03245679015785911
14,0.7539543645494159
15,-2.2062813625753086
16,-0.523913470668452
17,-1.0975441457343296
18,0.9447656433497813
19,0.9659164003866421
20,-1.6447745867353725
21,-0.5711211519644869
22,-0.014545677136408105
23,0.07822991470829127
24,-0.47442335792207235
25,25.0
26,-0.21746831361418983
27,0.5311847032983822
28,0.40559197474537845
29,0.40004653031636067
30,0.6153284385690463
31,1.363194338296307
32,0.7987204228748891
33,0.6467852406053607
34,-1.5592575756448548
35,0.7061978684204476
36,-0.9446771100766019
37,1.6410623532318769
38,-1.3256669039968385
39,-0.4967990656260579
40,2.7105706932313183
41,-0.17613604065618832
42,-0.43625291106654057
43,0.4013655693053687
44,1.6598664756978174
45,0.9436156498836157
46,-0.3610573422939318
47,2.1240370571649465
48,0.3654456729669973
49,0.4171198578995682
50,0.1747094226609475
51,0.6345954372982099
52,-1.5657077531204562
53,0.8099454296078114
54,-1.3815475193464855
55,0.26020936637231856
56,-0.20284542049627843
57,-0.33906719397517926
58,-0.29419980048222344
59,-0.10678005663493949
60,-1.453940962144116
61,0.10148585215590376
62,-0.5973987733455278
63,-0.269209456269701
64,-1.4151314063321025
65,0.2842124751754514
66,0.5012142925546401
67,-1.177719555232783
68,0.7407081562232875
69,-0.10993602398780414
70,1.8539450877599215
71,1.6152160006055396
72,-0.8154731745973266
73,-0.2744559659603909
74,0.7560920125868593
26,1.2457631934356035
27,0.8059054840013314
28,0.8900303223444963
29,0.3841071548036905
30,-1.6215483878076464
31,0.9173298270751732
32,2.1051137684873935
33,0.40513711902625016
34,0.5370428010615295
35,-0.8834876082597699
36,0.21738180085521636
37,0.8731468789664147
38,0.48575530966908326
39,-1.198237307311863
40,-1.7440462780635753
41,-0.5459675218352041
42,-0.536219761092213
43,-3.1438583842306893
44,1.9955687530851183
45,-1.1222872494122194
46,-0.6651669782173592
47,-0.027716384451354204
48,-1.2998014938312377
49,0.717038812246902
50,1.1209245666899226
51,-1.8992705682908337
52,1.5167836142117292
53,-0.5090336252462357
54,0.9792280835591411
55,-2.0144005775011884
56,-1.2337823107028651
57,0.1659032601608288
58,-1.7336551243764382
59,0.5586926480155389
60,-0.33982790475564884
61,1.8016859290623504
62,-0.5784727078453189
63,-0.4992335262105399
64,-3.7990169263057147
65,0.10588728433215536
66,0.23014659468555623
67,-1.2680103437917565
68,0.5750392443720826
69,0.19238666227065293
70,1.0874200476696216
71,-0.3086326274079308
72,0.3462897660117345
73,1.4391908791554626
74,1.8332314530856884
75,-25.0
76,-1.9150153175861253
77,0.13397210387328198
78,0.017013103365785716
79,0.11670783527577634
80,0.681431453023927
81,0.2766025397593883
82,-0.31498643217328987
83,1.1419887748265651
84,0.975576757573083
85,0.43530209027570643
86,-0.042724153068193445
87,-0.30743917100881446
88,-1.2587673887159139
89,-1.2110997994562274
90,0.16308896184714816
91,-0.1727101897923054
92,-0.7604085037485097
93,0.09583220326441612
94,0.614459554724203
95,0.3051399492047042
96,-2.757893113161325
97,-0.0998303819669334
98,-0.06691073630522072
99,0.5789726272553339
76,0.3652614566618937
77,-0.34900281219013435
78,-0.9652120468306805
79,-1.0447589531171915
80,0.5735731331651008
81,0.14169334098646774
82,-0.519204208763682
83,-1.269831277479186
84,-1.1915633538863528
85,-0.011319713058671273
86,0.5435308830413256
87,0.5771773758273387
88,1.0295011147193367
89,1.6421990722822706
90,0.604588084047694
91,-0.7016264979212866
92,0.8169577827531166
93,-2.5362075786550204
94,-0.18629922258046866
95,-0.07287076494534865
96,-0.643586261250713
97,-0.6940939108748988
98,-1.1641243739169445
99,0.5843849227661781
0,1.8025575236210356
1,-0.5552270142696769
2,-0.4285639509661904
3,1.274804918459334
4,-0.34556049972408365
5,-0.943434906397131
6,-1.0006945589173073
7,1.6998794359108056
8,0.5794922020649045
9,0.3420347003400587
10,-1.1715776275618084
11,0.5131026059188307
12,-0.6685096379131924
13,-1.0000833404957266
14,1.277126489467953
15,-0.5806935173532369
16,-0.8328820947015481
17,-0.8826594496252301
18,0.841649072259141
19,-1.270587832100099
20,2.0967557281433007
21,-0.4873503766326562
22,1.3998862941791128
23,-0.7921499953043597
24,-1.3430248545806363
0,0.2501439072612882
1,0.8939252352674104
2,2.0564474349500044
3,0.012890019940887183
4,-0.33464675953585443
5,-1.1933757986923714
6,-1.422004503234077
7,-0.7777102570173078
8,0.5171449179541934
9,-0.8300907473788753
10,-0.5775347780989238
11,0.14767165735262536
12,-1.9721024395786277
13,-0.27817929567477256
14,1.4896503981964753
15,-0.5279082700998666
16,-0.8300833496287727
17,-1.1192550376748354
18,-0.33070906877679873
19,-0.29489639406585866
20,1.3317332051229676
21,-2.261820910924611
22,1.3370450757795693
23,0.8859844361429542
24,0.8354277564801385
25,25.0
26,-0.8846193002442505
27,-0.21288221427235451
28,0.014392100161651485
29,-0.27055119878033135
30,-0.49235482768922934
31,-1.1544762602950638
32,-1.5613534606095019
33,-1.019053405789182
34,0.09578935284866708
35,0.4945653567017216
36,0.6960755202299728
37,0.21423772718673748
38,-1.2507737758391195
39,-0.2906763245368055
40,1.4661744730391222
41,-0.25977768219026887
42,-1.1060381796921626
43,0.5219011419277638
44,2.5247693005098775
45,-0.4407464012643449
46,-1.7629667202066674
47,0.3700089001386741
48,-0.5559860603489318
49,-0.6762478416106756
50,-0.2564100067387401
51,-0.934655005717179
52,0.46919113315844896
53,1.1794780014177042
54,0.47294837262751793
55,-0.7274191345827122
56,-0.8153347926859632
57,-1.073629780568152
58,0.09241045394991158
59,2.1520071696277214
60,-0.22467377685556852
61,-0.39592006777495803
62,0.055202893571084086
63,1.1760282132869206
64,1.0159331329693608
65,-0.8845658093370724
66,-0.8620435728803201
67,-2.036158860260977
68,0.14177664667461168
69,0.9816052381099066
70,1.4663518296259797
71,1.5912393132467109
72,-0.4687856607558591
73,-0.588175181845735
74,1.3488192909939074
26,1.479315841703275
27,0.4508121960652295
28,-2.0787094485112547
29,-1.2695988229542654
30,-0.6340889533464901
31,1.0775948308834162
32,0.7204571306817107
33,0.6396787654835799
34,-0.2882732070854332
35,1.1375982630996206
36,1.480744470594324
37,-0.33222972923608907
38,-0.5941393564279248
39,-0.46710913767965817
40,0.7359070258905388
41,-0.7677046046199757
42,0.8465149940981928
43,-0.6179240892717637
44,-0.36847356671869586
45,0.5533558567097103
46,1.7016208973533753
47,0.5659991702422262
48,1.0226566290711359
49,1.6987425279409067
50,-0.18141024846021953
51,1.6279987201447859
52,0.9440191162392306
53,1.0541704230654405
54,0.37696042912297745
55,1.1687017197505578
56,-1.0289186795948444
57,0.5233386795093651
58,-0.2283033576474741
59,1.565255700385214
60,-1.2359926093514058
61,0.10504272768315234
62,-0.6563378553148672
63,-0.17259103020004457
64,-0.6325266739529503
65,0.8235665034142563
66,-0.07967814817309926
67,-1.3152044299983134
68,0.3719046090209772
69,-0.8996045372749638
70,-0.5537712062819838
71,-1.3339260392317185
72,-0.4660395329863594
73,-0.44610946470662344
74,-0.6131422278268215
75,25.0
76,0.9812475857172418
77,0.36927149387068453
78,-0.3940106011338063
79,1.10334146795949
80,-0.37571253094014795
81,-0.13176683082393542
82,1.2258718084360876
83,-1.432279357474846
84,-0.11524279602402654
85,-0.9140386887571811
86,0.8768226449110638
87,-0.0718466665982749
88,-1.4630020030377726
89,1.320867657314122
90,-0.2435636779113219
91,-0.05069104193553215
92,-0.048931110380280564
93,0.6305758146742046
94,-1.272890772117725
95,0.5193153805949056
96,-1.992678619330077
97,-0.6796150090568936
98,0.34732678471750633
99,-0.39558576822842995
76,-0.1567753274363521
77,-1.4755039001704222
78,0.4643724046467662
79,1.107433361955131
80,-0.46958097366004975
81,-0.9832897979707382
82,-0.22997473275837424
83,0.24798250443473654
84,0.018102452664176576
85,2.1631204832335595
86,0.8780415638162099
87,0.4436011831774699
88,0.7614425648302102
89,-1.4844195009168148
90,-0.6928672330858102
91,-0.9161457731120534
92,-0.6787664992173711
93,0.48875956737455367
94,-1.5680951810901094
95,1.1780297510053372
96,-0.7957706060970612
97,1.5344443734984177
98,0.07975809769113158
99,-1.4381882115545588
0,0.5498947491964646
1,1.299165898760266
2,-0.8710414809780318
3,-0.30934167473045254
4,-1.0462903393885612
5,0.8930168256463261
6,1.1637741049931092
7,-0.4184661839089072
8,0.2893504668501217
9,-0.6770301243837661
10,-0.29813913438066947
11,-0.05792241149213983
12,-0.532612242597702
13,1.3316414421427039
14,-1.0865629857225259
15,-1.0527352532322805
16,0.6351883319354122
17,-0.9820077353349201
18,1.4323183530854509
19,1.7300415057806677
20,1.217265480918679
21,0.7911198976898782
22,-0.5441923809051735
23,-0.1753597894498861
24,-0.5118480283486864
25,0.2815528458336556
26,0.8349431689914809
27,-1.3437251279260438
28,-0.620630426774919
29,0.058308674742086966
30,0.03482321119270283
31,0.3384926244963026
32,-0.2985774082730817
33,-0.6368336540544478
34,0.10079760216154904
35,-0.07148649997760155
36,-0.5577607207012858
37,0.1742416204823311
38,1.2153482853159738
39,-0.24221025040566313
40,0.9955915636808921
41,0.17093510781718468
42,-1.1455153351076373
43,2.2840701298850523
44,0.3927828504534482
45,-0.37433992265876664
46,2.9723497561344514
47,2.396987540607526
48,1.4653725976979606
49,2.017789299278274
50,2.6864874612404934
51,-1.18403766195079
52,0.7301144760674169
53,-0.16011660966941504
54,-1.0849169237718879
55,-1.038058660563962
56,0.8673529892688497
57,1.2090825832895233
58,2.2094646358476253
59,0.4781396643294638
60,0.09952322346093803
61,0.24093518535208366
62,-0.29500693294521824
63,-1.3657008723969175
64,0.653537314736317
65,-1.0189448541234165
66,-1.3443526168152362
67,-0.8343629194589929
68,-0.30988956268865053
69,0.45103424883890153
70,0.48655487475084835
71,-1.0073315383952324
72,-0.8835446767339747
73,-1.111212682285474
74,-0.2809847289921364
75,0.3308284280258275
76,-0.890433572568488
77,-1.3295998961896511
78,0.11448676230415548
79,0.5742545881644717
80,1.394611197004362
81,-1.2332524416981983
82,0.30867758896643394
83,-0.9185475786583082
84,-0.7434567607263163
85,-1.2494595757290008
86,-0.5472432575383596
87,-0.8673752704175148
88,-0.3783727798266302
89,-0.3846470624434598
90,-0.868723936768242
91,-0.3935268169948425
92,0.21009420654750527
93,-0.49941870805766037
94,-0.8221409950280454