gwaslab 3.4.49__py3-none-any.whl → 3.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gwaslab might be problematic. Click here for more details.

@@ -38,6 +38,7 @@ def annotate_single(
38
38
  region,
39
39
  region_anno_bbox_args,
40
40
  skip,
41
+ arrow_kwargs=None,
41
42
  anno_height=1,
42
43
  amode="int",
43
44
  snpid="SNPID",
@@ -48,6 +49,9 @@ def annotate_single(
48
49
  _invert=False,
49
50
  log=Log()
50
51
  ):
52
+ if arrow_kwargs is None:
53
+ arrow_kwargs=dict()
54
+
51
55
  if anno and (to_annotate.empty is not True):
52
56
  #initiate a list for text and a starting position
53
57
  text = []
@@ -60,21 +64,21 @@ def annotate_single(
60
64
  elif anno:
61
65
  annotation_col=anno
62
66
  log.write(" -Annotating using column "+annotation_col+"...", verbose=verbose)
63
-
67
+ ################################################################################################################################
64
68
  ## calculate y span
65
69
  if region is not None:
66
70
  y_span = region[2] - region[1]
67
71
  else:
68
72
  y_span = sumstats["i"].max()-sumstats["i"].min()
69
-
70
73
  log.write(" -Adjusting text positions with repel_force={}...".format(repel_force), verbose=verbose)
71
74
  if anno_style == "expand" :
72
75
  to_annotate.loc[:, "ADJUSTED_i"] = adjust_text_position(to_annotate["i"].values.copy(), y_span, repel_force,max_iter=anno_max_iter,log=log,amode=amode,verbose=verbose)
73
76
  ## iterate through variants to be annotated
77
+ ################################################################################################################################
78
+
74
79
  anno_to_adjust_list = list()
75
80
 
76
81
  for rowi,row in to_annotate.iterrows():
77
-
78
82
  # avoid text overlapping
79
83
  ## adjust x to avoid overlapping################################################################
80
84
  if anno_style == "right" :
@@ -93,7 +97,7 @@ def annotate_single(
93
97
  else:
94
98
  pass
95
99
  ################################################################
96
- #shrink or increase the arm
100
+ # shrink or increase the arm by a factor (arm_scale)
97
101
  if arm_scale_d is not None:
98
102
  if anno_count not in arm_scale_d.keys():
99
103
  arm_scale =1
@@ -102,20 +106,32 @@ def annotate_single(
102
106
  ################################################################
103
107
 
104
108
  # vertical arm length in pixels
105
- #to_annotate["scaled_P"] = to_annotate5["scaled_P_2"].copy()
106
- # arm length in pixels
107
- #armB_length_in_point = ax1.transData.transform((skip,1.15*maxy))[1]-ax1.transData.transform((skip, row["scaled_P"]+1))[1]-arm_offset/2
108
- armB_length_in_point = ax1.transData.transform((skip,1.15*maxy))[1]-ax1.transData.transform((skip, row["scaled_P"]+0.01*maxy))[1]-arm_offset/2
109
- # scale if needed
110
- armB_length_in_point = armB_length_in_point*arm_scale
109
+ # Annotation y : 1.15 * maxy_anno
110
+ # Top dot: 1 * maxy_anno
111
+ # armB_length_in_point_raw = 0.15 * maxy_anno -> gap_pixel
112
+ # Fixed Offset: 0.5 * 0.15 * gap_pixel
113
+
114
+ #Calculate armB length in pixels
115
+ # arm_scale: raise up the ceiling
116
+
117
+ # gap : 0.5* space between top variant and annotation text
118
+ gap_pixel = (ax1.transData.transform((0,1.15*maxy*arm_scale))[1]-ax1.transData.transform((0, maxy*arm_scale))[1])*0.5
119
+
120
+ # armB_length_in_pixel_raw : distance between variant to annotate and annotation text
121
+ armB_length_in_pixel_raw = ax1.transData.transform((0,1.15*maxy*arm_scale))[1]-ax1.transData.transform((0, row["scaled_P"]+1))[1]
122
+
123
+ armB_length_in_pixel = armB_length_in_pixel_raw - gap_pixel
124
+
111
125
  ################################################################
126
+ # armB_length_in_pixel should not be negative
112
127
  if arm_scale>=1:
113
- #armB_length_in_point= armB_length_in_point if armB_length_in_point>0 else ax1.transData.transform((skip, maxy+2))[1]-ax1.transData.transform((skip, row["scaled_P"]+1))[1]
114
- armB_length_in_point= armB_length_in_point if armB_length_in_point>0 else ax1.transData.transform((skip, maxy+0.02*maxy))[1]-ax1.transData.transform((skip, row["scaled_P"]+0.01*maxy))[1]
115
- ###if anno_fixed_arm_length #############################################################
128
+ armB_length_in_pixel = max(0, armB_length_in_pixel)
129
+
130
+ ################################################################
131
+ #if setting anno_fixed_arm_length
116
132
  if anno_fixed_arm_length is not None:
117
- anno_fixed_arm_length_factor = ax1.transData.transform((skip,anno_fixed_arm_length))[1]-ax1.transData.transform((skip,0))[1]
118
- armB_length_in_point = anno_fixed_arm_length_factor
133
+ armB_length_in_pixel = ax1.transData.transform((skip,anno_fixed_arm_length))[1]-ax1.transData.transform((skip,0))[1]
134
+
119
135
  ################################################################################################################################
120
136
  # annotation alias
121
137
  if anno==True:
@@ -129,26 +145,31 @@ def annotate_single(
129
145
  else:
130
146
  annotation_text=row["Annotation"]
131
147
 
132
-
133
- #xy=(row["i"],row["scaled_P"]+0.2)
148
+ ################################################################################################################################
149
+ # setting arrow xy and text xy
150
+ # add a small space between variant and arrow head
134
151
  xy=(row["i"],row["scaled_P"]+0.01*maxy)
135
- xytext=(last_pos,1.15*maxy*arm_scale*anno_height)
152
+
153
+ # text xy is of the same height
154
+ # anno_height can be used to adjust the height of annotation text
155
+ xytext=(last_pos,1.15*maxy*(arm_scale + anno_height -1))
136
156
 
157
+ # for anno_fixed_arm_length
137
158
  if anno_fixed_arm_length is not None:
138
- armB_length_in_point = anno_fixed_arm_length
139
- xytext=(row["i"],row["scaled_P"]+0.2+anno_fixed_arm_length)
140
-
159
+ xytext=(row["i"],row["scaled_P"] + 0.2 + anno_fixed_arm_length)
160
+
161
+ ################################################################################################################################
162
+ # if not changing the directions of some annotation arror arms
141
163
  if anno_count not in anno_d.keys():
142
- #arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
143
- # connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_point)+",rad=0")
144
164
  if _invert==False:
145
165
  arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
146
- connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_point)+",rad=0")
166
+ connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_pixel)+",rad=0")
147
167
  else:
148
168
  arrowargs = dict(arrowstyle="-|>",relpos=(0,1),color="#ebebeb",
149
- connectionstyle="arc,angleA=0,armA=0,angleB=-90,armB="+str(armB_length_in_point)+",rad=0")
169
+ connectionstyle="arc,angleA=0,armA=0,angleB=-90,armB="+str(armB_length_in_pixel)+",rad=0")
150
170
  else:
151
- # adjuest horizontal direction
171
+ # if not changing the directions of some annotation arror arms
172
+ # adjust horizontal direction
152
173
  xy=(row["i"],row["scaled_P"])
153
174
  if anno_d[anno_count] in ["right","left","l","r"]:
154
175
  if anno_d[anno_count]=="right" or anno_d[anno_count]=="r":
@@ -170,7 +191,7 @@ def annotate_single(
170
191
  elif anno_d[anno_count]=="left" or anno_d[anno_count]=="l":
171
192
  arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
172
193
  connectionstyle="arc,angleA=-135,armA="+str( anno_d[anno_count][1])+",angleB=135,armB="+str( anno_d[anno_count][1])+",rad=0")
173
-
194
+ ################################################################################################################################
174
195
 
175
196
  if "r" in mode:
176
197
  arrowargs["color"] = "black"
@@ -179,16 +200,19 @@ def annotate_single(
179
200
  bbox_para[key]=value
180
201
  else:
181
202
  bbox_para=None
182
-
203
+
204
+ ################################################################################################################################
183
205
  if _invert==False:
184
- anno_default = {"rotation":40,"fontstyle":"italic","ha":"left","va":"bottom","fontsize":anno_fontsize,"fontweight":"normal","fontfamily":font_family}
206
+ anno_default = {"rotation":40, "fontstyle":"italic","ha":"left","va":"bottom","fontsize":anno_fontsize,"fontweight":"normal","fontfamily":font_family}
185
207
  else:
186
- anno_default = {"rotation":-40,"fontstyle":"italic","ha":"left","va":"top","fontsize":anno_fontsize,"fontweight":"normal","fontfamily":font_family}
208
+ anno_default = {"rotation":-40,"fontstyle":"italic","ha":"left","va":"top", "fontsize":anno_fontsize,"fontweight":"normal","fontfamily":font_family}
187
209
 
210
+ ################################################################################################################################
188
211
  if anno_style == "expand" :
189
212
  anno_default["rotation"] = 90
190
213
  if anno_style == "tight" :
191
214
  anno_default["rotation"] = 90
215
+ ################################################################################################################################
192
216
 
193
217
  for key,value in anno_args.items():
194
218
  anno_default[key]=value
@@ -196,12 +220,15 @@ def annotate_single(
196
220
  if row["i"] in highlight_i:
197
221
  for key,value in highlight_anno_args.items():
198
222
  anno_default[key]=value
199
-
223
+ ################################################################################################################################
200
224
  if anno_adjust==True:
201
225
  if _invert==False:
202
226
  arrowargs=dict(arrowstyle='-|>', color='grey', shrinkA=10, linewidth=0.1, relpos=(0,0.5))
203
227
  else:
204
228
  arrowargs=dict(arrowstyle='-|>', color='grey', shrinkA=10, linewidth=0.1, relpos=(1,0.5))
229
+ ################################################################################################################################
230
+ for key,value in arrow_kwargs.items():
231
+ arrowargs[key]=value
205
232
 
206
233
  anno_to_adjust = ax1.annotate(annotation_text,
207
234
  xy=xy,
@@ -213,6 +240,8 @@ def annotate_single(
213
240
  )
214
241
  anno_to_adjust_list.append(anno_to_adjust)
215
242
  anno_count +=1
243
+ ################################################################################################################################
244
+
216
245
  #anno_adjust_keyargs = {"arrowprops":dict(arrowstyle='->', color='grey', linewidth=0.1,relpos=(0.5,0.5))}
217
246
  if anno_adjust==True:
218
247
  log.write(" -Auto-adjusting text positions...", verbose=verbose)
@@ -270,6 +299,7 @@ def annotate_pair(
270
299
  pos="POS",
271
300
  repel_force=0.02,
272
301
  verbose=True,
302
+ arrow_kwargs=None,
273
303
  log=Log()
274
304
  ):
275
305
  if anno is not None:
@@ -354,15 +384,25 @@ def annotate_pair(
354
384
  arm_scale = arm_scale_d[anno_count]
355
385
 
356
386
  # vertical arm length in pixels
357
- armB_length_in_point = ax.transData.transform((skip,1.15*maxy_anno))[1]-ax.transData.transform((skip, row["scaled_P"]+1))[1]-arm_offset/2
358
- # times arm_scale to increase or reduce the length
359
- armB_length_in_point = armB_length_in_point*arm_scale
387
+ # Annotation y : 1.15 * maxy_anno
388
+ # Top dot: 1 * maxy_anno
389
+ # armB_length_in_point_raw = 0.15 * maxy_anno -> gap_pixel
390
+ # Fixed Offset: 0.5 * 0.15 * gap_pixel
391
+
392
+ #Calculate armB length in pixels
393
+ # arm_scale: raise up the ceiling
394
+ gap_pixel = (ax1.transData.transform((0,1.15*maxy_anno*arm_scale))[1]-ax1.transData.transform((0, maxy_anno*arm_scale))[1])*0.5
395
+
396
+ armB_length_in_pixel_raw = ax1.transData.transform((0,1.15*maxy_anno*arm_scale))[1]-ax1.transData.transform((0, row["scaled_P"]+1))[1]
397
+
398
+ armB_length_in_pixel = armB_length_in_pixel_raw - gap_pixel
360
399
 
361
400
  if arm_scale>=1:
362
- armB_length_in_point= armB_length_in_point if armB_length_in_point>0 else 0 #ax.transData.transform((skip, maxy_anno+2))[1]-ax.transData.transform((skip, row["scaled_P"]+1))[1]
401
+ armB_length_in_pixel= armB_length_in_pixel if armB_length_in_pixel>0 else 0
402
+
363
403
  if anno_fixed_arm_length is not None:
364
404
  anno_fixed_arm_length_factor = ax.transData.transform((skip,anno_fixed_arm_length))[1]-ax.transData.transform((skip,0))[1]
365
- armB_length_in_point = anno_fixed_arm_length_factor
405
+ armB_length_in_pixel = anno_fixed_arm_length_factor
366
406
 
367
407
  if anno==True:
368
408
  if row[snpid] in anno_alias.keys():
@@ -383,24 +423,24 @@ def annotate_pair(
383
423
  xytext=(last_pos,1.15*maxy_anno*arm_scale)
384
424
 
385
425
  if anno_fixed_arm_length is not None:
386
- armB_length_in_point = anno_fixed_arm_length
426
+ armB_length_in_pixel = anno_fixed_arm_length
387
427
  xytext=(row["i"],row["scaled_P"]+0.2+anno_fixed_arm_length)
388
428
 
389
429
  if anno_count not in anno_d.keys():
390
430
  if index==0:
391
431
  #upper panel
392
- if armB_length_in_point <5:
432
+ if armB_length_in_pixel <5:
393
433
  arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",connectionstyle="arc,armA=0,armB=0,rad=0.")
394
434
  else:
395
435
  arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
396
- connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_point)+",rad=0")
436
+ connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_pixel)+",rad=0")
397
437
  else:
398
438
  #lower panel
399
- if armB_length_in_point <5:
439
+ if armB_length_in_pixel <5:
400
440
  arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",connectionstyle="arc,armA=0,armB=0,rad=0.")
401
441
  else:
402
442
  arrowargs = dict(arrowstyle="-|>",relpos=(0,1),color="#ebebeb",
403
- connectionstyle="arc,angleA=0,armA=0,angleB=-90,armB="+str(armB_length_in_point)+",rad=0")
443
+ connectionstyle="arc,angleA=0,armA=0,angleB=-90,armB="+str(armB_length_in_pixel)+",rad=0")
404
444
 
405
445
  else:
406
446
  xy=(row["i"],row["scaled_P"])
@@ -441,6 +481,7 @@ def annotate_pair(
441
481
  arrowargs=dict(arrowstyle='-|>', color='grey', shrinkA=10, linewidth=0.1, relpos=(0,0.5))
442
482
  else:
443
483
  arrowargs=dict(arrowstyle='-|>', color='grey', shrinkA=10, linewidth=0.1, relpos=(1,0.5))
484
+
444
485
 
445
486
  anno_to_adjust = ax.annotate(annotation_text,
446
487
  xy=xy,
@@ -478,204 +519,4 @@ def annotate_pair(
478
519
  )
479
520
  else:
480
521
  log.write(" -Skip annotating", verbose=verbose)
481
- return ax1,ax5
482
-
483
-
484
- # subtype plot
485
- def annotate_subtype(
486
- sumstats,
487
- anno,
488
- mode,
489
- ax1,
490
- highlight_i,
491
- to_annotate,
492
- anno_d,
493
- anno_alias,
494
- anno_style,
495
- anno_args,
496
- arm_scale,
497
- anno_max_iter,
498
- arm_scale_d,
499
- arm_offset,
500
- anno_adjust,
501
- anno_fixed_arm_length,
502
- maxy,
503
- anno_fontsize,
504
- region,
505
- region_anno_bbox_args,
506
- skip,
507
- snpid="SNPID",
508
- chrom="CHR",
509
- pos="POS",
510
- repel_force=0.02,
511
- verbose=True,
512
- log=Log()
513
- ):
514
- if anno and (to_annotate.empty is not True):
515
- #initiate a list for text and a starting position
516
- text = []
517
- last_pos=0
518
- anno_count=0
519
- to_annotate = to_annotate.sort_values(by=[chrom,pos])
520
- ## log : annotation column
521
- if anno==True:
522
- annotation_col="CHR:POS"
523
- elif anno:
524
- annotation_col=anno
525
- log.write(" -Annotating using column "+annotation_col+"...", verbose=verbose)
526
-
527
- ## calculate y span
528
- if region is not None:
529
- y_span = region[2] - region[1]
530
- else:
531
- y_span = sumstats["i"].max()-sumstats["i"].min()
532
-
533
- log.write(" -Adjusting text positions with repel_force={}...".format(repel_force), verbose=verbose)
534
- if anno_style == "expand" :
535
- to_annotate.loc[:, "ADJUSTED_i"] = adjust_text_position(to_annotate["i"].values.copy(), y_span, repel_force,max_iter=anno_max_iter,log=log,verbose=verbose)
536
- ## iterate through variants to be annotated
537
- anno_to_adjust_list = list()
538
-
539
- for rowi,row in to_annotate.iterrows():
540
-
541
- # avoid text overlapping
542
- ## adjust x to avoid overlapping################################################################
543
- if anno_style == "right" :
544
- #right style
545
- if row["i"]>last_pos+repel_force*y_span:
546
- last_pos=row["i"]
547
- else:
548
- last_pos+=repel_force*y_span
549
- elif anno_style == "expand" :
550
- #expand style
551
- last_pos = row["ADJUSTED_i"]
552
- anno_args["rotation"] = 90
553
- elif anno_style == "tight" :
554
- #tight style
555
- anno_fixed_arm_length = 1
556
- anno_adjust = True
557
- anno_args["rotation"] = 90
558
- else:
559
- pass
560
- ################################################################
561
- #shrink or increase the arm
562
- if arm_scale_d is not None:
563
- if anno_count not in arm_scale_d.keys():
564
- arm_scale =1
565
- else:
566
- arm_scale = arm_scale_d[anno_count]
567
- ################################################################
568
-
569
- # vertical arm length in pixels
570
- armB_length_in_point = ax1.transData.transform((skip,1.15*maxy))[1]-ax1.transData.transform((skip, row["scaled_P"]+1))[1]-arm_offset/2
571
- # scale if needed
572
- armB_length_in_point = armB_length_in_point*arm_scale
573
- ################################################################
574
- if arm_scale>=1:
575
- armB_length_in_point= armB_length_in_point if armB_length_in_point>0 else ax1.transData.transform((skip, maxy+2))[1]-ax1.transData.transform((skip, row["scaled_P"]+1))[1]
576
- ###if anno_fixed_arm_length #############################################################
577
- if anno_fixed_arm_length is not None:
578
- anno_fixed_arm_length_factor = ax1.transData.transform((skip,anno_fixed_arm_length))[1]-ax1.transData.transform((skip,0))[1]
579
- armB_length_in_point = anno_fixed_arm_length_factor
580
- ################################################################################################################################
581
- # annotation alias
582
- if anno==True:
583
- if row[snpid] in anno_alias.keys():
584
- annotation_text = anno_alias[row[snpid]]
585
- else:
586
- annotation_text="Chr"+ str(row[chrom]) +":"+ str(int(row[pos]))
587
- elif anno:
588
- annotation_text=row["Annotation"]
589
-
590
- #
591
- fontweight = "normal"
592
- if len(highlight_i) >0:
593
- if row["i"] in highlight_i:
594
- fontweight = "bold"
595
-
596
-
597
- xy=(row["i"],row["scaled_P"]+0.2)
598
- xytext=(last_pos, 1.15*maxy*arm_scale)
599
-
600
- if anno_fixed_arm_length is not None:
601
- armB_length_in_point = anno_fixed_arm_length
602
- xytext=(row["i"],row["scaled_P"]+0.2+anno_fixed_arm_length)
603
-
604
- if anno_count not in anno_d.keys():
605
- #arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
606
- # connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_point)+",rad=0")
607
- arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
608
- connectionstyle="arc,angleA=0,armA=0,angleB=90,armB="+str(armB_length_in_point)+",rad=0")
609
- else:
610
- # adjuest direction
611
- xy=(row["i"],row["scaled_P"])
612
- if anno_d[anno_count] in ["right","left","l","r"]:
613
- if anno_d[anno_count]=="right" or anno_d[anno_count]=="r":
614
- armoffsetall = (ax1.transData.transform(xytext)[0]-ax1.transData.transform(xy)[0])*np.sqrt(2)
615
- armoffsetb = arm_offset
616
- armoffseta = armoffsetall - armoffsetb
617
- arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
618
- connectionstyle="arc,angleA=-135,armA="+str(armoffseta)+",angleB=45,armB="+str(armoffsetb)+",rad=0")
619
- elif anno_d[anno_count]=="left" or anno_d[anno_count]=="l":
620
- arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
621
- connectionstyle="arc,angleA=-135,armA="+str(arm_offset)+",angleB=135,armB="+str(arm_offset)+",rad=0")
622
- else:
623
- if anno_d[anno_count][0]=="right" or anno_d[anno_count][0]=="r":
624
- armoffsetall = (ax1.transData.transform(xytext)[0]-ax1.transData.transform(xy)[0])*np.sqrt(2)
625
- armoffsetb = anno_d[anno_count][1]
626
- armoffseta = armoffsetall - armoffsetb
627
- arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
628
- connectionstyle="arc,angleA=-135,armA="+str(armoffseta)+",angleB=45,armB="+str(armoffsetb)+",rad=0")
629
- elif anno_d[anno_count]=="left" or anno_d[anno_count]=="l":
630
- arrowargs = dict(arrowstyle="-|>",relpos=(0,0),color="#ebebeb",
631
- connectionstyle="arc,angleA=-135,armA="+str( anno_d[anno_count][1])+",angleB=135,armB="+str( anno_d[anno_count][1])+",rad=0")
632
-
633
-
634
- if "r" in mode:
635
- arrowargs["color"] = "black"
636
- bbox_para=dict(boxstyle="round", fc="white",zorder=3)
637
- for key,value in region_anno_bbox_args.items():
638
- bbox_para[key]=value
639
- else:
640
- bbox_para=None
641
-
642
- anno_default = {"rotation":40,"style":"italic","ha":"left","va":"bottom","fontsize":anno_fontsize,"fontweight":fontweight}
643
- for key,value in anno_args.items():
644
- anno_default[key]=value
645
-
646
- if anno_adjust==True:
647
- arrowargs=dict(arrowstyle='-|>', color='grey', shrinkA=10, linewidth=0.1, relpos=(0,0.5))
648
- anno_to_adjust = ax1.annotate(annotation_text,
649
- xy=xy,
650
- xytext=xytext,
651
- bbox=bbox_para,
652
- arrowprops=arrowargs,
653
- zorder=100,
654
- **anno_default
655
- )
656
- anno_to_adjust_list.append(anno_to_adjust)
657
- anno_count +=1
658
- #anno_adjust_keyargs = {"arrowprops":dict(arrowstyle='->', color='grey', linewidth=0.1,relpos=(0.5,0.5))}
659
- if anno_adjust==True:
660
- log.write(" -Auto-adjusting text positions...", verbose=verbose)
661
- adjust_text(texts = anno_to_adjust_list,
662
- autoalign=False,
663
- only_move={'points':'x', 'text':'x', 'objects':'x'},
664
- ax=ax1,
665
- precision=0.02,
666
- force_text=(repel_force,repel_force),
667
- expand_text=(1,1),
668
- expand_objects=(0,0),
669
- expand_points=(0,0),
670
- va="bottom",
671
- ha='left',
672
- avoid_points=False,
673
- lim =100
674
- #kwargs = anno_adjust_keyargs
675
- )
676
-
677
- else:
678
- log.write(" -Skip annotating", verbose=verbose)
679
-
680
- return ax1
681
-
522
+ return ax1,ax5
@@ -0,0 +1,2 @@
1
+ import matplotlib.pyplot as plt
2
+
@@ -80,6 +80,7 @@ def _quick_fix_chr(seires, chr_dict,log=Log(), verbose=True):
80
80
  '''
81
81
  if pd.api.types.is_string_dtype(seires) == True:
82
82
  # if chr is string dtype: convert using chr_dict
83
+ seires = seires.astype("string")
83
84
  seires = seires.map(chr_dict, na_action="ignore")
84
85
  seires = np.floor(pd.to_numeric(seires, errors='coerce')).astype('Int64')
85
86
  return seires
@@ -93,6 +94,12 @@ def _quick_fix_pos(seires,log=Log(), verbose=True):
93
94
  return seires
94
95
 
95
96
 
97
+ def _dropna_in_cols(sumstats, cols, log=Log(), verbose=True):
98
+ to_drop = sumstats[cols].isna().any(axis=1)
99
+ log.write(" -Dropping {} variants due to missing values in {}.".format(sum(to_drop),cols))
100
+ return sumstats.loc[~to_drop,:]
101
+
102
+
96
103
  def _get_largenumber(*args,log=Log(), verbose=True):
97
104
  '''
98
105
  get a helper large number, >> max(pos)
@@ -330,7 +337,7 @@ def _cut(series, mode,cutfactor,cut,skip, ylabels, cut_log, verbose, lines_to_pl
330
337
  if "b" not in mode:
331
338
  log.write(" -Minus log10(P) values above " + str(cut)+" will be shrunk with a shrinkage factor of " + str(cutfactor)+"...", verbose=verbose)
332
339
  else:
333
- log.write(" -Minus DENSITY values above " + str(cut)+" will be shrunk with a shrinkage factor of " + str(cutfactor)+"...", verbose=verbose)
340
+ log.write(" -DENSITY values above " + str(cut)+" will be shrunk with a shrinkage factor of " + str(cutfactor)+"...", verbose=verbose)
334
341
 
335
342
  maxticker=int(np.round(series.max(skipna=True)))
336
343
 
@@ -448,4 +455,4 @@ def _jagged_y(cut,skip,ax1,mode,mqqratio,jagged_len,jagged_wid, log=Log(), verbo
448
455
  ax1.plot((x0,-dx), (tycut,tycut+dy), zorder=1001, **kwargs)
449
456
  ax1.plot((-dx,+dx), (tycut+dy,tycut+3*dy), zorder=1001, **kwargs)
450
457
  ax1.plot((+dx,x0), (tycut+3*dy,tycut+4*dy), zorder=1001, **kwargs)
451
- return ax1
458
+ return ax1
@@ -50,7 +50,8 @@ def get_default_path(keyword,fmt="png"):
50
50
  "ldscrg":"ldscrg_heatmap",
51
51
  "miami":"miami",
52
52
  "esc":"effect_size_comparision",
53
- "afc":"allele_frequency_comparision"
53
+ "afc":"allele_frequency_comparision",
54
+ "gwheatmap":"genome_wide_heatmap"
54
55
  }
55
56
  prefix = path_dictionary[keyword]
56
57
  count = 1