gwaslab 3.6.8__py3-none-any.whl → 3.6.10__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.
- gwaslab/g_Log.py +13 -1
- gwaslab/g_Sumstats.py +11 -2
- gwaslab/g_version.py +2 -2
- gwaslab/util/util_ex_phewwas.py +44 -2
- gwaslab/util/util_in_calculate_power.py +19 -14
- gwaslab/viz/viz_aux_save_figure.py +2 -1
- gwaslab/viz/viz_plot_associations.py +61 -0
- gwaslab/viz/viz_plot_mqqplot.py +1 -1
- gwaslab/viz/viz_plot_template.py +98 -0
- gwaslab/viz/viz_plot_trumpetplot.py +45 -8
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/METADATA +1 -1
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/RECORD +16 -15
- gwaslab/hm_harmonize_sumstats.py +0 -1630
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/WHEEL +0 -0
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/licenses/LICENSE +0 -0
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/licenses/LICENSE_before_v3.4.39 +0 -0
- {gwaslab-3.6.8.dist-info → gwaslab-3.6.10.dist-info}/top_level.txt +0 -0
gwaslab/g_Log.py
CHANGED
|
@@ -31,4 +31,16 @@ class Log():
|
|
|
31
31
|
self.log_text = self.log_text + str(time.strftime('%Y/%m/%d %H:%M:%S')) + " " + " ".join(map(str,message)) + end
|
|
32
32
|
else:
|
|
33
33
|
if verbose: print(*message,end=end)
|
|
34
|
-
self.log_text = self.log_text + " ".join(map(str,message)) + end
|
|
34
|
+
self.log_text = self.log_text + " ".join(map(str,message)) + end
|
|
35
|
+
|
|
36
|
+
def get_log_for_last_operation(self):
|
|
37
|
+
last_log = []
|
|
38
|
+
rows = self.log_text.strip().split("\n")
|
|
39
|
+
|
|
40
|
+
# Iterate backwards to find the last operation
|
|
41
|
+
for line in reversed(rows):
|
|
42
|
+
last_log.append(line)
|
|
43
|
+
if "Start to" in line:
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
return "".join(reversed(last_log))
|
gwaslab/g_Sumstats.py
CHANGED
|
@@ -102,7 +102,7 @@ from gwaslab.viz.viz_plot_mqqplot import mqqplot
|
|
|
102
102
|
from gwaslab.viz.viz_plot_trumpetplot import plottrumpet
|
|
103
103
|
from gwaslab.viz.viz_plot_compare_af import plotdaf
|
|
104
104
|
from gwaslab.viz.viz_plot_credible_sets import _plot_cs
|
|
105
|
-
|
|
105
|
+
from gwaslab.viz.viz_plot_associations import _plot_associations
|
|
106
106
|
from gwaslab.io.io_read_pipcs import _read_pipcs
|
|
107
107
|
from gwaslab.io.io_load_ld import tofinemapping_using_ld
|
|
108
108
|
from gwaslab.io.io_preformat_input import preformat
|
|
@@ -112,6 +112,7 @@ from gwaslab.io.io_to_pickle import _reload
|
|
|
112
112
|
|
|
113
113
|
#20220309
|
|
114
114
|
class Sumstats():
|
|
115
|
+
|
|
115
116
|
def __init__(self,
|
|
116
117
|
sumstats=None,
|
|
117
118
|
fmt=None,
|
|
@@ -274,6 +275,10 @@ class Sumstats():
|
|
|
274
275
|
self.id = id(self)
|
|
275
276
|
self.tmp_path = _path(pid=self.id, log = self.log, verbose=verbose)
|
|
276
277
|
|
|
278
|
+
def __getitem__(self, index):
|
|
279
|
+
return self.data[index]
|
|
280
|
+
def __len__(self):
|
|
281
|
+
return len(self.data)
|
|
277
282
|
#### healper #################################################################################
|
|
278
283
|
def update_meta(self, **kwargs):
|
|
279
284
|
self.meta = _update_meta(self.meta, self.data,log = self.log, **kwargs)
|
|
@@ -695,7 +700,8 @@ class Sumstats():
|
|
|
695
700
|
return fig, outliers
|
|
696
701
|
|
|
697
702
|
def infer_ancestry(self, **kwargs):
|
|
698
|
-
self.meta["gwaslab"]["inferred_ancestry"] = _infer_ancestry(self.data,
|
|
703
|
+
self.meta["gwaslab"]["inferred_ancestry"] = _infer_ancestry(self.data, log=self.log,
|
|
704
|
+
**kwargs)
|
|
699
705
|
|
|
700
706
|
def plot_gwheatmap(self, **kwargs):
|
|
701
707
|
fig = _gwheatmap(self.data, **kwargs)
|
|
@@ -811,6 +817,9 @@ class Sumstats():
|
|
|
811
817
|
self.associations = associations_full
|
|
812
818
|
|
|
813
819
|
return associations_summary
|
|
820
|
+
def plot_associations(self,**kwargs):
|
|
821
|
+
|
|
822
|
+
_plot_associations(self.associations, **kwargs)
|
|
814
823
|
|
|
815
824
|
def check_cis(self, gls=False, **kwargs):
|
|
816
825
|
if "SNPID" in self.data.columns:
|
gwaslab/g_version.py
CHANGED
gwaslab/util/util_ex_phewwas.py
CHANGED
|
@@ -25,15 +25,19 @@ def _extract_associations(sumstats, rsid="rsID", log = Log(), verbose=True):
|
|
|
25
25
|
assoc_traits_agg = assoc_traits_agg.rename(columns={"trait":"GWASCATALOG_TRAIT",
|
|
26
26
|
"riskFrequency":"RAF",
|
|
27
27
|
"betaNum":"Beta",
|
|
28
|
-
"pvalue":"P-value"
|
|
28
|
+
"pvalue":"P-value",
|
|
29
|
+
"betaUnit":"Unit"
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
summary_columns=['GWASCATALOG_TRAIT','associationId', 'rsID', "geneName",
|
|
32
|
-
'RA', 'RAF','Beta', 'P-value','cohort','initialSampleSize','publicationInfo.pubmedId',
|
|
33
|
+
'RA', 'RAF','Beta',"Unit", 'P-value','cohort','initialSampleSize','publicationInfo.pubmedId',
|
|
33
34
|
"functionalClass","gene.geneName"]
|
|
34
35
|
|
|
35
36
|
assoc_traits_agg_summary = assoc_traits_agg[summary_columns]
|
|
36
37
|
|
|
38
|
+
assoc_traits_agg_summary = _align_beta(sumstats, assoc_traits_agg_summary, log, verbose)
|
|
39
|
+
assoc_traits_agg = _align_beta(sumstats, assoc_traits_agg, log, verbose)
|
|
40
|
+
|
|
37
41
|
return assoc_traits_agg, assoc_traits_agg_summary
|
|
38
42
|
|
|
39
43
|
def get_associations_from_gwascatalog(sumstats, rsid="rsID", log=Log(), verbose=True):
|
|
@@ -125,3 +129,41 @@ def parse_range(x):
|
|
|
125
129
|
low = np.log(range_list[0])
|
|
126
130
|
beta = (high + low)/2
|
|
127
131
|
return beta
|
|
132
|
+
|
|
133
|
+
def _align_beta(sumstats, assoc_traits_agg_summary, log, verbose):
|
|
134
|
+
# merge with sumstats
|
|
135
|
+
log.write("Merging GWAS Catalog associationms with Sumstats...",)
|
|
136
|
+
assoc_traits_agg_summary = pd.merge(sumstats[["rsID","CHR","POS","EA","NEA","BETA"]], assoc_traits_agg_summary, on = "rsID", how="inner")
|
|
137
|
+
# check direction
|
|
138
|
+
assoc_traits_agg_summary["GC_Beta_GL_RA"] = np.nan
|
|
139
|
+
assoc_traits_agg_summary["GC_Beta_GL_EA"] = np.nan
|
|
140
|
+
|
|
141
|
+
# get sumstats RA
|
|
142
|
+
assoc_traits_agg_summary["_GL_RA_BETA"] = assoc_traits_agg_summary["BETA"].abs()
|
|
143
|
+
assoc_traits_agg_summary["_GL_RA"] = assoc_traits_agg_summary["EA"]
|
|
144
|
+
assoc_traits_agg_summary["_GL_NRA"] = assoc_traits_agg_summary["NEA"]
|
|
145
|
+
is_GL_RA_flipped = assoc_traits_agg_summary["BETA"]<0
|
|
146
|
+
assoc_traits_agg_summary.loc[is_GL_RA_flipped, "_GL_RA"] = assoc_traits_agg_summary.loc[is_GL_RA_flipped, "NEA"]
|
|
147
|
+
assoc_traits_agg_summary.loc[is_GL_RA_flipped, "_GL_NRA"] = assoc_traits_agg_summary.loc[is_GL_RA_flipped, "EA"]
|
|
148
|
+
|
|
149
|
+
is_matched = assoc_traits_agg_summary["_GL_RA"] == assoc_traits_agg_summary["RA"]
|
|
150
|
+
log.write(" -GL_RA matched RA for {} variants ".format(sum(is_matched)), verbose=verbose)
|
|
151
|
+
assoc_traits_agg_summary.loc[is_matched, "GC_Beta_GL_RA"] = assoc_traits_agg_summary.loc[is_matched, "Beta"]
|
|
152
|
+
|
|
153
|
+
is_flipped = assoc_traits_agg_summary["_GL_NRA"] == assoc_traits_agg_summary["RA"]
|
|
154
|
+
log.write(" -GL_NRA matched RA for {} variants... Aligning with Sumstats Risk allele (BETA>0) in GC_Beta_GL_RA... ".format(sum(is_flipped)), verbose=verbose)
|
|
155
|
+
assoc_traits_agg_summary.loc[is_flipped, "GC_Beta_GL_RA"] = - assoc_traits_agg_summary.loc[is_flipped, "Beta"]
|
|
156
|
+
|
|
157
|
+
is_matched = assoc_traits_agg_summary["EA"] == assoc_traits_agg_summary["RA"]
|
|
158
|
+
log.write(" -EA matched RA for {} variants ".format(sum(is_matched)), verbose=verbose)
|
|
159
|
+
assoc_traits_agg_summary.loc[is_matched, "GC_Beta_GL_EA"] = assoc_traits_agg_summary.loc[is_matched, "Beta"]
|
|
160
|
+
|
|
161
|
+
is_flipped = assoc_traits_agg_summary["NEA"] == assoc_traits_agg_summary["RA"]
|
|
162
|
+
log.write(" -NEA matched RA for {} variants... Aligning with Sumstats Risk allele (BETA>0) in GC_Beta_GL_RA... ".format(sum(is_flipped)), verbose=verbose)
|
|
163
|
+
assoc_traits_agg_summary.loc[is_flipped, "GC_Beta_GL_EA"] = - assoc_traits_agg_summary.loc[is_flipped, "Beta"]
|
|
164
|
+
|
|
165
|
+
not_match = (assoc_traits_agg_summary["_GL_RA"] != assoc_traits_agg_summary["RA"])& (assoc_traits_agg_summary["_GL_NRA"] != assoc_traits_agg_summary["RA"])
|
|
166
|
+
log.write(" -NEA and EA not matching RA for {} variants... ".format(sum(not_match)), verbose=verbose)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
return assoc_traits_agg_summary
|
|
@@ -27,17 +27,19 @@ def get_power(
|
|
|
27
27
|
log.write(" -Number of cases:{}".format(ncase), verbose=verbose)
|
|
28
28
|
log.write(" -Number of controls:{}".format(ncontrol), verbose=verbose)
|
|
29
29
|
if genotype_rr is not None:
|
|
30
|
-
log.write(" -Risk allele RR:{
|
|
30
|
+
log.write(" -Risk allele RR:{}".format(genotype_rr), verbose=verbose)
|
|
31
31
|
elif genotype_or is not None:
|
|
32
|
-
log.write(" -Risk allele OR:{
|
|
32
|
+
log.write(" -Risk allele OR:{}".format(genotype_or), verbose=verbose)
|
|
33
33
|
elif beta is not None:
|
|
34
|
-
log.write(" -Risk allele beta:{
|
|
34
|
+
log.write(" -Risk allele beta:{}".format(beta), verbose=verbose)
|
|
35
35
|
else:
|
|
36
36
|
genotype_rr = 0.1
|
|
37
|
-
log.write(" -Risk allele RR:{
|
|
38
|
-
|
|
39
|
-
log.write(" -
|
|
40
|
-
log.write(" -
|
|
37
|
+
log.write(" -Risk allele RR:{}".format(genotype_rr), verbose=verbose)
|
|
38
|
+
|
|
39
|
+
log.write(" -Disease prevalence:{}".format(prevalence), verbose=verbose)
|
|
40
|
+
log.write(" -Risk allele frequency: {}".format(daf), verbose=verbose)
|
|
41
|
+
log.write(" -Significance level: {}".format(sig_level), verbose=verbose)
|
|
42
|
+
|
|
41
43
|
# Skol, A. D., Scott, L. J., Abecasis, G. R., & Boehnke, M. (2006). Joint analysis is more efficient than replication-based analysis for two-stage genome-wide association studies. Nature genetics, 38(2), 209-213.
|
|
42
44
|
aaf = daf**2
|
|
43
45
|
abf = 2 * (daf) * (1 - daf)
|
|
@@ -68,9 +70,9 @@ def get_power(
|
|
|
68
70
|
abp= x[1] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
69
71
|
bbp= x[2] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
70
72
|
log.write("Probability of disease :", verbose=verbose)
|
|
71
|
-
log.write(" - Individuals with AA genotype: {
|
|
72
|
-
log.write(" - Individuals with AB genotype: {
|
|
73
|
-
log.write(" - Individuals with BB genotype: {
|
|
73
|
+
log.write(" - Individuals with AA genotype: {}".format(aap), verbose=verbose)
|
|
74
|
+
log.write(" - Individuals with AB genotype: {}".format(abp), verbose=verbose)
|
|
75
|
+
log.write(" - Individuals with BB genotype: {}".format(bbp), verbose=verbose)
|
|
74
76
|
|
|
75
77
|
pcase= (aap * aaf + abp * abf*0.5) / prevalence
|
|
76
78
|
pcontrol=((1-aap )* aaf + (1-abp )* abf*0.5) / (1 - prevalence)
|
|
@@ -78,16 +80,19 @@ def get_power(
|
|
|
78
80
|
vcase = pcase *(1-pcase)
|
|
79
81
|
vcontrol =pcontrol *(1-pcontrol)
|
|
80
82
|
log.write("Expected risk allele frequency:", verbose=verbose)
|
|
81
|
-
log.write(" - In cases: {
|
|
82
|
-
log.write(" - In controls: {
|
|
83
|
+
log.write(" - In cases: {}".format(pcase), verbose=verbose)
|
|
84
|
+
log.write(" - In controls: {}".format(pcontrol), verbose=verbose)
|
|
83
85
|
|
|
84
86
|
num= (pcase - pcontrol)
|
|
85
|
-
|
|
87
|
+
for_sqrt = (vcase/ncase + vcontrol/ncontrol)*0.5
|
|
88
|
+
if np.iterable(for_sqrt):
|
|
89
|
+
for_sqrt[for_sqrt < 0] = np.nan
|
|
90
|
+
den= np.sqrt( for_sqrt )
|
|
86
91
|
u = num / den
|
|
87
92
|
|
|
88
93
|
c = ss.norm.isf(sig_level/2)
|
|
89
94
|
power = 1 - ss.norm.cdf(c-u) + ss.norm.cdf(-c-u)
|
|
90
|
-
log.write("Expected power: {
|
|
95
|
+
log.write("Expected power: {}".format(power), verbose=verbose)
|
|
91
96
|
|
|
92
97
|
elif mode=="q":
|
|
93
98
|
if beta is None:
|
|
@@ -53,7 +53,8 @@ def get_default_path(keyword,fmt="png"):
|
|
|
53
53
|
"afc":"allele_frequency_comparision",
|
|
54
54
|
"gwheatmap":"genome_wide_heatmap",
|
|
55
55
|
"scatter":"scatter",
|
|
56
|
-
"forest":"forest"
|
|
56
|
+
"forest":"forest",
|
|
57
|
+
"gwaslab":"gwaslab"
|
|
57
58
|
}
|
|
58
59
|
prefix = path_dictionary[keyword]
|
|
59
60
|
count = 1
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import seaborn as sns
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
from gwaslab.io.io_process_args import _update_args
|
|
4
|
+
from gwaslab.io.io_process_args import _update_arg
|
|
5
|
+
from gwaslab.g_Log import Log
|
|
6
|
+
|
|
7
|
+
def _plot_associations(associations,
|
|
8
|
+
values="Beta",
|
|
9
|
+
fig_args=None,
|
|
10
|
+
log=Log(),
|
|
11
|
+
verbose=True,
|
|
12
|
+
sort="P-value",
|
|
13
|
+
fontsize=12,
|
|
14
|
+
font_family="Arial",
|
|
15
|
+
cmap=None,
|
|
16
|
+
ylabel="Traits",
|
|
17
|
+
xlabel="rsID - Gene Name",
|
|
18
|
+
**args
|
|
19
|
+
):
|
|
20
|
+
|
|
21
|
+
log.write("Start to create heatmap for associations...", verbose=verbose)
|
|
22
|
+
|
|
23
|
+
cmap = _update_arg(cmap, "RdBu")
|
|
24
|
+
|
|
25
|
+
log.write(f" -Value to plot: {values}", verbose=verbose)
|
|
26
|
+
log.write(f" -Total number of associations :{len(associations)} ", verbose=verbose)
|
|
27
|
+
log.write(f" -Sorting associations by :{sort} ", verbose=verbose)
|
|
28
|
+
|
|
29
|
+
associations = associations.sort_values(by=[sort]).drop_duplicates(subset=["rsID","GWASCATALOG_TRAIT"])
|
|
30
|
+
|
|
31
|
+
log.write(f" -Keeping unique rsID-traits pairs :{len(associations)} ", verbose=verbose)
|
|
32
|
+
|
|
33
|
+
associations = associations.dropna(subset=[values])
|
|
34
|
+
log.write(f" -Keeping associations without NA in {values} :{len(associations)} ", verbose=verbose)
|
|
35
|
+
|
|
36
|
+
log.write(f" -Total number of unique variants for plotting :{associations['rsID'].nunique()} ", verbose=verbose)
|
|
37
|
+
log.write(f" -Total number of unique traits for plotting:{associations['GWASCATALOG_TRAIT'].nunique()} ", verbose=verbose)
|
|
38
|
+
|
|
39
|
+
matrix_beta = associations.pivot_table(index=['rsID','gene.geneName'],
|
|
40
|
+
columns='GWASCATALOG_TRAIT',
|
|
41
|
+
values=[values])
|
|
42
|
+
|
|
43
|
+
matrix_beta = matrix_beta.astype("float64")
|
|
44
|
+
|
|
45
|
+
matrix_beta.columns = matrix_beta.columns.droplevel(0)
|
|
46
|
+
|
|
47
|
+
height = max(2, len(matrix_beta)//2)
|
|
48
|
+
width = max(2, len(matrix_beta.columns)//2)
|
|
49
|
+
|
|
50
|
+
fig_args = _update_args(fig_args, dict(figsize=(width,height)))
|
|
51
|
+
fig,ax = plt.subplots(**fig_args)
|
|
52
|
+
|
|
53
|
+
sns.heatmap(matrix_beta.T, annot=True, fmt=".2f",cmap="RdBu",ax=ax)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
ax.set_xlabel(xlabel,fontsize=fontsize, fontfamily=font_family)
|
|
57
|
+
ax.set_ylabel(ylabel,fontsize=fontsize, fontfamily=font_family)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
log.write("Finished creating heatmap for associations.", verbose=verbose)
|
|
61
|
+
return fig, ax
|
gwaslab/viz/viz_plot_mqqplot.py
CHANGED
|
@@ -296,7 +296,7 @@ def mqqplot(insumstats,
|
|
|
296
296
|
region_ref.append(region_ref_second)
|
|
297
297
|
region_ref_index_dic = {value: index for index,value in enumerate(region_ref)}
|
|
298
298
|
|
|
299
|
-
taf =
|
|
299
|
+
taf = _update_arg(taf, [track_n,track_n_offset,track_fontsize_ratio,track_exon_ratio,track_text_offset])
|
|
300
300
|
region_marker_shapes = _update_arg(region_marker_shapes, ['o', '^','s','D','*','P','X','h','8'])
|
|
301
301
|
region_grid_line = _update_args(region_grid_line, {"linewidth": 2,"linestyle":"--"})
|
|
302
302
|
region_lead_grid_line = _update_args(region_lead_grid_line, {"alpha":0.5,"linewidth" : 2,"linestyle":"--","color":"#FF0000"})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import seaborn as sns
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
from gwaslab.io.io_process_args import _update_args
|
|
4
|
+
from gwaslab.io.io_process_args import _update_arg
|
|
5
|
+
from gwaslab.g_Log import Log
|
|
6
|
+
from gwaslab.viz.viz_aux_save_figure import save_figure
|
|
7
|
+
|
|
8
|
+
def _plot( associations,
|
|
9
|
+
values="Beta",
|
|
10
|
+
sort="P-value",
|
|
11
|
+
mode="gwaslab",
|
|
12
|
+
fontsize=12,
|
|
13
|
+
font_family="Arial",
|
|
14
|
+
cmap=None,
|
|
15
|
+
ylabel="Y",
|
|
16
|
+
xlabel="X",
|
|
17
|
+
xlim=None,
|
|
18
|
+
ylim=None,
|
|
19
|
+
yticks=None,
|
|
20
|
+
xticks=None,
|
|
21
|
+
title="Title",
|
|
22
|
+
title_pad=1.08,
|
|
23
|
+
title_fontsize=13,
|
|
24
|
+
linewidth=None,
|
|
25
|
+
linestyle=None,
|
|
26
|
+
linecolor=None,
|
|
27
|
+
dpi=200,
|
|
28
|
+
fig_args= None,
|
|
29
|
+
scatter_args=None,
|
|
30
|
+
save=None,
|
|
31
|
+
save_args=None,
|
|
32
|
+
log=Log(),
|
|
33
|
+
verbose=True,
|
|
34
|
+
**args
|
|
35
|
+
):
|
|
36
|
+
|
|
37
|
+
# update args
|
|
38
|
+
|
|
39
|
+
cmap = _update_arg(cmap, "RdBu")
|
|
40
|
+
|
|
41
|
+
fig_args = _update_args(fig_args, dict(figsize=(10,10)))
|
|
42
|
+
|
|
43
|
+
# create fig and ax
|
|
44
|
+
fig,ax = plt.subplots(**fig_args)
|
|
45
|
+
|
|
46
|
+
# draw lines
|
|
47
|
+
horizontal_line = ax.axhline(y=1, linewidth = linewidth,
|
|
48
|
+
linestyle="--",
|
|
49
|
+
color=linecolor,zorder=1000)
|
|
50
|
+
vertical_line = ax.axvline(x=1, linewidth = linewidth,
|
|
51
|
+
linestyle="--",
|
|
52
|
+
color=linecolor,zorder=1000)
|
|
53
|
+
|
|
54
|
+
# ticks
|
|
55
|
+
if xticks is not None:
|
|
56
|
+
ax.set_xticks(xticks)
|
|
57
|
+
ax.set_xticklabels(xticks,
|
|
58
|
+
fontsize=fontsize,
|
|
59
|
+
family=font_family)
|
|
60
|
+
|
|
61
|
+
if yticks is not None:
|
|
62
|
+
ax.set_xticks(yticks)
|
|
63
|
+
ax.set_xticklabels(yticks,
|
|
64
|
+
fontsize=fontsize,
|
|
65
|
+
family=font_family)
|
|
66
|
+
|
|
67
|
+
# labels
|
|
68
|
+
ax.set_xlabel(xlabel,
|
|
69
|
+
fontsize=fontsize,
|
|
70
|
+
fontfamily=font_family)
|
|
71
|
+
ax.set_ylabel(ylabel,
|
|
72
|
+
fontsize=fontsize,
|
|
73
|
+
fontfamily=font_family)
|
|
74
|
+
|
|
75
|
+
ax.tick_params(axis='x',
|
|
76
|
+
labelsize=fontsize,
|
|
77
|
+
labelfontfamily=font_family)
|
|
78
|
+
ax.tick_params(axis='y',
|
|
79
|
+
labelsize=fontsize,
|
|
80
|
+
labelfontfamily=font_family)
|
|
81
|
+
|
|
82
|
+
# title
|
|
83
|
+
title_pad = title_pad -0.05
|
|
84
|
+
fig.suptitle(title ,
|
|
85
|
+
fontsize = title_fontsize,
|
|
86
|
+
x=0.5,
|
|
87
|
+
y=title_pad)
|
|
88
|
+
|
|
89
|
+
# spines
|
|
90
|
+
ax.spines["top"].set_visible(False)
|
|
91
|
+
ax.spines["right"].set_visible(False)
|
|
92
|
+
ax.spines["left"].set_visible(True)
|
|
93
|
+
ax.spines["bottom"].set_visible(True)
|
|
94
|
+
|
|
95
|
+
save_figure(fig = fig, save = save, keyword=mode, save_args=save_args, log = log, verbose=verbose)
|
|
96
|
+
|
|
97
|
+
log.write("Finished creating plots.", verbose=verbose)
|
|
98
|
+
return fig, ax
|
|
@@ -170,10 +170,11 @@ def plottrumpet(mysumstats,
|
|
|
170
170
|
cols_to_use.append(chrom) if chrom not in cols_to_use else cols_to_use
|
|
171
171
|
|
|
172
172
|
if size != "ABS_BETA":
|
|
173
|
-
if size not in cols_to_use:
|
|
173
|
+
if size is not None and size not in cols_to_use:
|
|
174
174
|
cols_to_use.append(size)
|
|
175
175
|
if "hue" in scatter_args.keys():
|
|
176
|
-
|
|
176
|
+
if scatter_args["hue"] not in cols_to_use:
|
|
177
|
+
cols_to_use.append(scatter_args["hue"])
|
|
177
178
|
#filter by p #################################################################################################################
|
|
178
179
|
if p in mysumstats.columns:
|
|
179
180
|
sumstats = mysumstats.loc[mysumstats[p]< p_level,cols_to_use ].copy()
|
|
@@ -287,7 +288,10 @@ def plottrumpet(mysumstats,
|
|
|
287
288
|
sumstats["ABS_BETA"] = sumstats[beta].abs()
|
|
288
289
|
|
|
289
290
|
##################################################################################################
|
|
290
|
-
|
|
291
|
+
if size is None:
|
|
292
|
+
size_norm = None
|
|
293
|
+
else:
|
|
294
|
+
size_norm = (sumstats[size].min(), sumstats[size].max())
|
|
291
295
|
## if highlight ##################################################################################################
|
|
292
296
|
|
|
293
297
|
log.write(" -Creating scatter plot...", verbose=verbose)
|
|
@@ -389,15 +393,30 @@ def plottrumpet(mysumstats,
|
|
|
389
393
|
|
|
390
394
|
#second_legend = ax.legend(title="Power", loc="upper right",fontsize =fontsize,title_fontsize=fontsize)
|
|
391
395
|
log.write(" -Creating legends...")
|
|
396
|
+
# curve, size, hue
|
|
392
397
|
h,l = ax.get_legend_handles_labels()
|
|
398
|
+
|
|
393
399
|
if len(ts)>0:
|
|
400
|
+
# power curves
|
|
394
401
|
l1 = ax.legend(h[:int(len(ts))],l[:int(len(ts))], title="Power", loc="upper right",fontsize =fontsize,title_fontsize=fontsize)
|
|
395
402
|
for line in l1.get_lines():
|
|
396
403
|
line.set_linewidth(5.0)
|
|
397
|
-
|
|
398
|
-
|
|
404
|
+
## hue
|
|
405
|
+
if hue is not None or size is not None:
|
|
406
|
+
# # sizes
|
|
407
|
+
if hue is None and size is not None:
|
|
408
|
+
hue_size_legend_title = size
|
|
409
|
+
elif hue is not None and size is None:
|
|
410
|
+
hue_size_legend_title = hue
|
|
411
|
+
else:
|
|
412
|
+
hue_size_legend_title = None
|
|
413
|
+
l2 = ax.legend(h[int(len(ts)):],l[int(len(ts)):], title=hue_size_legend_title, loc="lower right",fontsize =fontsize,title_fontsize=fontsize)
|
|
414
|
+
|
|
415
|
+
## hue
|
|
399
416
|
if len(ts)>0:
|
|
400
417
|
ax.add_artist(l1)
|
|
418
|
+
if hue is not None or size is not None:
|
|
419
|
+
ax.add_artist(l2)
|
|
401
420
|
#first_legend = ax.legend(handles=dots, loc="lower right" ,title=size,fontsize =fontsize,title_fontsize=fontsize)
|
|
402
421
|
#ax.add_artist(first_legend)
|
|
403
422
|
##################################################################################################
|
|
@@ -780,17 +799,31 @@ def plot_power_x(
|
|
|
780
799
|
log=Log()):
|
|
781
800
|
|
|
782
801
|
#Checking columns#################################################################################################################
|
|
802
|
+
"""
|
|
803
|
+
Create power cure with user-specified x axis
|
|
804
|
+
q mode:
|
|
805
|
+
N
|
|
806
|
+
MAF
|
|
807
|
+
b mode:
|
|
808
|
+
N_CASE
|
|
809
|
+
N_CONTROL
|
|
810
|
+
PREVALENCE
|
|
811
|
+
BETA
|
|
812
|
+
"""
|
|
813
|
+
|
|
783
814
|
log.write("Start to create power plot...", verbose=verbose)
|
|
784
815
|
matplotlib.rc('font', family=font_family)
|
|
785
816
|
|
|
786
817
|
log.write(" -Settings:", verbose=verbose)
|
|
787
818
|
log.write(" -Mode: {}".format(mode), verbose=verbose)
|
|
819
|
+
|
|
788
820
|
if mode == "q" :
|
|
789
821
|
log.write(" -X axis: {}".format(x), verbose=verbose)
|
|
790
822
|
if x!="N":
|
|
791
823
|
log.write(" -N: {}".format(ns), verbose=verbose)
|
|
792
824
|
if x!="MAF":
|
|
793
825
|
log.write(" -MAF: {}".format(mafs), verbose=verbose)
|
|
826
|
+
|
|
794
827
|
if mode == "b" :
|
|
795
828
|
log.write(" -X axis: {}".format(x), verbose=verbose)
|
|
796
829
|
if x!="N_CASE":
|
|
@@ -846,8 +879,11 @@ def plot_power_x(
|
|
|
846
879
|
prevalence_range = np.linspace(0.01,0.99,n_matrix)
|
|
847
880
|
else:
|
|
848
881
|
prevalence_range = np.linspace(prevalence_range[0],prevalence_range[1],n_matrix)
|
|
849
|
-
#configure power threshold###################################################################################################
|
|
850
882
|
|
|
883
|
+
|
|
884
|
+
#configure power threshold###################################################################################################
|
|
885
|
+
# for hue
|
|
886
|
+
# which is the variable
|
|
851
887
|
if type(ns) is list:
|
|
852
888
|
var_to_change = ns
|
|
853
889
|
legend_title = "N"
|
|
@@ -895,12 +931,13 @@ def plot_power_x(
|
|
|
895
931
|
##creating power line############################################################################################
|
|
896
932
|
if mode=="q":
|
|
897
933
|
for i,value in enumerate(var_to_change):
|
|
898
|
-
|
|
934
|
+
# iterate through variables
|
|
899
935
|
n = ns
|
|
900
936
|
beta = betas
|
|
901
937
|
maf = mafs
|
|
902
938
|
sig_level = sig_levels
|
|
903
939
|
|
|
940
|
+
# update the variable
|
|
904
941
|
if legend_title == "BETA":
|
|
905
942
|
beta = value
|
|
906
943
|
elif legend_title == "MAF":
|
|
@@ -910,7 +947,7 @@ def plot_power_x(
|
|
|
910
947
|
elif legend_title == "Significance level":
|
|
911
948
|
sig_level = value
|
|
912
949
|
|
|
913
|
-
|
|
950
|
+
# update X
|
|
914
951
|
if x == "N":
|
|
915
952
|
x_values = n_range
|
|
916
953
|
n = x_values
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
gwaslab/__init__.py,sha256=tr8AGz-BqvOc5V0aUHNC-xW--LIAiUXrFo8HTR4SI9k,2861
|
|
2
2
|
gwaslab/cache_manager.py,sha256=HOTnSkCOyGEPLRl90WT8D_6pAdI8d8AzenMIDGuCeWc,28113
|
|
3
|
-
gwaslab/g_Log.py,sha256=
|
|
3
|
+
gwaslab/g_Log.py,sha256=gIZm2TG5ktW6Vpbg0daCrZevk6u_pmbZa_5jg-GhWSc,1914
|
|
4
4
|
gwaslab/g_Phenotypes.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
gwaslab/g_Sumstats.py,sha256=
|
|
5
|
+
gwaslab/g_Sumstats.py,sha256=w01312c5_fHMhs6cCFpQ78yXw5Rh6sRAQdvOnInuHg4,45735
|
|
6
6
|
gwaslab/g_SumstatsMulti.py,sha256=CDnYMK0L8bV-LNOwO4h9yJahOVHR-sPAxZMNaeKFb3U,15098
|
|
7
7
|
gwaslab/g_SumstatsPair.py,sha256=3-4aFh6pMZ4phcqHCCfyFPC3ySuck43wuTsfLG-ZAyY,13470
|
|
8
8
|
gwaslab/g_SumstatsSet.py,sha256=xuGLpsHyhY2SjMVsFHGdL3iCa-Leb_3bu_R8totkzBY,30180
|
|
@@ -14,8 +14,7 @@ gwaslab/g_meta.py,sha256=pXtSsQfFPv2UJmOxKMmLtcsp_Ku_H73YP7PnlfMd0sg,6472
|
|
|
14
14
|
gwaslab/g_meta_update.py,sha256=W1m6mh5jNUeZAW4T6F6kKZ10gE4l8YieoEC2mAfkzGg,2495
|
|
15
15
|
gwaslab/g_vchange_status.py,sha256=lc3G65-QBV5k5yK-ySGIxiUT0hMBmESLhMKYncwjSwU,1986
|
|
16
16
|
gwaslab/g_vchange_status_polars.py,sha256=kxyGQCur0ibVFBCyZghA-XNf_kLDXKK-l7VC-Om2IdA,1839
|
|
17
|
-
gwaslab/g_version.py,sha256=
|
|
18
|
-
gwaslab/hm_harmonize_sumstats.py,sha256=WkUGNxftEGF5NAJktbEqQfniwcoD6zWHd-4bGrBxOtM,84472
|
|
17
|
+
gwaslab/g_version.py,sha256=5CD7sWiCBN8MbBjnZvVpzZgVcUwOWQF64aXsu0VEgFU,1965
|
|
19
18
|
gwaslab/run_script.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
19
|
gwaslab/bd/bd_common_data.py,sha256=mlw977K-ihKf7TQEn6FwUCyJ2vcnq6KIhrX6J3bRMVA,14226
|
|
21
20
|
gwaslab/bd/bd_config.py,sha256=t3YeDMGRSP8k3lw4rHHilIM4jAXSzFOF9DtuuIbpDS8,924
|
|
@@ -65,7 +64,7 @@ gwaslab/util/util_ex_infer_ancestry.py,sha256=AXLEhuJUBT6XIYjADB-envFRGIZ-misneg
|
|
|
65
64
|
gwaslab/util/util_ex_ldproxyfinder.py,sha256=8E4g82gCmolAvrg52urNMJX11MZMwOAPGQaZ4cfggiU,16918
|
|
66
65
|
gwaslab/util/util_ex_ldsc.py,sha256=ss1QlwH7duLuVx_Ckb9mDbyz2neK8tv0WefUGCqzZUc,21685
|
|
67
66
|
gwaslab/util/util_ex_match_ldmatrix.py,sha256=uVfHKxWQRtUQ0lUkt1o2LtZPSd3fh1yQ1rElFa4FDao,17525
|
|
68
|
-
gwaslab/util/util_ex_phewwas.py,sha256=
|
|
67
|
+
gwaslab/util/util_ex_phewwas.py,sha256=oLbAgh_ULLWNP0m6bmD9xtx3EdDcH3HSIeTjxHX_0HU,8745
|
|
69
68
|
gwaslab/util/util_ex_plink_filter.py,sha256=pK1Yxtv9-J4rMOdVAG7VU9PktvI6-y4FxBiVEH0QuRs,1673
|
|
70
69
|
gwaslab/util/util_ex_process_h5.py,sha256=LqfQKBjXnbPSRUVJy9hhRhuoS5wG93yoIguiFDZN1A4,2837
|
|
71
70
|
gwaslab/util/util_ex_process_ref.py,sha256=qtDRxJT0O2NgW4fd6VkRMxIHhSdzhSwz6bfa4iLQvcc,17132
|
|
@@ -81,7 +80,7 @@ gwaslab/util/util_ex_run_prscs.py,sha256=DJu-tIX6gQcdsZFcqESNM2NN0gO5vfhGBzwOgHO
|
|
|
81
80
|
gwaslab/util/util_ex_run_scdrs.py,sha256=Oxjx5eTyfAXqv0-V2GrYJrm-loYaHJ_zY0U4Ictb3tk,3135
|
|
82
81
|
gwaslab/util/util_ex_run_susie.py,sha256=Wp7aH8xSQb4mWmvMSYIEsBUInNwZhkxoxEbjY51PEl4,6847
|
|
83
82
|
gwaslab/util/util_in_calculate_gc.py,sha256=MWOXVzJv7SZx4i2_ncRiqsiEOADc7EfghaUzgGy4jaE,2219
|
|
84
|
-
gwaslab/util/util_in_calculate_power.py,sha256=
|
|
83
|
+
gwaslab/util/util_in_calculate_power.py,sha256=iF7VPKhOyS-fCvO9kf94voqOUMvoIEFUYOTC49x4SZU,10424
|
|
85
84
|
gwaslab/util/util_in_convert_h2.py,sha256=a8Cbudt3xn9WP2bPc-7ysuowB-LYub8j8GeDXl7Lk7Q,6483
|
|
86
85
|
gwaslab/util/util_in_correct_winnerscurse.py,sha256=Gp--yAQ8MMzdkWIvXP9C1BHVjZc-YzqHfYWhAj19w9w,2110
|
|
87
86
|
gwaslab/util/util_in_estimate_ess.py,sha256=QDOQ5vXfHtVkUEqX-TscsC831-FMTtGXXiHo1YxSFzU,1009
|
|
@@ -98,7 +97,8 @@ gwaslab/viz/viz_aux_chromatin.py,sha256=aWZaXOSvGyZY7wQcoFDaqHRYCSHZbi_K4Q70HruN
|
|
|
98
97
|
gwaslab/viz/viz_aux_property.py,sha256=UIaivghnLXYpTwkKnXRK0F28Jbn9L6OaICk3K73WZaU,33
|
|
99
98
|
gwaslab/viz/viz_aux_quickfix.py,sha256=6xgJYHBEz6iTRkuIAS1e28PQJH1eIViBCOMvczxI-BQ,18698
|
|
100
99
|
gwaslab/viz/viz_aux_reposition_text.py,sha256=iRIP-Rkltlei068HekJcVubiqPrunBqvAoSQ1eHk04M,4304
|
|
101
|
-
gwaslab/viz/viz_aux_save_figure.py,sha256=
|
|
100
|
+
gwaslab/viz/viz_aux_save_figure.py,sha256=IOhojOCPPUDjZZYw7i4BgzCpAeasNpnzBTyrpiSoH_4,2856
|
|
101
|
+
gwaslab/viz/viz_plot_associations.py,sha256=0hdepohuQOLft5nI2GVFLz-2Q0jUsLiJPTemkH7bNJI,2472
|
|
102
102
|
gwaslab/viz/viz_plot_compare_af.py,sha256=pnL6pEQOSXZ1Zm2UTX-TdvTYSFD9zSY2vaJZSo4Ry_w,5348
|
|
103
103
|
gwaslab/viz/viz_plot_compare_effect.py,sha256=KF0Ug4OwVwfl205Z5nRqGwXBLceuwJXYXj6378sT1Sg,69629
|
|
104
104
|
gwaslab/viz/viz_plot_credible_sets.py,sha256=CjTtO5Dk2R-_GpZ0KN2NW0bN-EDga1OCjt9U8zDiTcw,5864
|
|
@@ -106,7 +106,7 @@ gwaslab/viz/viz_plot_effect.py,sha256=quWnT_WwERt61s0iVpnznQWgw8a5S3LeVkMuWNi6iE
|
|
|
106
106
|
gwaslab/viz/viz_plot_forestplot.py,sha256=xgOnefh737CgdQxu5naVyRNBX1NQXPFKzf51fbh6afs,6771
|
|
107
107
|
gwaslab/viz/viz_plot_miamiplot.py,sha256=nzPqP8HD2RElrFFP0OtnsYoAEjVpkfcvkRZNul6pJPg,31318
|
|
108
108
|
gwaslab/viz/viz_plot_miamiplot2.py,sha256=7Ixar822FLGEe8Jo2y54cOfcBC_AxQnwvbM7qth_Juw,18100
|
|
109
|
-
gwaslab/viz/viz_plot_mqqplot.py,sha256=
|
|
109
|
+
gwaslab/viz/viz_plot_mqqplot.py,sha256=qAi7eVAHTqkZk6AQAEW1yPBrSpIsEkD9mQ-O4zhwzzU,74160
|
|
110
110
|
gwaslab/viz/viz_plot_phe_heatmap.py,sha256=wUv3x7x2kyQWUfIrRiyxlAwILHbg3L4V-tMMvji8VQI,9589
|
|
111
111
|
gwaslab/viz/viz_plot_qqplot.py,sha256=XVRabkCKrAV83I-bbdMt5Hh0wkZEyZPiq-Wxtiq7azs,6619
|
|
112
112
|
gwaslab/viz/viz_plot_regional2.py,sha256=p-A1N-18ENo0FSwTW6rJlCacEeHJFW7dVwuQ91Ozv-8,43160
|
|
@@ -114,10 +114,11 @@ gwaslab/viz/viz_plot_regionalplot.py,sha256=UZSeXHfQlGWAYW_tMt00lZt8_vhiB6QcVLvM
|
|
|
114
114
|
gwaslab/viz/viz_plot_rg_heatmap.py,sha256=AvVAlOOAwhqGWCses7MfdIXLVQSIA2SFE6bd7K1NaLw,13865
|
|
115
115
|
gwaslab/viz/viz_plot_scatter_with_reg.py,sha256=0cpE6ui7yuJ1lhoLu_klac2OSzd5QDx6V51fyplB3GI,8366
|
|
116
116
|
gwaslab/viz/viz_plot_stackedregional.py,sha256=bgVQir_Wj3TxB3o7NJFf7b8HETlWjppgfwLsbUyr3oo,20668
|
|
117
|
-
gwaslab/viz/
|
|
118
|
-
gwaslab
|
|
119
|
-
gwaslab-3.6.
|
|
120
|
-
gwaslab-3.6.
|
|
121
|
-
gwaslab-3.6.
|
|
122
|
-
gwaslab-3.6.
|
|
123
|
-
gwaslab-3.6.
|
|
117
|
+
gwaslab/viz/viz_plot_template.py,sha256=3tOT4pWcxN8je6XEcqPTQ7PJXEG25cwXUnDnoIhqjMA,2917
|
|
118
|
+
gwaslab/viz/viz_plot_trumpetplot.py,sha256=BwQ22RdBEefLBdQU6H9eoYioZicjhFCvCARncXa_Jww,43862
|
|
119
|
+
gwaslab-3.6.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
120
|
+
gwaslab-3.6.10.dist-info/licenses/LICENSE_before_v3.4.39,sha256=GhLOU_1UDEKeOacYhsRN_m9u-eIuVTazSndZPeNcTZA,1066
|
|
121
|
+
gwaslab-3.6.10.dist-info/METADATA,sha256=-3PRSVGLmsptQANloRqgg0zQESyteNHkhibxqRvudlI,7074
|
|
122
|
+
gwaslab-3.6.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
123
|
+
gwaslab-3.6.10.dist-info/top_level.txt,sha256=PyY6hWtrALpv2MAN3kjkIAzJNmmBTH5a2risz9KwH08,8
|
|
124
|
+
gwaslab-3.6.10.dist-info/RECORD,,
|