A PyTorch implementation of the PENNE model for inferring gene expression from phase-contrast microscopy images
Project description
PENNE - Phase-to-Expression Neural Network Estimator
Implementation of PENNE, a method for inferring transcriptome from phase-contrast microscopy images.
Read the paper and the documentations
Installing PENNE
Installing using PyPI
PENNE is available on the Python Package Index (PyPI) to be installed with pip directly. It is strongly recommended to create a virtual environment before installing, as this is built on numpy 1.x, which means it will probably fail if you try to install it in an environment that is already built with numpy 2.x due to the massive architecture change for numpy.
To install, run:
virtualenv --no-download penne
source penne/bin/activate
pip install pcm-penne
Installing Locally
Alternatively, you may also install PENNE from the GitHub repository directly. To do that, first create a virtual Python environment and install PENNE locally.
virtualenv --no-download penne
source penne/bin/activate
git clone https://github.com/schwartzlab-methods/penne
cd penne
pip install .
Inferences using PENNE
An example workflow of how to use PENNE to infer gene expression from your phase-contrast microscopy images can be found at ./tutorials/inference.ipynb. You may supply your own checkpoint files, but if none is supplied, PENNE will automatically download it from the official GitHub repository.
Inferences with the CLI tool
Alternatively, you can also run inferences using the CLI interface to perform quick inferences. To do this, after you have installed PENNE, run:
python3 penne --input path_to_directory_with_your_images \
--output path_to_directory_to_save_the_images
You can also optionally use --penne_checkpoint, --spaghetti_checkpoint, and --gene_names if you are not using the default pre-trained model.
Inferences with Docker
For a dependency-free and reproducible environment, the CLI inference tool of PENNE is available as a Docker image. To use it, ensure you have Docker installed, then run:
Option 1: Use the Pre-built Image from Docker Hub
The official image is hosted on Docker Hub.
-
Pull the latest image:
docker pull yinnikun/penne:latest
-
Run Inference:
To run inference, you need to mount a local directory into the container. This directory should contain your input images and the model checkpoint. The container will write the output images back to this same directory.
Let's say your local data is organized as follows:
/path/to/your/data/ ├── inputs/ │ ├── image1.tif │ └── image2.tif ├── penne.ckpt <-- optional, if not supplied it will be downloaded ├── spaghetti.ckpt <-- optional, if not supplied it will be downloaded └── outputs/ <-- This will be createdExecute the following command:
docker run --rm -v "/path/to/your/data:/data" yinnikun/penne:latest \ --input /data/inputs \ --penne_checkpoint /data/penne.ckpt \ --spaghetti_checkpoint /data/penne.ckpt
--rm: Automatically removes the container when it exits.-v "/path/to/your/data:/data": Mounts your local data directory into the/datadirectory inside the container. Remember to use absolute paths.
Option 2: Build the Image Locally
You can also build the Docker image directly from the dockerfile in this repository.
-
Build the image:
docker build -t penne:latest .
-
Run Inference: The
docker runcommand is the same as above, just replace the image name:docker run --rm -v "/path/to/your/data:/data" penne:latest \ --input /data/inputs \ --output /data/outputs \ --penne_checkpoint /data/penne.ckpt \ --spaghetti_checkpoint /data/penne.ckpt
Training your own model
You can also train your own model to perform the inferences. See the documentations for the details on how to use the TrainPenne class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcm_penne-1.0.0.tar.gz.
File metadata
- Download URL: pcm_penne-1.0.0.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01fa95c9c82252e7ebb60d923276258706ef67b2c7c179c07eda713caebaeb44
|
|
| MD5 |
32334071770b30982643f9574e9fad6e
|
|
| BLAKE2b-256 |
fcd0e2cbf79579f3df83330657bf061ef657274ae14fe4c01c13bc5c66963777
|
Provenance
The following attestation bundles were made for pcm_penne-1.0.0.tar.gz:
Publisher:
python-publish.yml on schwartzlab-methods/penne
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcm_penne-1.0.0.tar.gz -
Subject digest:
01fa95c9c82252e7ebb60d923276258706ef67b2c7c179c07eda713caebaeb44 - Sigstore transparency entry: 2085106489
- Sigstore integration time:
-
Permalink:
schwartzlab-methods/penne@a08c23d0f7d34476c72756786efc0e9c762cb37c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/schwartzlab-methods
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a08c23d0f7d34476c72756786efc0e9c762cb37c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pcm_penne-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pcm_penne-1.0.0-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32cca75e3f0e1038153f669ee6cf2cd05492755f3e1298e6f93b7d42665dabbd
|
|
| MD5 |
a840dc168826634cd0c2adcdb924ac9c
|
|
| BLAKE2b-256 |
b79a9304dc09cc409284547930ee5f865990c341c7a69445322e5af465115bb8
|
Provenance
The following attestation bundles were made for pcm_penne-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on schwartzlab-methods/penne
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcm_penne-1.0.0-py3-none-any.whl -
Subject digest:
32cca75e3f0e1038153f669ee6cf2cd05492755f3e1298e6f93b7d42665dabbd - Sigstore transparency entry: 2085106509
- Sigstore integration time:
-
Permalink:
schwartzlab-methods/penne@a08c23d0f7d34476c72756786efc0e9c762cb37c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/schwartzlab-methods
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a08c23d0f7d34476c72756786efc0e9c762cb37c -
Trigger Event:
release
-
Statement type: