Upload README.md

#1
by farjvd - opened
Files changed (1) hide show
  1. README.md +87 -118
README.md CHANGED
@@ -1,127 +1,96 @@
1
- <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN -->
2
- <p align="center">
3
- <a href="https://github.com/vevotx/mosaicfm">
4
- <picture>
5
- <img alt="tahoe-therapeutics" src="./assets/tahoe-navy-logo.png" width="95%">
6
- </picture>
7
- </a>
8
- </p>
9
- <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_END -->
10
-
11
- <p align="center">
12
- <a href="https://github.com/astral-sh/ruff"><img alt="Linter: Ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
13
- <a href="https://github.com/vevotx/mosaicfm/blob/main/LICENSE">
14
- <img alt="License" src="https://img.shields.io/badge/License-Apache%202.0-green.svg">
15
- </a>
16
- <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
17
- </p>
18
- <br />
19
-
20
- # MosaicFM
21
-
22
- This is the internal codebase for the **MosaicFM** series of single-cell RNA-seq foundation models
23
- developed by Vevo Therapeutics. Our repository follows a similar structure to [llm-foundry](https://github.com/mosaicml/llm-foundry/tree/main)
24
- and imports several utility functions from it. Please follow the developer guidelines if you are
25
- contributing to this repository. For main results and documentation, please refer to the results section.
26
- If you are looking to train or finetune a model on single-cell data, please refer to the training section.
27
-
28
- The repository is organized as follows:
29
- * `mosaicfm/` contains the building blocks for the MosaicFM models.
30
- * `mosaicfm/model/blocks` Building block modules that may be used across models
31
- * `mosaicfm/model/model` Full architectures subclassed from [ComposerModel](https://docs.mosaicml.com/projects/composer/en/latest/composer_model.html)
32
- * `mosaicfm/tasks/` Helper functions to use in downstream applications, such as embedding extraction.
33
- * `mosaicfm/tokenizer` Vocabulary building and tokenization functions.
34
- * `mosaicfm/data` Data loaders and collators
35
- * `mosaicfm/utils` Miscellaneous utility functions such to dowload files from s3 etc.
36
- * `scripts/` contains scripts to train/evaluate models and to build datasets.
37
- * `scripts/train.py` Script to train a model. Accepts a yaml file or command line arguments for specifying job parameters.
38
- * `scripts/prepare_for_inference.py` Script to save a model for inference by packaging it with the vocabulary and saving metadata.
39
- * `scripts/depmap` Scripts to run the depmap benchmark.
40
- * `mcli` yaml files to configure and launch runs on the MosaicML platform.
41
- * `runai` yaml files to configure and launch runs on RunAI.
42
- * `tutorials` Notebooks to demonstrate some applications of the models.
43
-
44
- ## Hardware and Software Requirements
45
-
46
- We have tested our code on NVIDIA A100 and H100 GPUs with CUDA 12.1.
47
- At the moment, we are also restricted to use a version of llm-foundry no later v0.6.0, since support for the triton
48
- implementation of flash-attention was removed in [v0.7.0](https://github.com/mosaicml/llm-foundry/releases/tag/v0.7.0).
49
-
50
- We support launching runs on the MosaicML platform as well as on local machines through RunAI.
51
- The recommended method for using MosaicFM is to use the pre-built [vevotx/ml-scgpt](https://hub.docker.com/repository/docker/vevotx/ml-scgpt/) docker image.
52
-
53
- Currently, we have the following images available:
54
-
55
- | Image Name | Base Image | Description |
56
- |--------------------------------|-------------|-------------------------------------------------|
57
- | [`vevotx/ml-scgpt:shreshth`](https://github.com/vevotx/vevo-docker/tree/main/ml_docker_vevo_scgpt) | docker.io/mosaicml/llm-foundry:2.2.1_cu121_flash2-813d596 | Image used for MosaicFM-1.3B (July 2024 release) |
58
 
59
  ## Installation
60
 
61
- ### With docker
62
- ```shell
63
- git clone https://github.com/vevotx/mosaicfm.git
64
- cd mosaicfm
65
- pip install -e .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ```
67
- ### Without docker
68
- ```shell
69
- git clone https://github.com/vevotx/mosaicfm.git
70
- cd mosaicfm
71
- mamba env create -f envs/mosaicfm_env.yml
72
- mamba activate mosaicfm
73
- pip install -e . --no-deps # Inside the mosaicfm directory
74
  ```
75
- > [!NOTE]
76
- > If you are on an H100 GPU you may see `'sm_90' is not a recognized processor for this target (ignoring processor)`. This is expected and safe to ignore.
77
-
78
-
79
- ## Datasets
80
-
81
- The following datasets are used for training and evaluation:
82
-
83
- | Dataset Path | Description |
84
- |------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
85
- | `s3://vevo-ml-datasets/vevo-scgpt/datasets/cellxgene_primary_2024-04-29_MDS/` | MDS dataset comprising ~45M cells from Apr 2024 release by CellxGene and Vevo dataset 35 (resistance-is-futile) |
86
- | `s3://vevo-ml-datasets/vevo-scgpt/datasets/cellxgene_primary_2023-12-15_MDS_v2/` | MDS dataset comprising ~34M cells from Dec 2023 release by CellxGene. |
87
- |`s3://vevo-ml-datasets/umair/scgpt-depmap/` | Root folder containing Depmap dataset and model predictions |
88
- |`s3://vevo-drives/drive_3/ANALYSIS/analysis_107/` | Root folder MSigDB data and model predictions |
89
-
90
- ## Pre-trained Models
91
-
92
- | Model Name | Run Name | Path to Checkpoints | WandB id |
93
- |-----------------------------|------------------------------------|---------------------------------------------------------------|----------|
94
- | **MosaicFM-1.3B** | scgpt-1_3b-2048-prod | `s3:/vevo-scgpt/models/scgpt-1_3b-2048-prod/` | lv6jl8kl |
95
- | **MosaicFM-70M** | scgpt-70m-1024-fix-norm-apr24-data | `s3:/vevo-scgpt/models/scgpt-70m-1024-fix-norm-apr24-data/` | 55n5wvdm |
96
- | **MosaicFM-25M** | scgpt-25m-1024-fix-norm-apr24-data | `s3:/vevo-scgpt/models/scgpt-25m-1024-fix-norm-apr24-data/` | bt4a1luo |
97
- | **MosaicFM-9M** | sscgpt-test-9m-full-data | `s3:/vevo-scgpt/models/scgpt-test-9m-full-data/` | di7kyyf1 |
98
-
99
- ## Results
100
- Links to evaluations and benchmarks are provided below:
101
- - [Depmap](scripts/depmap/README.md)
102
- - [MSigDB](https://github.com/vevotx/shreshth_sandbox/tree/main/analysis/04_msigdb_benchmark/README.md)
103
-
104
- Please refer to our technical report for detailed results and analysis: [Internal Link](https://drive.google.com/drive/u/1/folders/1KeAXZ9zNYh4uHbLL5XUMmreAkHXW4yXo)
105
-
106
- ## Developer Guidelines
107
- We use the black code style and the Ruff linter to mantain consistency across contributions.
108
- Please set-up `pre-commit` and run the repository level hooks before committing any changes.
109
- Please do not push to master directly. Create a new branch and open a pull request for review.
110
- To set up pre-commit hooks, run the following command:
111
- ```shell
112
- pip install pre-commit
113
- pre-commit install
114
- pre-commit run --all-files # Before committing
115
  ```
116
- We also encourage new contributions to use type annotations and docstrings for functions and classes. In the future we
117
- will add `pyright` and `pydocstyle` checks to the pre-commit hooks. We encourage the use of Google style docstrings.
118
 
119
- If you will be launching any training/evaluation runs, please also make sure you have access to `s3`, `wandb`
120
- and `mcli`/`runai` by reaching out on #infrastructure.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  ## Acknowledgements
123
- We would like to thank the developers of the following open-source projects:
124
- - [scGPT](https://github.com/bowang-lab/scGPT/tree/main)
125
- - [llm-foundry](https://github.com/mosaicml/llm-foundry)
126
- - [streaming](https://github.com/mosaicml/streaming)
127
- - [datasets](https://github.com/huggingface/datasets)
 
1
+ # TahoeX1
2
+
3
+ TahoeX1 is a family of transformer-based foundation models for single-cell RNA sequencing developed by Tahoe Therapeutics.
4
+
5
+ ## Available Models
6
+
7
+ - TahoeX1-3B
8
+ - TahoeX1-1B
9
+ - TahoeX1-70M
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  ## Installation
12
 
13
+ 1. Clone the repository:
14
+ ```bash
15
+ git clone https://github.com/vevotx/mosaicfm-release.git
16
+ cd mosaicfm-release
17
+ ```
18
+
19
+ 2. Install the package. We recommend using the pre-built Docker image [vevotx/mosaicfm:1.0.0]()TODO, but you can also install locally:
20
+ - **With Docker**
21
+ ```bash
22
+ pip install -e .
23
+ ```
24
+ - **Without Docker**
25
+ ```bash
26
+ mamba env create -f envs/mosaicfm_env.yml
27
+ mamba activate mosaicfm-release
28
+ pip install -e . --no-deps
29
+ ```
30
+
31
+ ## Required Files
32
+ Required files including the training datasets, benchmark files, and vocabulary files are hosted in Tahoe's S3 bucket [tahoe-hackathon-data] (s3://tahoe-hackathon-data).
33
+
34
+
35
+ ## Getting Cell and Gene Embeddings
36
+
37
+ 1. Create a configuration file (see `scripts/inference/configs/predict.yaml`).
38
+ ```bash
39
+ # Configure config file with:
40
+ # - paths.model_dir: model checkpoint path
41
+ # - paths.adata_input: input h5ad file
42
+ # - paths.adata_output: output h5ad file
43
+ # - predict.return_gene_embeddings: True (for extracting and saving gene embeddings)
44
  ```
45
+
46
+ 2. Run the embedding script:
47
+ ```bash
48
+ python scripts/inference/predict_embeddings.py path/to/config.yaml
49
+
50
+ # Optional parameters can be added to overwrite config values:
51
+ python scripts/inference/predict_embeddings.py path/to/config.yaml --paths.model_name=tx --batch_size=128
52
  ```
53
+
54
+ Cell embeddings are written to the output AnnData file. If `return_gene_embeddings` is `True`, gene embeddings are also stored.
55
+
56
+ 3. If you encounter OOM error, fall back to the lower-level `tasks.get_batch_embeddings` API, which loads gene
57
+ embeddings in chunks:
58
+
59
+ ```python
60
+ model, vocab, model_cfg, collator_cfg = load_model(
61
+ model_dir,
62
+ device=device,
63
+ return_gene_embeddings=return_gene_embeddings,
64
+ )
65
+ cell_embs, gene_embs = get_batch_embeddings(
66
+ adata=adata,
67
+ model=model,
68
+ vocab=vocab,
69
+ model_cfg=model_cfg,
70
+ collator_cfg=collator_cfg,
71
+ return_gene_embeddings=True
72
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ```
 
 
74
 
75
+ ## Training
76
+ 1. Define a YAML configuration file (see examples in `runai/` or `mcli/`) describing model, data and training parameters.
77
+
78
+ 2. Launch training with Composer:
79
+ ```bash
80
+ composer scripts/train.py path/to/config.yaml
81
+ ```
82
+
83
+ ## Applications
84
+
85
+ For downstream applications and benchmarks:
86
+ - **MSigDB pathway analysis**: See `scripts/msigdb/`
87
+ - **DepMap gene essentiality**: See `scripts/depmap/`
88
+ - **Cell clustering**: See `scripts/clustering_tutorial.ipynb`
89
+
90
+ ## License
91
+
92
+ TODO
93
 
94
  ## Acknowledgements
95
+
96
+ Built upon [scGPT](https://github.com/bowang-lab/scGPT), [llm-foundry](https://github.com/mosaicml/llm-foundry), and [streaming](https://github.com/mosaicml/streaming).