gwaslab 3.4.41__py3-none-any.whl → 3.4.43__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/bd_common_data.py +14 -1
- gwaslab/bd_get_hapmap3.py +7 -3
- gwaslab/cache_manager.py +687 -0
- gwaslab/g_Sumstats.py +156 -138
- gwaslab/g_SumstatsPair.py +15 -15
- gwaslab/g_version.py +2 -2
- gwaslab/hm_harmonize_sumstats.py +558 -32
- gwaslab/io_read_tabular.py +7 -7
- gwaslab/io_to_formats.py +96 -21
- gwaslab/io_to_pickle.py +1 -1
- gwaslab/ldsc_ldscore.py +1 -1
- gwaslab/qc_fix_sumstats.py +4 -11
- gwaslab/util_ex_calculate_ldmatrix.py +2 -2
- gwaslab/util_ex_calculate_prs.py +2 -2
- gwaslab/util_ex_ldsc.py +163 -110
- gwaslab/util_ex_plink_filter.py +2 -2
- gwaslab/util_ex_run_clumping.py +2 -2
- gwaslab/util_in_filter_value.py +27 -9
- gwaslab/viz_plot_mqqplot.py +12 -11
- gwaslab/viz_plot_trumpetplot.py +115 -4
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/METADATA +8 -3
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/RECORD +26 -25
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/WHEEL +1 -1
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/LICENSE +0 -0
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/LICENSE_before_v3.4.39 +0 -0
- {gwaslab-3.4.41.dist-info → gwaslab-3.4.43.dist-info}/top_level.txt +0 -0
gwaslab/bd_common_data.py
CHANGED
|
@@ -298,9 +298,22 @@ def gtf_to_protein_coding(gtfpath,log=Log(),verbose=True):
|
|
|
298
298
|
|
|
299
299
|
return protein_coding_path
|
|
300
300
|
|
|
301
|
+
####################################################################################################################
|
|
302
|
+
# From BioPython: https://github.com/biopython/biopython/blob/c5a6b1374267d769b19c1022b4b45472316e78b4/Bio/Seq.py#L36
|
|
303
|
+
def _maketrans(complement_mapping):
|
|
304
|
+
"""Make a python string translation table.
|
|
305
|
+
|
|
306
|
+
Arguments:
|
|
307
|
+
- complement_mapping - a dictionary.
|
|
301
308
|
|
|
302
|
-
|
|
309
|
+
Returns a translation table (a bytes object of length 256) for use with
|
|
310
|
+
the python string's translate method.
|
|
303
311
|
|
|
312
|
+
Compatible with lower case and upper case sequences.
|
|
313
|
+
"""
|
|
314
|
+
keys = "".join(complement_mapping.keys()).encode("ASCII")
|
|
315
|
+
values = "".join(complement_mapping.values()).encode("ASCII")
|
|
316
|
+
return bytes.maketrans(keys + keys.lower(), values + values.lower())
|
|
304
317
|
|
|
305
318
|
####################################################################################################################
|
|
306
319
|
|
gwaslab/bd_get_hapmap3.py
CHANGED
|
@@ -12,7 +12,7 @@ from gwaslab.qc_fix_sumstats import finished
|
|
|
12
12
|
#A P-value
|
|
13
13
|
#A signed summary statistic (beta, OR, log odds, Z-score, etc)
|
|
14
14
|
|
|
15
|
-
def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",build="19", verbose=True, match_allele= True, log=Log()):
|
|
15
|
+
def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",build="19", verbose=True, match_allele= True, how="inner", log=Log()):
|
|
16
16
|
##start function with col checking##########################################################
|
|
17
17
|
_start_line = "extract HapMap3 SNPs"
|
|
18
18
|
_end_line = "extracting HapMap3 SNPs"
|
|
@@ -47,7 +47,7 @@ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",b
|
|
|
47
47
|
#rsid A1 A2 #CHROM POS
|
|
48
48
|
#rs3094315 G A 1 752566
|
|
49
49
|
|
|
50
|
-
if rsid in sumstats.columns:
|
|
50
|
+
if rsid in sumstats.columns and how=="inner":
|
|
51
51
|
output = sumstats.loc[sumstats[rsid].isin(hapmap3_ref["rsid"].values),:].copy()
|
|
52
52
|
return output
|
|
53
53
|
|
|
@@ -56,11 +56,15 @@ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",b
|
|
|
56
56
|
sumstats ["chr:pos"] = sumstats[chrom].astype("string")+":"+sumstats[pos].astype("string")
|
|
57
57
|
hapmap3_ref["chr:pos"] = hapmap3_ref["#CHROM"]+":"+hapmap3_ref["POS"]
|
|
58
58
|
hapmap3_ref = hapmap3_ref.rename(columns={"rsid":"rsID"})
|
|
59
|
-
output = pd.merge(sumstats,hapmap3_ref.loc[:,["chr:pos","rsID"]+additional_cols],left_on="chr:pos",right_on="chr:pos",how=
|
|
59
|
+
output = pd.merge(sumstats,hapmap3_ref.loc[:,["chr:pos","rsID"]+additional_cols],left_on="chr:pos",right_on="chr:pos",how=how,suffixes=('', '_hapmap3')).copy()
|
|
60
60
|
if match_allele:
|
|
61
61
|
log.write(" -Checking if alleles are same...")
|
|
62
62
|
is_matched = ((output[ea].astype("string") == output["A1"]) & (output[nea].astype("string") == output["A2"])) \
|
|
63
63
|
| ((output[ea].astype("string") == output["A2"]) & (output[nea].astype("string") == output["A1"]))
|
|
64
|
+
if how=="right":
|
|
65
|
+
is_matched = ((output[ea].astype("string") == output["A1"]) & (output[nea].astype("string") == output["A2"])) \
|
|
66
|
+
| ((output[ea].astype("string") == output["A2"]) & (output[nea].astype("string") == output["A1"])) | output[ea].isna()
|
|
67
|
+
|
|
64
68
|
log.write(" -Variants with macthed alleles: {}".format(sum(is_matched)))
|
|
65
69
|
output = output.loc[is_matched,:]
|
|
66
70
|
output = output.drop(columns=["chr:pos"]+additional_cols)
|