Skip to main content

Spatial transcriptomics foundation model

Project description

TERRA

Installation

To install the project and its dependencies, run:

pip install -e .

Repository Structure

  1. main.py
    The main entry point for the project, which supports running training and evaluation sweeps. It includes command-line arguments for customization and handles multi-GPU setups.

  2. configs/$DATASET.yaml
    Configuration file that defines the dataset specific hyperparameters and settings used during the training process, such as model architecture, data handling, and optimization settings ($DATASET is the name of the dataset, e.g. merfish_300k).

  3. src/terra/models/gene_transformer.py
    Contains the model definition for the gene transformer, implementing the core architecture that will be trained and evaluated.

  4. src/terra/train.py
    Handles the training process in a distributed setting. This script contains the logic for executing the training loop and logging results.

  5. src/terra/infer.py
    Manages the evaluation process. It evaluates the trained model on the specified tasks and logs the performance metrics.

  6. src/terra/utils/config.py
    Includes helper functions to setup the model and batch size params.

  7. src/terra/utils/embedding.py
    Provides utility functions for handling and loading embeddings required by the model during training and inference.

  8. src/terra/utils/evaluation.py
    Includes helper functions to streamline the evaluation process, such as metrics calculations and data preparation.

  9. src/terra/datasets/cell_neighborhood_dataset.py Includes helper functions to create torch datasets for data loading.

  10. tests
    Includes test cases for different functionalities.

Usage

Training

To start training with a single GPU, use the following command:

python -m pdb main.py --fname configs/$DATASET.yaml --devices cuda:0

where $DATASET is the name of the dataset, e.g. merfish_300k.

To start training with multiple GPUs, use the following command:

python -m pdb main.py --fname configs/$DATASET.yaml --devices cuda:0 cuda:1

To perform a sweep during training, use:

python -m pdb main.py --fname configs/$DATASET.yaml --devices cuda:0 --do_sweep

For multi-node training, first configure the required settings in your job_config file. Then, execute the following command:

bsub_mn_mg_yaml configs/job/hst_corpus_70m_test.yaml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terra_st-0.0.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terra_st-0.0.0-py3-none-any.whl (234.8 kB view details)

Uploaded Python 3

File details

Details for the file terra_st-0.0.0.tar.gz.

File metadata

  • Download URL: terra_st-0.0.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for terra_st-0.0.0.tar.gz
Algorithm Hash digest
SHA256 4a5328c494692b6fda61a0c83391227f060f407b7bef200bbbb26e0f22df25e7
MD5 ab4f1f0b6590cc06347603947adfab74
BLAKE2b-256 19a463597804dde6c65a908ad255a835d36f6ada42690dd2e40e772552745be8

See more details on using hashes here.

File details

Details for the file terra_st-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: terra_st-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 234.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for terra_st-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc9dfcd88944aa2ebbc0fb4b07119f3ef6b30d64fa3b9ff9579472963cfe9b6f
MD5 5f89722cbae3d32a4412356fb276ec7b
BLAKE2b-256 fb78b7016190b05f44cb36a45619627bbc408d5a55899ff6e806330386c75ce8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page