gwaslab 3.5.5__py3-none-any.whl → 3.5.7__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.

@@ -0,0 +1,283 @@
1
+ import pandas as pd
2
+ import matplotlib.pyplot as plt
3
+ import matplotlib.ticker as ticker
4
+ import matplotlib.patches as patches
5
+ import seaborn as sns
6
+ import numpy as np
7
+ import scipy as sp
8
+ import copy
9
+ from math import ceil
10
+ from shutil import which
11
+ from pyensembl import EnsemblRelease
12
+ from allel import GenotypeArray
13
+ from allel import read_vcf
14
+ from allel import rogers_huff_r_between
15
+ import matplotlib as mpl
16
+ from scipy import stats
17
+ from mpl_toolkits.axes_grid1.inset_locator import inset_axes
18
+ from mpl_toolkits.axes_grid1.inset_locator import mark_inset
19
+ from matplotlib.ticker import MaxNLocator
20
+ import gc as garbage_collect
21
+ from adjustText import adjust_text
22
+ from gwaslab.viz_aux_reposition_text import adjust_text_position
23
+ from gwaslab.viz_aux_annotate_plot import annotate_single
24
+ from gwaslab.viz_plot_qqplot import _plot_qq
25
+ from gwaslab.hm_harmonize_sumstats import auto_check_vcf_chr_dict
26
+ from gwaslab.viz_plot_regional2 import _plot_regional
27
+ from gwaslab.viz_plot_regional2 import process_vcf
28
+ from gwaslab.viz_plot_regional2 import _get_lead_id
29
+ from gwaslab.viz_aux_quickfix import _get_largenumber
30
+ from gwaslab.viz_aux_quickfix import _quick_fix_p_value
31
+ from gwaslab.viz_aux_quickfix import _quick_fix_pos
32
+ from gwaslab.viz_aux_quickfix import _quick_fix_chr
33
+ from gwaslab.viz_aux_quickfix import _quick_fix_eaf
34
+ from gwaslab.viz_aux_quickfix import _quick_fix_mlog10p
35
+ from gwaslab.viz_aux_quickfix import _quick_add_tchrpos
36
+ from gwaslab.viz_aux_quickfix import _quick_merge_sumstats
37
+ from gwaslab.viz_aux_quickfix import _quick_assign_i
38
+ from gwaslab.viz_aux_quickfix import _quick_assign_i_with_rank
39
+ from gwaslab.viz_aux_quickfix import _quick_extract_snp_in_region
40
+ from gwaslab.viz_aux_quickfix import _quick_assign_highlight_hue_pair
41
+ from gwaslab.viz_aux_quickfix import _quick_assign_marker_relative_size
42
+ from gwaslab.viz_aux_quickfix import _cut
43
+ from gwaslab.viz_aux_quickfix import _set_yticklabels
44
+ from gwaslab.viz_aux_quickfix import _jagged_y
45
+ from gwaslab.viz_aux_save_figure import save_figure
46
+ from gwaslab.g_Log import Log
47
+ from gwaslab.util_in_calculate_gc import lambdaGC
48
+ from gwaslab.util_in_get_sig import getsig
49
+ from gwaslab.util_in_get_sig import annogene
50
+ from gwaslab.bd_common_data import get_chr_to_number
51
+ from gwaslab.bd_common_data import get_number_to_chr
52
+ from gwaslab.bd_common_data import get_recombination_rate
53
+ from gwaslab.bd_common_data import get_gtf
54
+ from gwaslab.util_in_filter_value import _filter_region
55
+ from gwaslab.g_version import _get_version
56
+ from matplotlib.colors import ListedColormap
57
+ from matplotlib.colors import LinearSegmentedColormap
58
+ from matplotlib.colors import to_hex
59
+ from gwaslab.io_process_args import _extract_kwargs
60
+
61
+ def _plot_effect(to_plot,
62
+ y=None,
63
+ y_sort=None,
64
+ group=None,
65
+ x="BETA",
66
+ se="SE",
67
+ eaf="EAF",
68
+ snpr2="SNPR2",
69
+ ylabel="Variant",
70
+ eaf_panel=True,
71
+ snpvar_panel=True,
72
+ rename_dic=None,
73
+ err_args=None,
74
+ font_args=None,
75
+ save=None,
76
+ title=None,
77
+ save_args=None,
78
+ eaf_args=None,
79
+ snpr2_args=None,
80
+ fig_args=None,
81
+ scatter_args=None,
82
+ effect_label=None,
83
+ eaf_label=None,
84
+ snpr2_label=None,
85
+ log=Log(),
86
+ verbose=True,
87
+ legend_mode=1,
88
+ ncol=2,
89
+ size=None,
90
+ hue=None,
91
+ style=None,
92
+ **args):
93
+
94
+ if err_args is None:
95
+ err_args={"ecolor":"#cccccc",
96
+ "linewidth":0,
97
+ "zorder":90,
98
+ "elinewidth":1}
99
+ if eaf_args is None:
100
+ eaf_args={"color":"#74BAD3"}
101
+ if snpr2_args is None:
102
+ snpr2_args={"color":"#74BAD3"}
103
+ if font_args is None:
104
+ font_args={'fontsize':12,'family':'sans','fontname':'Arial'}
105
+ if fig_args is None:
106
+ fig_args={"figsize":(8,8),"dpi":300}
107
+ if scatter_args is None:
108
+ scatter_args={"s":20}
109
+
110
+
111
+ legend_titles=[]
112
+ if hue is not None:
113
+ args["hue"] = hue
114
+ legend_titles.append(hue)
115
+
116
+ if size is not None:
117
+ args["size"] = size
118
+ legend_titles.append(size)
119
+
120
+ if style is not None:
121
+ args["style"] = style
122
+ legend_titles.append(style)
123
+
124
+
125
+ save_kwargs = _extract_kwargs("save", save_args, locals())
126
+ err_kwargs = _extract_kwargs("err", err_args, locals())
127
+ scatter_kwargs = _extract_kwargs("scatter", scatter_args, locals())
128
+ font_kwargs = _extract_kwargs("font",font_args, locals())
129
+
130
+ def concat_cols(cols):
131
+ string = "-".join(map(str,cols))
132
+ return string
133
+
134
+ y_name = "-".join(y)
135
+
136
+ to_plot[y_name] = to_plot[y].apply(lambda x: concat_cols(x), axis=1)
137
+
138
+
139
+ # sort y
140
+ if y_sort is None:
141
+ y_sort = ["CHR","POS","STUDY"]
142
+
143
+ to_plot = to_plot.sort_values(by=y_sort)
144
+
145
+ if group is None:
146
+ group = ["CHR","POS"]
147
+ to_plot = to_plot.sort_values(by=group)
148
+ # Assign group IDs based on the sorted 'score'
149
+
150
+ to_plot['_VAR_GROUP'] = to_plot.groupby(group).ngroup() + 1
151
+
152
+ to_plot["_VAR_INDEX"] = range(len(to_plot))
153
+ to_plot["_VAR_INDEX"]= to_plot["_VAR_INDEX"] + to_plot['_VAR_GROUP']
154
+
155
+ y="_VAR_INDEX"
156
+
157
+ if rename_dic is None:
158
+ rename_dic = {
159
+ "BETA":"Per-allele effect size",
160
+ "STUDY":"Study"
161
+ }
162
+ ncols=1
163
+ if eaf_panel:
164
+ ncols+=1
165
+ if snpvar_panel:
166
+ ncols+=1
167
+
168
+ if ncols==1:
169
+ fig,ax1 = plt.subplots(ncols=ncols, **fig_args)
170
+ elif ncols==2:
171
+ if eaf_panel==True:
172
+ fig,axes = plt.subplots(ncols=ncols, dpi=400,sharey=True)
173
+ ax1=axes[0]
174
+ ax2=axes[1]
175
+ else:
176
+ fig,axes = plt.subplots(ncols=ncols, dpi=400,sharey=True)
177
+ ax1=axes[0]
178
+ ax3=axes[1]
179
+ else:
180
+ fig,axes = plt.subplots(ncols=ncols, dpi=400,sharey=True)
181
+ ax1=axes[0]
182
+ ax2=axes[1]
183
+ ax3=axes[2]
184
+
185
+ sns.scatterplot(data=to_plot, x=x, y=y, ax=ax1, zorder=100, **args)
186
+
187
+ ax1.errorbar(y=to_plot[y], x=to_plot[x], xerr=to_plot[se],
188
+ **err_kwargs)
189
+
190
+ ax1.axvline(x=0,linestyle="dashed",c="grey")
191
+ ax1.set_yticks(to_plot[y], labels = to_plot[y_name])
192
+ ax1.set_ylabel(ylabel)
193
+
194
+ if title is not None:
195
+ ax1.set_title(title)
196
+
197
+ if eaf_panel==True:
198
+ ax2.barh(y=to_plot[y], width=to_plot[eaf], zorder=100, **eaf_args)
199
+ ax2.set_xlabel(eaf)
200
+
201
+ if snpvar_panel==True:
202
+ ax3.barh(y=to_plot[y], width=to_plot[snpr2], zorder=100,**snpr2_args)
203
+ ax3.set_xlabel(snpr2)
204
+
205
+ #try:
206
+ if legend_mode==1:
207
+ #if ncols==1:
208
+ sns.move_legend(
209
+ ax1, "upper left",
210
+ bbox_to_anchor=(1, 1), title=None, frameon=False, bbox_transform = axes[-1].transAxes
211
+ )
212
+ #else:
213
+ ##
214
+ # sns.move_legend(
215
+ # ax1, "lower left",
216
+ # bbox_to_anchor=(0, ncols), title=None, frameon=False,
217
+ # )
218
+ #elif legend_mode==2:
219
+ # sns.move_legend(
220
+ # ax1, "lower center",
221
+ # bbox_to_anchor=(0, 1), ncol=ncol, title=None, frameon=False,
222
+ # )
223
+ #except:
224
+ # pass
225
+
226
+
227
+ #handles, labels = ax1.get_legend_handles_labels()
228
+ #if len(labels)>0:
229
+ # #new_labels = []
230
+ # #ncol = len(labels)
231
+ # max_col=0
232
+ # new_labels=[]
233
+ # new_labels_i = []
234
+ # previous_i = 0
235
+ # max_string_len=0
236
+ # for i in range(len(labels)):
237
+ # if len(labels[i]) > max_string_len:
238
+ # max_string_len = len(labels[i])
239
+ # if labels[i] in legend_titles:
240
+ # new_labels_i.append(i)
241
+ # col_number = i - previous_i
242
+ # if col_number > max_col:
243
+ # max_col = col_number
244
+ # previous_i = i
245
+ # for i in labels:
246
+ # new_labels.append(str(i).ljust(max_string_len))
247
+ # print(new_labels)
248
+ # new_labels_i.append(len(labels))
249
+ #
250
+ # legend_rows = []
251
+ # #new_labels_i[index+1] - i
252
+ # for index, i in enumerate(new_labels_i):
253
+ # if index<len(new_labels_i)-1:
254
+ # legend_row = ax1.legend(labels = new_labels[i:new_labels_i[index+1]],
255
+ # handles= handles[i:new_labels_i[index+1]],
256
+ # loc="lower left",
257
+ # bbox_to_anchor=(-0.2, 1.02 + 0.05*index),
258
+ # ncol=max_col,
259
+ # scatterpoints=1,
260
+ # title=None,
261
+ # borderpad=0,
262
+ # handletextpad=0.1,
263
+ # handlelength=0.7,
264
+ # borderaxespad =0,
265
+ # alignment = "left",
266
+ # fontsize=8,
267
+ # frameon=False)
268
+ # legend_rows.append(legend_row)
269
+ # for legend_row in legend_rows[:-1]:
270
+ # ax1.add_artist(legend_row)
271
+
272
+
273
+
274
+ if effect_label is not None:
275
+ ax1.set_xlabel(effect_label)
276
+ if eaf_label is not None:
277
+ ax2.set_xlabel(eaf_label)
278
+ if snpr2_label is not None:
279
+ ax3.set_xlabel(snpr2_label)
280
+
281
+ save_figure(fig, save, keyword="forest",save_args=save_kwargs, log=log, verbose=verbose)
282
+
283
+ return fig
@@ -249,7 +249,7 @@ def plot_miami2(
249
249
  #####################################################################################################################
250
250
  ##plotting
251
251
  if figax is None:
252
- fig_args["figsize"] = (15,10)
252
+ #fig_args["figsize"] = (15,10)
253
253
  fig, (ax1, ax5) = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 1]},**fig_args)
254
254
  plt.subplots_adjust(hspace=region_hspace)
255
255
  else:
@@ -110,9 +110,17 @@ def mqqplot(insumstats,
110
110
  region_anno_bbox_args = None,
111
111
  region_marker_shapes=None,
112
112
  region_legend_marker=True,
113
- cbar_title='LD $r^{2}$ with variant',
113
+ region_ref_alias = None,
114
+ cbar_title='LD $\mathregular{r^2}$ with variant',
114
115
  cbar_fontsize = None,
116
+ cbar_scale=True,
115
117
  cbar_font_family = None,
118
+ cbar_bbox_to_anchor = (0,0,1,1),
119
+ cbar_equal_aspect = True,
120
+ cbar_w_scale=1,
121
+ cbar_h_scale=1,
122
+ cbar_downward_offset =1.3,
123
+ cbar_borderpad=None,
116
124
  track_n=4,
117
125
  track_n_offset=0,
118
126
  track_fontsize_ratio=0.95,
@@ -197,7 +205,9 @@ def mqqplot(insumstats,
197
205
  title_pad=1.08,
198
206
  title_fontsize=13,
199
207
  fontsize = 9,
200
- font_family="Arial",
208
+ font_family=None,
209
+ fontfamily="Arial",
210
+ math_fontfamily="dejavusans",
201
211
  anno_fontsize = 9,
202
212
  figargs=None,
203
213
  fig_args= None,
@@ -222,6 +232,7 @@ def mqqplot(insumstats,
222
232
  ):
223
233
 
224
234
  # log.writeing meta info #######################################################################################
235
+
225
236
  if chr_dict is None:
226
237
  chr_dict = get_chr_to_number()
227
238
  if xtick_chr_dict is None:
@@ -281,7 +292,8 @@ def mqqplot(insumstats,
281
292
 
282
293
  # 7 colors
283
294
  region_ld_colors_m = ["#E51819","#367EB7","green","#F07818","#AD5691","yellow","purple"]
284
-
295
+ if font_family is None:
296
+ font_family = fontfamily
285
297
  if region_title_args is None:
286
298
  region_title_args = {"size":10}
287
299
  if cbar_fontsize is None:
@@ -297,7 +309,7 @@ def mqqplot(insumstats,
297
309
  if maf_bin_colors is None:
298
310
  maf_bin_colors = ["#f0ad4e","#5cb85c", "#5bc0de","#000042"]
299
311
  if save_args is None:
300
- save_args = {"dpi":400,"facecolor":"white"}
312
+ save_args = {"dpi":600,"facecolor":"none"}
301
313
  if highlight is None:
302
314
  highlight = list()
303
315
  if highlight_anno_args is None:
@@ -328,22 +340,15 @@ def mqqplot(insumstats,
328
340
  else:
329
341
  _if_quick_qc = False
330
342
 
331
- if save is not None:
332
- if type(save) is not bool:
333
- if len(save)>3:
334
- if save[-3:]=="pdf" or save[-3:]=="svg":
335
- fig_args["dpi"]=72
336
- scatter_args["rasterized"]=True
337
- qq_scatter_args["rasterized"]=True
338
- else:
339
- fig_args["dpi"] = save_args["dpi"]
340
-
341
343
  # configure dpi if saving the plot
342
- fig_args, scatter_args, qq_scatter_args, save_args = _configure_fig_save_kwargs(save = save,
344
+ fig_args, scatter_args, qq_scatter_args, save_args = _configure_fig_save_kwargs(mode=mode,
345
+ save = save,
343
346
  fig_args = fig_args,
344
347
  scatter_args = scatter_args,
345
348
  qq_scatter_args = qq_scatter_args,
346
- save_args = save_args)
349
+ save_args = save_args,
350
+ log=log,
351
+ verbose=verbose)
347
352
 
348
353
 
349
354
  if len(anno_d) > 0 and arm_offset is None:
@@ -810,12 +815,16 @@ def mqqplot(insumstats,
810
815
  region=region,
811
816
  vcf_path=vcf_path,
812
817
  marker_size=marker_size,
813
- fontsize=fontsize,
814
818
  build=build,
815
- chrom_df=chrom_df,
816
- xtick_chr_dict=xtick_chr_dict,
819
+ cbar_scale=cbar_scale,
820
+ cbar_fontsize=cbar_fontsize,
821
+ cbar_bbox_to_anchor=cbar_bbox_to_anchor,
822
+ cbar_w_scale=cbar_w_scale,
823
+ cbar_h_scale=cbar_h_scale,
824
+ cbar_equal_aspect=cbar_equal_aspect,
825
+ cbar_downward_offset =cbar_downward_offset,
826
+ cbar_borderpad=cbar_borderpad,
817
827
  cut_line_color=cut_line_color,
818
- vcf_chr_dict =vcf_chr_dict,
819
828
  gtf_path=gtf_path,
820
829
  gtf_chr_dict = gtf_chr_dict,
821
830
  gtf_gene_name=gtf_gene_name,
@@ -828,17 +837,16 @@ def mqqplot(insumstats,
828
837
  region_step = region_step,
829
838
  region_ref = region_ref,
830
839
  region_ref_index_dic = region_ref_index_dic,
840
+ region_ref_alias = region_ref_alias,
831
841
  region_grid = region_grid,
832
842
  region_grid_line = region_grid_line,
833
843
  region_lead_grid = region_lead_grid,
834
844
  region_lead_grid_line = region_lead_grid_line,
835
- region_hspace=region_hspace,
836
845
  region_title=region_title,
837
846
  region_title_args=region_title_args,
838
847
  region_ld_legend = region_ld_legend,
839
848
  region_legend_marker=region_legend_marker,
840
849
  region_ld_threshold = region_ld_threshold,
841
- region_ld_colors = region_ld_colors,
842
850
  palette = palette,
843
851
  region_marker_shapes = region_marker_shapes,
844
852
  region_recombination = region_recombination,
@@ -846,8 +854,6 @@ def mqqplot(insumstats,
846
854
  region_flank_factor =region_flank_factor,
847
855
  track_font_family=track_font_family,
848
856
  taf=taf,
849
- tabix=tabix,
850
- chrom=chrom,
851
857
  pos=pos,
852
858
  verbose=verbose,
853
859
  log=log
@@ -906,10 +912,10 @@ def mqqplot(insumstats,
906
912
 
907
913
  # Configure X, Y axes #######################################################
908
914
  log.write("Start to process figure arts.",verbose=verbose)
909
- if region is None:
910
- # if Manhattan plot
911
-
912
- ax1 = _process_xtick(ax1=ax1,
915
+
916
+ ax1, ax3 = _process_xtick(ax1=ax1,
917
+ ax3=ax3,
918
+ mode=mode,
913
919
  chrom_df=chrom_df,
914
920
  xtick_chr_dict=xtick_chr_dict,
915
921
  fontsize = fontsize,
@@ -933,7 +939,8 @@ def mqqplot(insumstats,
933
939
  mode=mode,
934
940
  bwindowsizekb=bwindowsizekb,
935
941
  fontsize=fontsize,
936
- font_family=font_family,
942
+ font_family=font_family,
943
+ math_fontfamily=math_fontfamily,
937
944
  ax4=ax4,
938
945
  log=log,
939
946
  verbose=verbose)
@@ -1115,11 +1122,14 @@ def mqqplot(insumstats,
1115
1122
 
1116
1123
  ##############################################################################################################################################################################
1117
1124
 
1118
- def _configure_fig_save_kwargs(save=None,
1125
+ def _configure_fig_save_kwargs(mode="m",
1126
+ save=None,
1119
1127
  fig_args=None,
1120
1128
  scatter_args=None,
1121
1129
  qq_scatter_args=None,
1122
- save_args=None):
1130
+ save_args=None,
1131
+ log=Log(),
1132
+ verbose=True):
1123
1133
  if fig_args is None:
1124
1134
  fig_args = dict()
1125
1135
  if scatter_args is None:
@@ -1135,8 +1145,14 @@ def _configure_fig_save_kwargs(save=None,
1135
1145
  if save[-3:]=="pdf" or save[-3:]=="svg":
1136
1146
  # to save as vectorized plot
1137
1147
  fig_args["dpi"]=72
1138
- scatter_args["rasterized"]=True
1139
- qq_scatter_args["rasterized"]=True
1148
+
1149
+ if mode!="r":
1150
+ scatter_args["rasterized"]=True
1151
+ qq_scatter_args["rasterized"]=True
1152
+ log.write("Saving as pdf/svg: scatter plot will be rasterized for mqq...", verbose=verbose)
1153
+ else:
1154
+ scatter_args["rasterized"]=False
1155
+ qq_scatter_args["rasterized"]=False
1140
1156
  else:
1141
1157
  fig_args["dpi"] = save_args["dpi"]
1142
1158
  return fig_args, scatter_args, qq_scatter_args, save_args
@@ -1397,45 +1413,52 @@ def _process_line(ax1, sig_line, suggestive_sig_line, additional_line, lines_to_
1397
1413
 
1398
1414
  def _process_cbar(cbar, cbar_fontsize, cbar_font_family, cbar_title, log=Log(),verbose=True):
1399
1415
  log.write(" -Processing color bar...",verbose=verbose)
1400
- #if type(cbar) == list:
1401
- # for cbar_single in cbar:
1402
- # cbar_yticklabels = cbar_single.ax.get_yticklabels()
1403
- # cbar_single.ax.set_yticklabels(cbar_yticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
1404
- # cbar_single.ax.set_title(cbar_title, fontsize=cbar_fontsize, family=cbar_font_family, loc="center",y=-0.2 )
1405
- #else:
1406
-
1416
+
1407
1417
  cbar_yticklabels = cbar.get_yticklabels()
1408
- cbar.set_yticklabels(cbar_yticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
1418
+ cbar.set_yticklabels(cbar_yticklabels,
1419
+ fontsize=cbar_fontsize,
1420
+ family=cbar_font_family )
1409
1421
  cbar_xticklabels = cbar.get_xticklabels()
1410
- cbar.set_xticklabels(cbar_xticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
1422
+ cbar.set_xticklabels(cbar_xticklabels,
1423
+ fontsize=cbar_fontsize,
1424
+ family=cbar_font_family )
1411
1425
 
1412
- cbar.set_title(cbar_title, fontsize=cbar_fontsize, family=cbar_font_family, loc="center", y=1.00 )
1426
+ cbar.set_title(cbar_title, fontsize=cbar_fontsize,
1427
+ family=cbar_font_family,
1428
+ loc="center", y=1.00 )
1413
1429
  return cbar
1414
1430
 
1415
- def _process_xtick(ax1, chrom_df, xtick_chr_dict, fontsize, font_family, log=Log(),verbose=True):
1431
+ def _process_xtick(ax1, mode, chrom_df, xtick_chr_dict, fontsize, font_family="Arial", ax3=None , log=Log(),verbose=True):
1432
+
1416
1433
  log.write(" -Processing X ticks...",verbose=verbose)
1417
- ax1.set_xticks(chrom_df.astype("float64"))
1418
- ax1.set_xticklabels(chrom_df.index.astype("Int64").map(xtick_chr_dict),fontsize=fontsize,family=font_family)
1419
- return ax1
1434
+
1435
+ if mode!="r":
1436
+ ax1.set_xticks(chrom_df.astype("float64"))
1437
+ ax1.set_xticklabels(chrom_df.index.astype("Int64").map(xtick_chr_dict),
1438
+ fontsize=fontsize,
1439
+ family=font_family)
1440
+
1441
+ if ax3 is not None:
1442
+ ax3.tick_params(axis='x',
1443
+ labelsize=fontsize,
1444
+ labelfontfamily=font_family)
1445
+
1446
+ return ax1, ax3
1420
1447
 
1421
1448
  def _process_ytick(ax1, fontsize, font_family, ax4, log=Log(),verbose=True):
1422
1449
  log.write(" -Processing Y labels...",verbose=verbose)
1423
- #ax1_yticklabels = ax1.get_yticklabels()
1424
- #print(ax1_yticklabels)
1425
- #plt.draw()
1426
- #ax1_yticks = ax1.get_yticks()
1427
- #print(ax1_yticks)
1428
- #ax1.set_yticklabels(ax1_yticklabels,fontsize=fontsize,family=font_family)
1429
- ax1.tick_params(axis='y', labelsize=fontsize,labelfontfamily=font_family)
1430
- #ax1.set_yticks(ax1_yticks,ax1_yticklabels,fontsize=fontsize,family=font_family)
1450
+
1451
+ ax1.tick_params(axis='y',
1452
+ labelsize=fontsize,
1453
+ labelfontfamily=font_family)
1454
+
1431
1455
  if ax4 is not None:
1432
- #ax4_yticklabels = ax4.get_yticklabels()
1433
- #ax4_yticks = ax4.get_yticks()
1434
- ax4.tick_params(axis='y', labelsize=fontsize,labelfontfamily=font_family)
1435
- #ax4.set_yticks(ax4_yticks,ax4_yticklabels, fontsize=fontsize,family=font_family)
1456
+ ax4.tick_params(axis='y',
1457
+ labelsize=fontsize,
1458
+ labelfontfamily=font_family)
1436
1459
  return ax1, ax4
1437
1460
 
1438
- def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family, ax3=None , log=Log(),verbose=True):
1461
+ def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family="Arial", ax3=None , log=Log(),verbose=True):
1439
1462
  log.write(" -Processing X labels...",verbose=verbose)
1440
1463
  if region is not None:
1441
1464
  if xlabel is None:
@@ -1450,19 +1473,29 @@ def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family,
1450
1473
  ax1.set_xlabel(xlabel,fontsize=fontsize,family=font_family)
1451
1474
  return ax1, ax3
1452
1475
 
1453
- def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family, ax4=None, log=Log(),verbose=True):
1476
+ def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family, math_fontfamily, ax4=None, log=Log(),verbose=True):
1454
1477
  log.write(" -Processing Y labels...",verbose=verbose)
1455
1478
  if "b" in mode:
1456
1479
  if ylabel is None:
1457
1480
  ylabel ="Density of GWAS \n SNPs within "+str(bwindowsizekb)+" kb"
1458
- ax1.set_ylabel(ylabel,ha="center",va="bottom",fontsize=fontsize,family=font_family)
1481
+ ax1.set_ylabel(ylabel,ha="center",va="bottom",
1482
+ fontsize=fontsize,
1483
+ family=font_family,
1484
+ math_fontfamily=math_fontfamily)
1459
1485
  else:
1460
1486
  if ylabel is None:
1461
- ylabel ="$-log_{10}(P)$"
1462
- ax1.set_ylabel(ylabel,fontsize=fontsize,family=font_family)
1487
+ ylabel ="$\mathregular{-log_{10}(P)}$"
1488
+ ax1.set_ylabel(ylabel,
1489
+ fontsize=fontsize,
1490
+ family=font_family,
1491
+ math_fontfamily=math_fontfamily)
1492
+
1463
1493
  if ax4 is not None:
1464
1494
  ax4_ylabel = ax4.get_ylabel()
1465
- ax4.set_ylabel(ax4_ylabel, fontsize=fontsize, family=font_family )
1495
+ ax4.set_ylabel(ax4_ylabel,
1496
+ fontsize=fontsize,
1497
+ family=font_family,
1498
+ math_fontfamily=math_fontfamily )
1466
1499
  return ax1, ax4
1467
1500
 
1468
1501
  def _process_spine(ax1, mode):
@@ -1477,6 +1510,11 @@ def _process_spine(ax1, mode):
1477
1510
 
1478
1511
 
1479
1512
  def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
1513
+ #ax1 m / r
1514
+ #ax2 qq
1515
+ #ax3 gene track
1516
+ #ax4 recombination
1517
+
1480
1518
  if mode=="qqm":
1481
1519
  fig, (ax2, ax1) = plt.subplots(1, 2,gridspec_kw={'width_ratios': [1, mqqratio]},**fig_args)
1482
1520
  ax3 = None