From e7fde0e329df93a08466da126db1dc54b781437b Mon Sep 17 00:00:00 2001
From: hjulienn <hanna.julienne@pasteur.fr>
Date: Thu, 5 Jan 2023 12:58:17 +0100
Subject: [PATCH] Maintenance: removed deprecated numpy types

---
 jass_preprocessing/__main__.py      | 7 +++----
 jass_preprocessing/compute_score.py | 2 +-
 jass_preprocessing/map_reference.py | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/jass_preprocessing/__main__.py b/jass_preprocessing/__main__.py
index 9ef13c5..d9ceda6 100644
--- a/jass_preprocessing/__main__.py
+++ b/jass_preprocessing/__main__.py
@@ -5,6 +5,7 @@ Write clean GWAS datasets by chromosome
 __updated__ = '2022-03-02'
 
 import pandas as pd
+import numpy as np
 import jass_preprocessing as jp
 import time
 import argparse
@@ -40,7 +41,6 @@ def launch_preprocessing(args):
     gwas_map.set_index("tag", inplace=True)
     print(gwas_map)
     for tag in gwas_map.index:
-
         gwas_filename = gwas_map.loc[tag, "filename"]
 
         print('processing GWAS: {}'.format(tag))
@@ -56,13 +56,13 @@ def launch_preprocessing(args):
             gw_df = jp.map_gwas.read_gwas(GWAS_link, mapgw)
 
         print("#SNPs in GWAS summary statistic file: {}".format(gw_df.shape[0]))
-        ref = jp.map_reference.read_reference(args.ref_path, bool(args.mask_MHC), float(args.minimum_MAF), region_to_mask=eval(args.additional_masked_region))
+        ref = jp.map_reference.read_reference(args.ref_path, np.bool_(args.mask_MHC), np.double(args.minimum_MAF), region_to_mask=eval(args.additional_masked_region))
         mgwas = jp.map_reference.map_on_ref_panel(gw_df, ref, gwas_map.loc[tag, "index_type"])
 
         print("#SNPs mapped to reference panel: {}".format(mgwas.shape[0]))
         mgwas = jp.map_reference.compute_snp_alignement(mgwas)
         mgwas = jp.compute_score.compute_z_score(mgwas)
-        mgwas = jp.compute_score.compute_sample_size(mgwas, args.diagnostic_folder, tag, float(args.percent_sample_size))
+        mgwas = jp.compute_score.compute_sample_size(mgwas, args.diagnostic_folder, tag, np.double(args.percent_sample_size))
         end = time.time()
 
         print("#SNPs remaining after sample size filter: {}".format(mgwas.shape[0]))
@@ -91,7 +91,6 @@ def add_preprocessing_argument():
     parser.add_argument('--additional-masked-region', required=False, help= "List of dictionary containing coordinate of region to mask. For example :[{'chr':6, 'start':50000000, 'end': 70000000}, {'chr':6, 'start':100000000, 'end': 120000000}]", default='None')
 
     parser.add_argument('--imputation-quality-treshold', required=False, help= "minimum imputation quality in summary statistics", default='None')
-
     parser.set_defaults(func=launch_preprocessing)
 
     return parser
diff --git a/jass_preprocessing/compute_score.py b/jass_preprocessing/compute_score.py
index fd176a3..349be38 100644
--- a/jass_preprocessing/compute_score.py
+++ b/jass_preprocessing/compute_score.py
@@ -51,7 +51,7 @@ def compute_sample_size(mgwas, diagnostic_folder, trait, perSS = 0.7):
         warnings.warn("Some snp had an infinite sample size")
 
     myW_thres = np.percentile(myN.dropna(), 90)
-    ss_thres = float(perSS) * myW_thres
+    ss_thres = np.double(perSS) * myW_thres
     mgwas["computed_N"] = myN
     plt.clf()
     p1 = sns.distplot(mgwas.computed_N[~mgwas.computed_N.isna()])
diff --git a/jass_preprocessing/map_reference.py b/jass_preprocessing/map_reference.py
index 2b676aa..65550fd 100644
--- a/jass_preprocessing/map_reference.py
+++ b/jass_preprocessing/map_reference.py
@@ -21,7 +21,7 @@ def read_reference(gwas_reference_panel, mask_MHC=False, minimum_MAF=None, regio
     """
     ref = pd.read_csv(gwas_reference_panel, header=None, sep= "\t",
                       names =[ 'chr', "snp_id", "MAF","pos",  "ref", "alt"],
-                      dtype = {"chr": str, "snp_id":str, "MAF": np.float, "pos":np.int, "ref":str, "alt":str},
+                      dtype = {"chr": str, "snp_id":str, "MAF": np.double, "pos":np.int64, "ref":str, "alt":str},
                        index_col="snp_id")
 
     def sorted_alleles(x):
-- 
GitLab