Skip to content

Commit

Permalink
fix the SyntaxWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganten-Hornby committed Dec 9, 2024
1 parent f98a45d commit 5dfe4cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
12 changes: 1 addition & 11 deletions src/gsMap/diagnosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from gsMap.config import DiagnosisConfig
from gsMap.utils.manhattan_plot import ManhattanPlot
from gsMap.visualize import draw_scatter, load_st_coord, estimate_point_size_for_plot
from gsMap.visualize import draw_scatter, load_st_coord, estimate_point_size_for_plot,load_ldsc


warnings.filterwarnings("ignore", category=FutureWarning)
Expand All @@ -23,16 +23,6 @@ def convert_z_to_p(gwas_data):
gwas_data['P'] = gwas_data['P'].clip(lower=min_p_value)
return gwas_data


def load_ldsc(ldsc_input_file):
"""Load LDSC data and calculate logp."""
ldsc = pd.read_csv(ldsc_input_file, compression='gzip')
ldsc['spot'] = ldsc['spot'].astype(str).replace('\.0', '', regex=True)
ldsc.set_index('spot', inplace=True)
ldsc['logp'] = -np.log10(ldsc['p'])
return ldsc


def load_gene_diagnostic_info(config:DiagnosisConfig):
"""Load or compute gene diagnostic info."""
gene_diagnostic_info_save_path = config.get_gene_diagnostic_info_save_path(config.trait_name)
Expand Down
2 changes: 1 addition & 1 deletion src/gsMap/utils/generate_r2_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def read(self, fname):
raise ValueError('{f} filename must end in {f}'.format(f=end))
comp = get_compression(fname)
self.df = pd.read_csv(fname, header=self.header, usecols=self.usecols,
sep='\s+', compression=comp)
sep=r'\s+', compression=comp)
if self.colnames:
self.df.columns = self.colnames
if self.keepcol is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/gsMap/utils/regression_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def read_csv(fh, **kwargs):
'''
Read the csv data
'''
return pd.read_csv(fh, sep='\s+', na_values='.', **kwargs)
return pd.read_csv(fh, sep=r'\s+', na_values='.', **kwargs)


# Fun for reading loading LD scores
Expand Down
10 changes: 7 additions & 3 deletions src/gsMap/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@


def load_ldsc(ldsc_input_file):
ldsc = pd.read_csv(ldsc_input_file, compression='gzip')
ldsc.spot = ldsc.spot.astype(str).replace('\.0', '', regex=True)
ldsc.index = ldsc.spot
ldsc = pd.read_csv(
ldsc_input_file,
compression='gzip',
dtype={'spot': str, 'p': float},
index_col='spot',
usecols=['spot', 'p']
)
ldsc['logp'] = -np.log10(ldsc.p)
return ldsc

Expand Down

0 comments on commit 5dfe4cf

Please sign in to comment.