-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release
0.1.2
. Minor updates / bug fixes + Adding containers.
- Loading branch information
Showing
11 changed files
with
328 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Usage: | ||
# ** Step 1 ** Build the docker image: | ||
# docker build -f cli.Dockerfile -t magenpy-cli . | ||
# ** Step 2** Run the docker container in interactive shell mode: | ||
# docker run -it magenpy-cli /bin/bash | ||
# ** Step 3** Test magenpy_ld: | ||
# magenpy_ld -h | ||
|
||
FROM python:3.11-slim-buster | ||
|
||
LABEL authors="Shadi Zabad" | ||
LABEL version="0.1" | ||
LABEL description="Docker image containing all requirements to run the commandline scripts in the magenpy package" | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
unzip \ | ||
wget \ | ||
pkg-config \ | ||
g++ gcc \ | ||
libopenblas-dev \ | ||
libomp-dev | ||
|
||
# Download and setup plink2: | ||
RUN mkdir -p /software && \ | ||
wget https://s3.amazonaws.com/plink2-assets/alpha5/plink2_linux_avx2_20240105.zip -O /software/plink2.zip && \ | ||
unzip /software/plink2.zip -d /software && \ | ||
rm /software/plink2.zip | ||
|
||
# Download and setup plink1.9: | ||
RUN mkdir -p /software && \ | ||
wget https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20231211.zip -O /software/plink.zip && \ | ||
unzip /software/plink.zip -d /software && \ | ||
rm /software/plink.zip | ||
|
||
# Add plink1.9 and plink2 to PATH: | ||
RUN echo 'export PATH=$PATH:/software' >> ~/.bashrc | ||
|
||
# Install magenpy package from PyPI | ||
RUN pip install --upgrade pip magenpy | ||
|
||
# Test the installation | ||
RUN magenpy_ld -h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Usage: | ||
# ** Step 1 ** Build the docker image: | ||
# docker build -f ../vemPRS/containers/jupyter.Dockerfile -t magenpy-jupyter . | ||
# ** Step 2 ** Run the docker container (pass the appropriate port): | ||
# docker run -p 8888:8888 magenpy-jupyter | ||
# ** Step 3 ** Open the link in your browser: | ||
# http://localhost:8888 | ||
|
||
|
||
FROM python:3.11-slim-buster | ||
|
||
LABEL authors="Shadi Zabad" | ||
LABEL version="0.1" | ||
LABEL description="Docker image containing all requirements to run the magenpy package in a Jupyter Notebook" | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
unzip \ | ||
wget \ | ||
pkg-config \ | ||
g++ gcc \ | ||
libopenblas-dev \ | ||
libomp-dev | ||
|
||
# Download and setup plink2: | ||
RUN mkdir -p /software && \ | ||
wget https://s3.amazonaws.com/plink2-assets/alpha5/plink2_linux_avx2_20240105.zip -O /software/plink2.zip && \ | ||
unzip /software/plink2.zip -d /software && \ | ||
rm /software/plink2.zip | ||
|
||
# Download and setup plink1.9: | ||
RUN mkdir -p /software && \ | ||
wget https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20231211.zip -O /software/plink.zip && \ | ||
unzip /software/plink.zip -d /software && \ | ||
rm /software/plink.zip | ||
|
||
# Add plink1.9 and plink2 to PATH: | ||
RUN echo 'export PATH=$PATH:/software' >> ~/.bashrc | ||
|
||
# Install magenpy package from PyPI | ||
RUN pip install --upgrade pip magenpy jupyterlab | ||
|
||
# Expose the port Jupyter Lab will be served on | ||
EXPOSE 8888 | ||
|
||
# Set the working directory | ||
WORKDIR /magenpy_dir | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /magenpy_dir | ||
|
||
# Run Jupyter Lab | ||
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--NotebookApp.token=''"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
This is a utility script that converts the old-style published LD matrices (magenpy 0.0.X) to the new | ||
format deployed since magenpy>=0.1. The old LD matrix format used ragged Zarr arrays, while the new format | ||
uses flattened Zarr arrays that are more efficient and easier to work with. The script takes the path to the | ||
old LD matrices and converts them to the new format with the desired precision (e.g. float32). | ||
The user may also specify the compressor name and compression level for the new LD matrices. | ||
The script will validate the conversion by checking the integrity of the new LD matrices. | ||
Usage: | ||
python convert_old_ld_matrices.py --old-matrix-path /path/to/old/ld_matrices/chr_* \ | ||
--new-path /path/to/new/ld_matrices/ \ | ||
--dtype float32 | ||
""" | ||
|
||
import magenpy as mgp | ||
from magenpy.utils.system_utils import makedir | ||
import zarr | ||
import os.path as osp | ||
import glob | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser(description=""" | ||
Convert old-style LD matrices (magenpy 0.0.X) to the new format (magenpy >=0.1). | ||
""") | ||
|
||
parser.add_argument('--old-matrix-path', dest='old_path', type=str, required=True, | ||
help='The path to the old LD matrix. Can be a wild card of the form "path/to/chr_*"') | ||
parser.add_argument('--new-path', dest='new_path', type=str, required=True, | ||
help='The path where to store the new LD matrix.') | ||
parser.add_argument('--dtype', dest='dtype', type=str, default='int16', | ||
choices={'int8', 'int16', 'float32', 'float64'}, | ||
help='The desired data type for the entries of the new LD matrix.') | ||
parser.add_argument('--compressor', dest='compressor', type=str, default='zstd', | ||
help='The compressor name for the new LD matrix.') | ||
parser.add_argument('--compression-level', dest='compression_level', type=int, default=9, | ||
help='The compression level for the new LD matrix.') | ||
|
||
args = parser.parse_args() | ||
|
||
for f in glob.glob(args.old_path): | ||
|
||
try: | ||
z_arr = zarr.open(f, 'r') | ||
chrom = z_arr.attrs['Chromosome'] | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
continue | ||
|
||
print(f"> Converting LD matrix for chromosome: {chrom}") | ||
|
||
new_path_suffix = f'chr_{chrom}' | ||
if new_path_suffix not in args.new_path: | ||
new_path = osp.join(args.new_path, new_path_suffix) | ||
else: | ||
new_path = args.new_path | ||
|
||
makedir(new_path) | ||
|
||
ld_mat = mgp.LDMatrix.from_ragged_zarr_matrix(f, | ||
new_path, | ||
overwrite=True, | ||
dtype=args.dtype, | ||
compressor_name=args.compressor, | ||
compression_level=args.compression_level) | ||
print("Valid conversion:", ld_mat.validate_ld_matrix()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.