M Christenson commited on
Commit
ea63229
·
verified ·
1 Parent(s): 580b7d5

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +1 -210
README.md CHANGED
@@ -1,210 +1 @@
1
- ---
2
- tags:
3
- - single-cell
4
- - foundation models
5
- ---
6
-
7
- # SCimilarity Model
8
-
9
- ## Model Details
10
-
11
- - **Model Name**: SCimilarity
12
- - **Version**: 1.0 [deeplife version]
13
- - **Type**: Metric learning framework for single-cell RNA-seq data
14
- - **Paper**: [Scalable querying of human cell atlases via a foundational model reveals commonalities across fibrosis-associated macrophages
15
- ](https://www.biorxiv.org/content/10.1101/2023.07.18.549537v1)
16
- - **Original Implementation**: [SCimilarity GitHub Repository](https://github.com/genentech/scimilarity)
17
-
18
- ## Model Description
19
-
20
- SCimilarity is a metric learning framework that learns and searches a unified and interpretable representation of single-cell RNA-seq data. It enables annotation of cell types and instant querying for cell states across tens of millions of profiles. In the context of DeepLife ML Infra, we focus on its cell embedding capabilities.
21
-
22
- ### Abstract
23
-
24
- Single-cell RNA-seq (scRNA-seq) studies have profiled over 100 million human cells across diseases, developmental stages, and perturbations to date. A singular view of this vast and growing expression landscape could help reveal novel associations between cell states and diseases, discover cell states in unexpected tissue contexts, and relate in vivo cells to in vitro models. However, these require a common, scalable representation of cell profiles from across the body, a general measure of their similarity, and an efficient way to query these data. Here, we present SCimilarity, a metric learning framework to learn and search a unified and interpretable representation that annotates cell types and instantaneously queries for a cell state across tens of millions of profiles. We demonstrate SCimilarity on a 22.7 million cell corpus assembled across 399 published scRNA-seq studies, showing accurate integration, annotation and querying. We experimentally validated SCimilarity by querying across tissues for a macrophage subset originally identified in interstitial lung disease, and showing that cells with similar profiles are found in other fibrotic diseases, tissues, and a 3D hydrogel system, which we then repurposed to yield this cell state in vitro. SCimilarity serves as a foundational model for single cell gene expression data and enables researchers to query for similar cellular states across the entire human body, providing a powerful tool for generating novel biological insights from the growing Human Cell Atlas.
25
-
26
- ### Key Features
27
-
28
- - Generates unified embeddings for single-cell expression profiles
29
- - Enables efficient querying and annotation across large-scale datasets
30
- - Generalizes to new studies without retraining
31
- - Supports discovery of novel cell state associations across diseases and tissues
32
-
33
- ## Intended Use
34
-
35
- SCimilarity is designed for researchers working with single-cell RNA sequencing (scRNA-seq) data. Within the DeepLife ML Infra framework, it can be used for:
36
-
37
- - Generating cell embeddings from scRNA-seq data
38
- - Querying for similar cell states across large datasets
39
- - Annotating cell types in new datasets
40
- - Discovering novel associations between cell states and diseases
41
-
42
- ## Training Data
43
-
44
- The model was trained on a corpus of 22.7 million cells assembled from 399 published scRNA-seq studies. For detailed information about the training data, please refer to the original paper.
45
-
46
- ## Performance
47
-
48
- SCimilarity has demonstrated:
49
-
50
- - Accurate integration and annotation across a large corpus of cells
51
- - Efficient querying for similar cell states across tissues and diseases
52
- - Ability to reveal novel biological insights, as validated experimentally
53
-
54
- For specific performance metrics, please refer to the original paper.
55
-
56
- ## Limitations
57
-
58
- - The model's performance may vary for cell types or states that are underrepresented in the training data
59
- - As with any embedding model, care should be taken when interpreting similarities, especially across different experimental conditions or protocols
60
-
61
- ## Ethical Considerations
62
-
63
- Users should be aware that while the data used to train SCimilarity is from public sources, it represents human tissue samples and should be treated with appropriate respect and consideration. Researchers using this model should adhere to ethical guidelines for human subjects research.
64
-
65
- ## Usage
66
-
67
- To use the SCimilarity model within the DeepLife ML Infra:
68
-
69
- 1. Install the package:
70
- ```
71
- pip install deeplife-mlinfra
72
- ```
73
-
74
- 2. Import and use the model:
75
- ```python
76
- import anndata as ad
77
- from huggingface_hub import hf_hub_download
78
- from dl_models.models.scimilarity.model import SCimilarityEmbedModel
79
- from dl_models.models.scimilarity.processor import SCimilarityProcessor
80
-
81
- # Load the model and preprocessor
82
- model = SCimilarityEmbedModel.from_pretrained("deeplife/scimilarity_model")
83
- preprocessor = SCimilarityProcessor.from_pretrained("deeplife/scimilarity_model")
84
- model.eval()
85
-
86
- # Load your data (example using a sample dataset)
87
- filepath = hf_hub_download(
88
- repo_id="deeplife/h5ad_samples",
89
- filename="GSE136831small.h5ad",
90
- repo_type="dataset",
91
- )
92
- adata = ad.read_h5ad(filepath)
93
-
94
- # Preprocess and create a dataloader
95
- dataloader = preprocessor.transform_to_dataloader(adata, batch_size=256)
96
-
97
- # Get embeddings
98
- for batch in dataloader:
99
- embed = model.get_cell_embeddings(batch)
100
- break # This gets embeddings for the first batch
101
-
102
- # You can now use these embeddings for downstream tasks
103
- ```
104
-
105
- For visualization of the embeddings, you can use techniques like PCA or UMAP:
106
-
107
- ```python
108
- import numpy as np
109
- from sklearn.decomposition import PCA
110
- import matplotlib.pyplot as plt
111
- import umap
112
-
113
- # Convert embed to numpy
114
- embed_np = embed.detach().cpu().numpy()
115
-
116
- # Perform PCA
117
- pca = PCA(n_components=2)
118
- embed_pca = pca.fit_transform(embed_np)
119
-
120
- # Perform UMAP
121
- umap_reducer = umap.UMAP(n_components=2, random_state=42)
122
- embed_umap = umap_reducer.fit_transform(embed_np)
123
-
124
- # Plot the results
125
- fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 8))
126
-
127
- # PCA plot
128
- scatter1 = ax1.scatter(embed_pca[:, 0], embed_pca[:, 1], alpha=0.7)
129
- ax1.set_title('SCimilarity Embeddings - PCA')
130
- ax1.set_xlabel('PC1')
131
- ax1.set_ylabel('PC2')
132
- plt.colorbar(scatter1, ax=ax1)
133
-
134
- # UMAP plot
135
- scatter2 = ax2.scatter(embed_umap[:, 0], embed_umap[:, 1], alpha=0.7)
136
- ax2.set_title('SCimilarity Embeddings - UMAP')
137
- ax2.set_xlabel('UMAP1')
138
- ax2.set_ylabel('UMAP2')
139
- plt.colorbar(scatter2, ax=ax2)
140
-
141
- plt.tight_layout()
142
- plt.show()
143
- ```
144
-
145
- For more detailed usage instructions, please refer to the [documentation](https://github.com/deeplifeai/deeplife-mlinfra).
146
-
147
- ## Citation
148
-
149
- If you use this model in your research, please cite both the original SCimilarity paper and the DeepLife ML Infra package:
150
-
151
- ```
152
- @article{yoo2023scimilarity,
153
- title={SCimilarity: a scalable and universal cell state similarity metric for single cell RNA-sequencing data},
154
- author={Yoo, Byungjin and Nawy, Tal and Hu, Yuanjie and Szeto, Gregory L and Wuster, Arthur},
155
- journal={bioRxiv},
156
- pages={2023.07.18.549537},
157
- year={2023},
158
- publisher={Cold Spring Harbor Laboratory}
159
- }
160
-
161
- @software{deeplife_mlinfra,
162
- title={DeepLife ML Infra: Infrastructure for Biological Deep Learning Models},
163
- author={DeepLife AI Team},
164
- year={2023},
165
- url={https://github.com/deeplifeai/deeplife-mlinfra},
166
- version={1.0.0}
167
- }
168
- ```
169
-
170
- ## License
171
-
172
- ### Code License
173
-
174
- The SCimilarity code is licensed under the Apache License, Version 2.0. The full text of the license is as follows:
175
-
176
- ```
177
- Copyright 2023 Genentech, Inc.
178
-
179
- Licensed under the Apache License, Version 2.0 (the "License");
180
- you may not use this file except in compliance with the License.
181
- You may obtain a copy of the License at
182
-
183
- http://www.apache.org/licenses/LICENSE-2.0
184
-
185
- Unless required by applicable law or agreed to in writing, software
186
- distributed under the License is distributed on an "AS IS" BASIS,
187
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
- See the License for the specific language governing permissions and
189
- limitations under the License.
190
- ```
191
-
192
- ### Model Weights License
193
-
194
- The SCimilarity model weights are licensed under the Creative Commons Attribution Share Alike 4.0 International license. Users are free to share and adapt the material under the following terms:
195
-
196
- - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
197
- - ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
198
-
199
- For the full text of this license, please visit: [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
200
-
201
- ## Additional Resources
202
-
203
- - [SCimilarity Documentation](https://genentech.github.io/scimilarity/index.html)
204
- - [Pretrained Model Weights and Data](https://zenodo.org/records/10685499)
205
-
206
- ## Contact
207
-
208
- For questions or issues related to this model implementation in DeepLife ML Infra, please open an issue in the [repository](https://github.com/deeplifeai/deeplife-mlinfra).
209
-
210
- For questions about the original SCimilarity model, please refer to the [original repository](https://github.com/genentech/scimilarity).
 
1
+ /Users/gucky92/.cache/huggingface/hub/models--deeplife--scimilarity_model/snapshots/580b7d53b74d11716bdbcc3f04c3bf80b92acbac/README.md