Skip to content

Commit

Permalink
deleted format function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianhua-Wang committed Mar 22, 2023
1 parent f4d70ef commit ff62587
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 326 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.2.2] - 2023-03-22

### Added


### Changed
- deleted format function


### Fixed


## [0.2.1] - 2023-01-10

### Added
Expand Down
44 changes: 22 additions & 22 deletions easyfinemap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,28 @@ def validate_ldref(
ld.valid(ldref_path, outprefix, file_type, mac, threads)


@app.command()
def validate_sumstats(
sumstats_path: Path = typer.Argument(..., help="The path to the GWAS summary statistics file."),
output: Path = typer.Argument(..., help="The output prefix."),
) -> None:
"""Validate the GWAS summary statistics file."""
if sumstats_path.exists():
sumstats = pd.read_csv(sumstats_path, sep="\t")
typer.echo(f"Loaded {sumstats_path} successfully.")
typer.echo(f"Number of SNPs: {sumstats.shape[0]}")
typer.echo(f"Number of columns: {sumstats.shape[1]}")
typer.echo(f"Columns: {list(sumstats.columns)}")
valid_sumstats = SumStat(sumstats)
valid_sumstats = valid_sumstats.standarize()
if output.suffix == ".gz":
valid_sumstats.to_csv(output, sep="\t", index=False, compression="gzip")
else:
valid_sumstats.to_csv(output, sep="\t", index=False)
typer.echo(f"Saved the validated summary statistics to {output}.")
else:
logging.error(f"No such file of {sumstats_path}.")
sys.exit(1)
# @app.command()
# def validate_sumstats(
# sumstats_path: Path = typer.Argument(..., help="The path to the GWAS summary statistics file."),
# output: Path = typer.Argument(..., help="The output prefix."),
# ) -> None:
# """Validate the GWAS summary statistics file."""
# if sumstats_path.exists():
# sumstats = pd.read_csv(sumstats_path, sep="\t")
# typer.echo(f"Loaded {sumstats_path} successfully.")
# typer.echo(f"Number of SNPs: {sumstats.shape[0]}")
# typer.echo(f"Number of columns: {sumstats.shape[1]}")
# typer.echo(f"Columns: {list(sumstats.columns)}")
# valid_sumstats = SumStat(sumstats)
# valid_sumstats = valid_sumstats.standarize()
# if output.suffix == ".gz":
# valid_sumstats.to_csv(output, sep="\t", index=False, compression="gzip")
# else:
# valid_sumstats.to_csv(output, sep="\t", index=False)
# typer.echo(f"Saved the validated summary statistics to {output}.")
# else:
# logging.error(f"No such file of {sumstats_path}.")
# sys.exit(1)


@app.command()
Expand Down
5 changes: 2 additions & 3 deletions easyfinemap/easyfinemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from easyfinemap.ldref import LDRef
from easyfinemap.sumstat import SumStat
from easyfinemap.tools import Tools
from easyfinemap.utils import io_in_tempdir
from easyfinemap.utils import io_in_tempdir, make_SNPID_unique


class EasyFinemap(object):
Expand Down Expand Up @@ -581,8 +581,7 @@ def finemap_all_loci(
threads : int, optional
Number of threads, by default 1
"""
sumstats = SumStat(sumstats)
sumstats = sumstats.standarize()
sumstats = make_SNPID_unique(sumstats)
if credible_threshold and credible_method is None and methods != ["all"] and len(methods) == 1:
credible_method = methods[0]
kwargs_list = []
Expand Down
5 changes: 2 additions & 3 deletions easyfinemap/loci.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from easyfinemap.ldref import LDRef
from easyfinemap.sumstat import SumStat
from easyfinemap.tools import Tools
from easyfinemap.utils import get_significant_snps, io_in_tempdir
from easyfinemap.utils import get_significant_snps, io_in_tempdir, make_SNPID_unique


class Loci:
Expand Down Expand Up @@ -101,8 +101,7 @@ def identify_indep_loci(
Tuple[pd.DataFrame, pd.DataFrame]
The independent lead snps and independent loci.
"""
sumstats = SumStat(sumstats)
sumstats = sumstats.standarize()
sumstats = make_SNPID_unique(sumstats)
if method == "distance":
sig_df = get_significant_snps(sumstats, sig_threshold)
lead_snp = self.indep_snps_by_distance(sig_df, distance)
Expand Down
Loading

0 comments on commit ff62587

Please sign in to comment.