gwaslab 3.4.15__tar.gz → 3.4.16__tar.gz
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-3.4.15/src/gwaslab.egg-info → gwaslab-3.4.16}/PKG-INFO +2 -2
- {gwaslab-3.4.15 → gwaslab-3.4.16}/README.md +1 -1
- {gwaslab-3.4.15 → gwaslab-3.4.16}/pyproject.toml +1 -1
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/__init__.py +3 -1
- gwaslab-3.4.16/src/gwaslab/calculate_power.py +124 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/mqqplot.py +1 -1
- gwaslab-3.4.16/src/gwaslab/trumpetplot.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16/src/gwaslab.egg-info}/PKG-INFO +2 -2
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab.egg-info/SOURCES.txt +1 -0
- gwaslab-3.4.15/src/gwaslab/calculate_power.py +0 -47
- {gwaslab-3.4.15 → gwaslab-3.4.16}/LICENSE +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/setup.cfg +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/CommonData.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/Log.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/Phenotypes.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/Sumstats.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/Sumstatssummary.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/annotategenename.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/annotateplot.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/calculate_gc.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/compare_effect.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/config.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/chrx_par/chrx_par_hg19.bed.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/chrx_par/chrx_par_hg38.bed.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/formatbook.json +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/high_ld/high_ld_hla_hg19.bed.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/high_ld/high_ld_hla_hg38.bed.gz +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/reference.json +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/download.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/fill.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/filtervalue.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/fixdata.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/get_hapmap3.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/getdensity.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/getsig.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/gwascatalog.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/h2_conversion.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/meta.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/metaanalysis.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/miamiplot.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/plotrg.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/preformat_input.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/processdata.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/qqplot.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/quickfix.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/read_ldsc.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/regionalplot.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/retrievedata.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/rsID2chrpos.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/textreposition.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/to_formats.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/to_pickle.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/vchangestatus.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/version.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/winnerscurse.py +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab.egg-info/dependency_links.txt +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab.egg-info/requires.txt +0 -0
- {gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gwaslab
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.16
|
|
4
4
|
Summary: A collection of handy tools for GWAS SumStats
|
|
5
5
|
Author-email: Yunye <yunye@gwaslab.com>
|
|
6
6
|
Project-URL: Homepage, https://cloufield.github.io/gwaslab/
|
|
@@ -32,7 +32,7 @@ Note: GWASLab is being updated very frequently for now. I will release the first
|
|
|
32
32
|
## Install
|
|
33
33
|
|
|
34
34
|
```
|
|
35
|
-
pip install gwaslab==3.4.
|
|
35
|
+
pip install gwaslab==3.4.15
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
|
|
@@ -32,4 +32,6 @@ from gwaslab.download import update_record
|
|
|
32
32
|
from gwaslab.to_pickle import dump_pickle
|
|
33
33
|
from gwaslab.to_pickle import load_pickle
|
|
34
34
|
from gwaslab.config import options
|
|
35
|
-
from gwaslab.version import _show_version as show_version
|
|
35
|
+
from gwaslab.version import _show_version as show_version
|
|
36
|
+
from gwaslab.calculate_power import get_power
|
|
37
|
+
from gwaslab.calculate_power import get_beta
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
import scipy.stats as ss
|
|
4
|
+
from gwaslab.Log import Log
|
|
5
|
+
import scipy as sp
|
|
6
|
+
|
|
7
|
+
def get_power(
|
|
8
|
+
mode="b",
|
|
9
|
+
t=0,
|
|
10
|
+
genotype_or=1.3 ,
|
|
11
|
+
beta=0.3,
|
|
12
|
+
eaf=0.1,
|
|
13
|
+
n=10000,
|
|
14
|
+
scase= 2000,
|
|
15
|
+
scontrol= 15000,
|
|
16
|
+
prevalence= 0.15,
|
|
17
|
+
daf = 0.2,
|
|
18
|
+
sig_level= 5e-8,
|
|
19
|
+
vary=1,
|
|
20
|
+
log=Log(),
|
|
21
|
+
verbose=True
|
|
22
|
+
):
|
|
23
|
+
if mode=="b":
|
|
24
|
+
print("Input settings:{}".format(daf))
|
|
25
|
+
print(" -Number of cases:{}".format(scase))
|
|
26
|
+
print(" -Number of controls:{}".format(scontrol))
|
|
27
|
+
print(" -Risk allele OR:{:.3f}".format(genotype_or))
|
|
28
|
+
print(" -Disease prevalence:{:.3f}".format(prevalence))
|
|
29
|
+
print(" -Risk allele frequency: {:.3f}".format(daf))
|
|
30
|
+
print(" -Significance level: {:.3e}".format(sig_level))
|
|
31
|
+
# 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.
|
|
32
|
+
aaf = daf**2
|
|
33
|
+
abf = 2 * (daf) * (1 - daf)
|
|
34
|
+
bbf = (1- daf)**2
|
|
35
|
+
|
|
36
|
+
# additive
|
|
37
|
+
x = [ 2*genotype_or-1, genotype_or, 1 ]
|
|
38
|
+
|
|
39
|
+
aap= x[0] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
40
|
+
abp= x[1] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
41
|
+
bbp= x[2] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
42
|
+
print("Probability of disease :")
|
|
43
|
+
print(" - Individuals with AA genotype: {:.3f}".format(aap))
|
|
44
|
+
print(" - Individuals with AB genotype: {:.3f}".format(abp))
|
|
45
|
+
print(" - Individuals with BB genotype: {:.3f}".format(bbp))
|
|
46
|
+
|
|
47
|
+
pcase= (aap * aaf + abp * abf*0.5) / prevalence
|
|
48
|
+
pcontrol=((1-aap )* aaf + (1-abp )* abf*0.5) / (1 - prevalence)
|
|
49
|
+
|
|
50
|
+
vcase = pcase *(1-pcase)
|
|
51
|
+
vcontrol =pcontrol *(1-pcontrol)
|
|
52
|
+
print("Expected risk allele frequency:")
|
|
53
|
+
print(" - In cases: {:.3f}".format(pcase))
|
|
54
|
+
print(" - In controls: {:.3f}".format(pcontrol))
|
|
55
|
+
|
|
56
|
+
num= (pcase - pcontrol)
|
|
57
|
+
den= np.sqrt( (vcase/scase + vcontrol/scontrol)*0.5 )
|
|
58
|
+
u = num / den
|
|
59
|
+
|
|
60
|
+
c = ss.norm.isf(sig_level/2)
|
|
61
|
+
power = 1 - ss.norm.cdf(c-u) + ss.norm.cdf(-c-u)
|
|
62
|
+
print("Expected power: {:.3f}".format(power))
|
|
63
|
+
|
|
64
|
+
elif mode=="q":
|
|
65
|
+
if verbose:
|
|
66
|
+
log.write("Significance level: {}".format(sig_level))
|
|
67
|
+
log.write("EAF: {}".format(eaf))
|
|
68
|
+
log.write("BETA: {}".format(beta))
|
|
69
|
+
log.write("N: {}".format(n))
|
|
70
|
+
log.write("H2: {}".format(2*eaf*(1-eaf)*(beta**2)))
|
|
71
|
+
c = ss.chi2.isf(sig_level/2,df=1)
|
|
72
|
+
NCP = n * 2*eaf*(1-eaf)*(beta**2)/vary
|
|
73
|
+
power = 1 - ss.ncx2.cdf(c,df=1,nc=NCP)
|
|
74
|
+
|
|
75
|
+
return power
|
|
76
|
+
|
|
77
|
+
def get_beta(
|
|
78
|
+
mode="b",
|
|
79
|
+
t=0,
|
|
80
|
+
genotype_or=1.3 ,
|
|
81
|
+
eaf=0.1,
|
|
82
|
+
n=10000,
|
|
83
|
+
scase= 2000,
|
|
84
|
+
scontrol= 15000,
|
|
85
|
+
prevalence= 0.15,
|
|
86
|
+
daf = 0.2,
|
|
87
|
+
sig_level= 5e-8,
|
|
88
|
+
vary=1,
|
|
89
|
+
log=Log(),
|
|
90
|
+
verbose=True,
|
|
91
|
+
n_matrix=500
|
|
92
|
+
):
|
|
93
|
+
if mode=="q":
|
|
94
|
+
if t >0:
|
|
95
|
+
def calculate_power_single(
|
|
96
|
+
beta,
|
|
97
|
+
eaf,
|
|
98
|
+
n,
|
|
99
|
+
t,
|
|
100
|
+
sig_level=5e-8,vary=1):
|
|
101
|
+
|
|
102
|
+
c = ss.chi2.isf(sig_level/2,df=1)
|
|
103
|
+
h2 = 2*eaf*(1-eaf)*(beta**2)
|
|
104
|
+
NCP = n * h2/vary
|
|
105
|
+
power = 1 - ss.ncx2.cdf(c,df=1,nc=NCP)
|
|
106
|
+
return power
|
|
107
|
+
|
|
108
|
+
matrix = np.zeros((n_matrix,n_matrix),dtype=float)
|
|
109
|
+
eafs = np.linspace(0.5,0.0001,n_matrix)
|
|
110
|
+
betas = np.linspace(0.0001,10,n_matrix)
|
|
111
|
+
|
|
112
|
+
for i in range(n_matrix):
|
|
113
|
+
matrix[i,] = calculate_power_single(beta=betas,eaf=eafs[i],n=n,t=t)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
i,j=1,1
|
|
117
|
+
eaf_beta = []
|
|
118
|
+
while i<n_matrix-1 and j<n_matrix-1:
|
|
119
|
+
if matrix[i,j] < t:
|
|
120
|
+
j+=1
|
|
121
|
+
else:
|
|
122
|
+
i+=1
|
|
123
|
+
eaf_beta.append((eafs[i],betas[j]))
|
|
124
|
+
return pd.DataFrame(eaf_beta)
|
|
@@ -322,7 +322,7 @@ def mqqplot(insumstats,
|
|
|
322
322
|
|
|
323
323
|
# CHR and POS ########################################################################
|
|
324
324
|
# chrom and pos exists && (m || r mode)
|
|
325
|
-
if (chrom is not None) and (pos is not None) and (("m" in mode) or ("r" in mode)):
|
|
325
|
+
if (chrom is not None) and (pos is not None) and (("qq" in mode) or ("m" in mode) or ("r" in mode)):
|
|
326
326
|
# when manhattan plot, chrom and pos is needed.
|
|
327
327
|
if chrom in insumstats.columns:
|
|
328
328
|
usecols.append(chrom)
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gwaslab
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.16
|
|
4
4
|
Summary: A collection of handy tools for GWAS SumStats
|
|
5
5
|
Author-email: Yunye <yunye@gwaslab.com>
|
|
6
6
|
Project-URL: Homepage, https://cloufield.github.io/gwaslab/
|
|
@@ -32,7 +32,7 @@ Note: GWASLab is being updated very frequently for now. I will release the first
|
|
|
32
32
|
## Install
|
|
33
33
|
|
|
34
34
|
```
|
|
35
|
-
pip install gwaslab==3.4.
|
|
35
|
+
pip install gwaslab==3.4.15
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
def get_power(genotype_or=1.3 ,
|
|
2
|
-
scase= 2000,
|
|
3
|
-
scontrol= 15000,
|
|
4
|
-
prevalence= 0.15,
|
|
5
|
-
daf = 0.2,
|
|
6
|
-
sig_level= 5e-8
|
|
7
|
-
):
|
|
8
|
-
print("Input settings:{}".format(daf))
|
|
9
|
-
print(" -Number of cases:{}".format(scase))
|
|
10
|
-
print(" -Number of controls:{}".format(scontrol))
|
|
11
|
-
print(" -Risk allele OR:{:.3f}".format(genotype_or))
|
|
12
|
-
print(" -Disease prevalence:{:.3f}".format(prevalence))
|
|
13
|
-
print(" -Risk allele frequency: {:.3f}".format(daf))
|
|
14
|
-
print(" -Significance level: {:.3e}".format(sig_level))
|
|
15
|
-
# 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.
|
|
16
|
-
aaf = daf**2
|
|
17
|
-
abf = 2 * (daf) * (1 - daf)
|
|
18
|
-
bbf = (1- daf)**2
|
|
19
|
-
|
|
20
|
-
# additive
|
|
21
|
-
x = [ 2*genotype_or-1, genotype_or, 1 ]
|
|
22
|
-
|
|
23
|
-
aap= x[0] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
24
|
-
abp= x[1] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
25
|
-
bbp= x[2] * prevalence / (x[0]*aaf + x[1]*abf + x[2]*bbf)
|
|
26
|
-
print("Probability of disease :")
|
|
27
|
-
print(" - Individuals with AA genotype: {:.3f}".format(aap))
|
|
28
|
-
print(" - Individuals with AB genotype: {:.3f}".format(abp))
|
|
29
|
-
print(" - Individuals with BB genotype: {:.3f}".format(bbp))
|
|
30
|
-
|
|
31
|
-
pcase= (aap * aaf + abp * abf*0.5) / prevalence
|
|
32
|
-
pcontrol=((1-aap )* aaf + (1-abp )* abf*0.5) / (1 - prevalence)
|
|
33
|
-
|
|
34
|
-
vcase = pcase *(1-pcase)
|
|
35
|
-
vcontrol =pcontrol *(1-pcontrol)
|
|
36
|
-
print("Expected risk allele frequency:")
|
|
37
|
-
print(" - In cases: {:.3f}".format(pcase))
|
|
38
|
-
print(" - In controls: {:.3f}".format(pcontrol))
|
|
39
|
-
|
|
40
|
-
num= (pcase - pcontrol)
|
|
41
|
-
den= np.sqrt( (vcase/scase + vcontrol/scontrol)*0.5 )
|
|
42
|
-
u = num / den
|
|
43
|
-
|
|
44
|
-
c = ss.norm.isf(sig_level/2)
|
|
45
|
-
power = 1 - ss.norm.cdf(c-u) + ss.norm.cdf(-c-u)
|
|
46
|
-
print("Expected power: {:.3f}".format(power))
|
|
47
|
-
return power
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz
RENAMED
|
File without changes
|
{gwaslab-3.4.15 → gwaslab-3.4.16}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|