Skip to content

Commit

Permalink
Small bug fixes in LDMatrix and system_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
shz9 committed Jun 10, 2024
1 parent 227d08c commit 45c9462
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ not work well for very large datasets with millions of variants and it causes ov
- Updated the way we determine the `pandas` chunksize when converting from `plink` tables to `zarr`.
- Simplified the way we compute the quantization scale in `model_utils`.
- Fixed major bug in how LD window thresholds that are passed to `plink1.9` are computed.
- Fixed in-place `fillna` in `from_plink_table` in `LDMatrix` to conform to latest `pandas` API.
- Update `run_shell_script` to check for and capture errors.

### Added

Expand Down
2 changes: 1 addition & 1 deletion magenpy/LDMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def from_plink_table(cls,
row_index = snp_idx[ld_chunk['SNP_A'].values]

# Fill N/A in R before storing it:
ld_chunk['R'].fillna(0., inplace=True)
ld_chunk.fillna({'R': 0.}, inplace=True)

# Add LD data to the zarr array:
if np.issubdtype(dtype, np.integer):
Expand Down
7 changes: 5 additions & 2 deletions magenpy/utils/system_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ def run_shell_script(cmd):
"""
Run the shell script given the command prompt in `cmd`.
:param cmd: A string with the shell command to run.
:return: The result of the shell command.
:raises: subprocess.CalledProcessError if the shell command fails.
"""

result = subprocess.run(cmd, shell=True, capture_output=True)
result = subprocess.run(cmd, shell=True, capture_output=True, check=True)

if result.stderr:
raise subprocess.CalledProcessError(
Expand All @@ -175,5 +178,5 @@ def delete_temp_files(prefix):
for f in glob.glob(f"{prefix}*"):
try:
os.remove(f)
except Exception:
except (OSError, FileNotFoundError):
continue

0 comments on commit 45c9462

Please sign in to comment.