HUB
Sign inSign up

psychemistz/sigdiscovpy

By psychemistz

•Updated 8 months ago

spatial signature discovery in python

Image
0

5.1K

psychemistz/sigdiscovpy repository overview

⁠Docker Usage Guide

This guide explains how to use sigdiscovPy with Docker, including CPU, GPU, and R-enabled versions.

⁠Quick Start

⁠Pull Pre-built Images
# CPU version (Python only) - recommended for most users
docker pull psychemistz/sigdiscovpy:latest

# GPU version (Python + CuPy)
docker pull psychemistz/sigdiscovpy:gpu

# CPU + R version (Python + sigdiscov R package)
docker pull psychemistz/sigdiscovpy:with-r

# GPU + R version (full stack)
docker pull psychemistz/sigdiscovpy:gpu-with-r
⁠Build Images Locally
# CPU version (default, Python only ~5 min)
docker build -t sigdiscovpy:latest .

# GPU version (Python + CuPy ~10 min)
docker build -t sigdiscovpy:gpu --build-arg USE_GPU=true .

# CPU + R version (Python + R packages ~30-60 min)
docker build -t sigdiscovpy:with-r --build-arg INSTALL_R=true .

# GPU + R version (full stack ~40-90 min)
docker build -t sigdiscovpy:gpu-with-r --build-arg USE_GPU=true --build-arg INSTALL_R=true .
⁠Build Arguments
ArgumentDefaultDescription
USE_GPUfalseSet to true for GPU/CUDA support
INSTALL_RfalseSet to true to include R and sigdiscov package

⁠Available Docker Images

TagPythonGPURSizeUse Case
latest / cpuyesnono~2 GBGeneral use
gpuyesyesno~6 GBGPU acceleration
with-r / cpu-with-ryesnoyes~3.5 GBR cross-validation
gpu-with-ryesyesyes~8 GBFull stack

⁠R Packages Included

When building with INSTALL_R=true, the following packages are installed. CRAN packages are fetched as pre-compiled binaries from the Posit Public Package Manager⁠ for faster builds.

⁠From CRAN (pre-compiled binaries)

Core (sigdiscov dependencies):

  • Matrix, Rcpp, RcppArmadillo (required by sigdiscov)
  • ggplot2, sctransform (suggested by sigdiscov)
  • testthat, data.table
  • remotes, BiocManager, devtools

Optional:

  • Seurat, hdf5r (for Seurat/HDF5 workflows)
⁠From Bioconductor (BiocManager::install())
  • rhdf5 (HDF5 I/O for cross-validation with Python)
⁠From GitHub (remotes::install_github())
  • sigdiscov: psychemistz/sigdiscov - Spatial signature discovery R package

⁠Running Containers

⁠Interactive Mode
# CPU
docker run -it --rm -v $(pwd):/workspace psychemistz/sigdiscovpy:latest

# GPU
docker run -it --rm --gpus all -v $(pwd):/workspace psychemistz/sigdiscovpy:gpu

# CPU + R (for cross-validation)
docker run -it --rm -v $(pwd):/workspace psychemistz/sigdiscovpy:with-r
⁠Run Scripts
# Python script
docker run --rm -v $(pwd):/workspace psychemistz/sigdiscovpy:latest python your_script.py

# R script
docker run --rm -v $(pwd):/workspace psychemistz/sigdiscovpy:with-r Rscript your_script.R

⁠Using Docker Compose

Docker Compose simplifies container management:

# Start CPU container
docker-compose up -d sigdiscovpy

# Start GPU container
docker-compose up -d sigdiscovpy-gpu

# Start CPU + R container
docker-compose up -d sigdiscovpy-r

# Enter a running container
docker-compose exec sigdiscovpy bash

# Stop all containers
docker-compose down
⁠Available Services
ServiceGPURPortDescription
sigdiscovpynono-CPU interactive
sigdiscovpy-gpuyesno-GPU interactive
sigdiscovpy-rnoyes-CPU + R interactive
sigdiscovpy-gpu-ryesyes-GPU + R interactive
sigdiscovpy-jupyternono8888Jupyter Lab (CPU)
sigdiscovpy-jupyter-gpuyesno8889Jupyter Lab (GPU)
sigdiscovpy-jupyter-rnoyes8890Jupyter Lab (CPU + R)
⁠Jupyter Lab
# Start Jupyter (CPU)
docker-compose up sigdiscovpy-jupyter
# Open http://localhost:8888

# Start Jupyter (GPU)
docker-compose up sigdiscovpy-jupyter-gpu
# Open http://localhost:8889

# Start Jupyter (CPU + R)
docker-compose up sigdiscovpy-jupyter-r
# Open http://localhost:8890

⁠Validation Examples

⁠Verify Python Installation
docker run --rm psychemistz/sigdiscovpy:latest python -c "
import sigdiscovpy
print(f'sigdiscovPy {sigdiscovpy.__version__}')
print(f'GPU available: {sigdiscovpy.GPU_AVAILABLE}')
"
⁠Verify R Installation
docker run --rm psychemistz/sigdiscovpy:with-r Rscript -e "
cat('R version:', R.version.string, '\n')

# Check packages
for (pkg in c('sigdiscov', 'Matrix', 'Rcpp', 'RcppArmadillo')) {
    if (require(pkg, quietly = TRUE, character.only = TRUE)) {
        cat(pkg, 'OK -', as.character(packageVersion(pkg)), '\n')
    } else {
        cat(pkg, 'NOT FOUND\n')
    }
}
"
⁠Cross-Validation (R vs Python)
# Enter container with R
docker run -it --rm -v $(pwd):/workspace psychemistz/sigdiscovpy:with-r

# Inside container - Run R computation
Rscript -e "
library(sigdiscov)
# ... your R analysis code
"

# Run Python computation
python -c "
import sigdiscovpy
# ... your Python analysis code
"

⁠GPU Support

⁠Prerequisites
  1. NVIDIA GPU with CUDA support
  2. NVIDIA Container Toolkit⁠
⁠Installation (Ubuntu)
# Add NVIDIA repository
distribution=\$(. /etc/os-release;echo \$ID\$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/\$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list

# Install
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit

# Restart Docker
sudo systemctl restart docker
⁠Verify GPU Access
# Check GPU is accessible
docker run --rm --gpus all psychemistz/sigdiscovpy:gpu nvidia-smi

# Check CuPy
docker run --rm --gpus all psychemistz/sigdiscovpy:gpu python -c "
import cupy as cp
print(f'CuPy version: {cp.__version__}')
x = cp.arange(10)
print(f'GPU array: {x}')
"

⁠Troubleshooting

⁠R Package Installation Failures

If R packages fail to install, try building with verbose output:

docker build -t sigdiscovpy:with-r --build-arg INSTALL_R=true --progress=plain .

Common issues:

  • Network timeout: Increase timeout in Dockerfile or retry
  • Missing system library: Add to apt-get install list
  • GitHub rate limit: Wait and retry, or use a GitHub token
⁠Permission Issues
# Run as current user
docker run -it --rm -u $(id -u):$(id -g) -v $(pwd):/workspace psychemistz/sigdiscovpy:latest
⁠Memory Issues
# Increase memory limit
docker run -it --rm -m 16g -v $(pwd):/workspace psychemistz/sigdiscovpy:latest
⁠GPU Not Detected
# Check NVIDIA driver
nvidia-smi

# Check Docker GPU support
docker info | grep -i gpu

# Verify nvidia-container-toolkit
which nvidia-container-toolkit

⁠Customization

⁠Add Your Own Packages

Create a custom Dockerfile:

FROM psychemistz/sigdiscovpy:with-r

# Add R packages
RUN R -e "install.packages('your_r_package', repos='https://cloud.r-project.org/')"

# Add Python packages
RUN pip3 install your_python_package
⁠Mount Additional Data
docker run -it --rm \
  -v $(pwd):/workspace \
  -v /path/to/data:/data:ro \
  -v /path/to/results:/results \
  psychemistz/sigdiscovpy:latest

⁠Singularity / HPC

On HPC clusters where Docker is not available, use Singularity or Apptainer to pull the Docker images:

# Load Singularity or Apptainer (cluster-specific)
module load singularity   # or: module load apptainer

# Pull CPU image
singularity pull docker://psychemistz/sigdiscovpy:latest

# Pull R-enabled image
singularity pull docker://psychemistz/sigdiscovpy:with-r

# Run interactively
singularity exec sigdiscovpy_latest.sif python3 -c "import sigdiscovpy; print(sigdiscovpy.__version__)"

# Run with data binding
singularity exec --bind /path/to/data:/data sigdiscovpy_latest.sif python3 your_script.py

# Run R inside the container
singularity exec sigdiscovpy_with-r.sif Rscript -e "library(sigdiscov); cat('OK\n')"

Note: Building images from the Dockerfile on HPC requires fakeroot support. If unavailable, pull the pre-built images from Docker Hub instead.

⁠CI/CD Notes

  • Default CI builds use INSTALL_R=false for speed
  • R-enabled builds are triggered on releases or manual dispatch
  • Use workflow_dispatch with build_r=true to build R images manually
# Trigger R build manually in GitHub Actions
workflow_dispatch:
  inputs:
    build_r:
      description: 'Build images with R packages'
      default: 'true'

Tag summary

Content type

Image

Digest

sha256:92f8edc12…

Size

469.7 MB

Last updated

8 months ago

docker pull psychemistz/sigdiscovpy