Skip to content

Commit

Permalink
Release 0.1.1 Minor updates / bug fixes + Adding containers
Browse files Browse the repository at this point in the history
  • Loading branch information
shz9 committed Apr 24, 2024
1 parent 98df100 commit 4487197
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 65 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.1] - 2024-04-24

### Changed

- Fixed bugs in the E-Step benchmarking script.
- Re-wrote the logic for finding BLAS libraries in the `setup.py` script. :crossed_fingers:

### Added

- `Dockerfile`s for both `cli` and `jupyter` modes.

## [0.1.0] - 2024-04-05

A large scale restructuring of the code base to improve efficiency and usability.
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/benchmark_e_step.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

"""
Benchmark the speed of the E-Step in VIPRS
----------------------------
Expand Down Expand Up @@ -214,9 +216,9 @@ def exec_func():
# ------------------------------------------------------------------------

# Create a grid:
grid = HyperparameterGrid()
grid = HyperparameterGrid(n_snps=gdl.n_snps)
# Generate a grid for pi using 5 equidistant grid points:
grid.generate_pi_grid(steps=args.grid_size, n_snps=gdl.n_snps)
grid.generate_pi_grid(steps=args.grid_size)
# Generate a grid for sigma epsilon using 5 equidistant grid points:
grid.generate_sigma_epsilon_grid(steps=args.grid_size)

Expand Down
2 changes: 1 addition & 1 deletion bin/viprs_evaluate
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if args.covariates_file is not None:
# Make sure that samples remain after reading both:
assert sample_table.n > 0, "No samples found after merging the covariates and phenotype files."

prs_df = pd.read_csv(args.prs_file, sep='\t')
prs_df = pd.read_csv(args.prs_file, sep=r'\s+')

# Merge the PRS data with the phenotype data:
prs_df = prs_df.merge(sample_table.get_individual_table(), on=['FID', 'IID'])
Expand Down
1 change: 1 addition & 0 deletions bin/viprs_fit
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Usage:

import os.path as osp


def check_args(args):
"""
Check the validity, consistency, and completeness of the commandline arguments.
Expand Down
1 change: 1 addition & 0 deletions bin/viprs_score
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ from magenpy.utils.system_utils import makedir, get_filenames
from magenpy.GWADataLoader import GWADataLoader
from viprs.model.BayesPRSModel import BayesPRSModel


print(fr"""
**********************************************
_____
Expand Down
43 changes: 43 additions & 0 deletions containers/cli.Dockerfile
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 viprs-cli .
# ** Step 2** Run the docker container in interactive shell mode:
# docker run -it viprs-cli /bin/bash
# ** Step 3** Test viprs fit:
# viprs_fit -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 VIPRS 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 viprs package from PyPI
RUN pip install --upgrade pip viprs

# Test the installation
RUN viprs_fit -h
53 changes: 53 additions & 0 deletions containers/jupyter.Dockerfile
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 viprs-jupyter .
# ** Step 2 ** Run the docker container (pass the appropriate port):
# docker run -p 8888:8888 viprs-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 VIPRS 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 viprs package from PyPI
RUN pip install --upgrade pip viprs jupyterlab

# Expose the port Jupyter Lab will be served on
EXPOSE 8888

# Set the working directory
WORKDIR /viprs_dir

# Copy the current directory contents into the container at /app
COPY . /viprs_dir

# Run Jupyter Lab
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--NotebookApp.token=''"]
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ summary statistics from `fastGWA`:
```python linenums="1"
# Load genotype and GWAS summary statistics data (chromosome 22):
gdl = mgp.GWADataLoader(bed_files=mgp.tgp_eur_data_path(), # Path of the genotype data
sumstats_files=mgp.ukb_height_fastGWA_path(), # Path of the summary statistics
sumstats_files=mgp.ukb_height_sumstats_path(), # Path of the summary statistics
sumstats_format="fastGWA") # Specify the format of the summary statistics
```

Expand Down
20 changes: 19 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ a new environment with the required dependencies as follows:

```bash
python_version=3.11 # Change python version here if needed
conda create --name "viprs_env" -c anaconda -c conda-forge python=$python_version compilers openblas -y
conda create --name "viprs_env" -c anaconda -c conda-forge python=$python_version compilers pkg-config openblas -y
conda activate viprs_env
```

Expand Down Expand Up @@ -68,3 +68,21 @@ source viprs_env/bin/activate
python -m pip install --upgrade pip
python -m pip install viprs>=0.1
```

### Using `Docker` containers

If you are using `Docker` containers, you can build a container with the `viprs` package
and all its dependencies by downloading the relevant `Dockerfile` from the
[repository](https://github.com/shz9/viprs/tree/master/containers) and building it
as follows:

```bash
# Build the docker image:
docker build -f cli.Dockerfile -t viprs-cli .
# Run the container in interactive mode:
docker run -it viprs-cli /bin/bash
# Test that the package installed successfully:
viprs_fit -h
```

We plan to publish pre-built `Docker` images on `DockerHub` in the future.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ requires = [
"extension-helpers",
"scipy",
"oldest-supported-numpy",
"pkgconfig"
]
build-backend = "setuptools.build_meta"

Expand Down
Loading

0 comments on commit 4487197

Please sign in to comment.