M Christenson commited on
Commit
9b63433
·
verified ·
1 Parent(s): 23f6916

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +9 -206
README.md CHANGED
@@ -1,206 +1,9 @@
1
-
2
-
3
- # SCimilarity Model
4
-
5
- ## Model Details
6
-
7
- - **Model Name**: SCimilarity
8
- - **Version**: 1.0 [deeplife version]
9
- - **Type**: Metric learning framework for single-cell RNA-seq data
10
- - **Paper**: [Scalable querying of human cell atlases via a foundational model reveals commonalities across fibrosis-associated macrophages
11
- ](https://www.biorxiv.org/content/10.1101/2023.07.18.549537v1)
12
- - **Original Implementation**: [SCimilarity GitHub Repository](https://github.com/genentech/scimilarity)
13
-
14
- ## Model Description
15
-
16
- 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.
17
-
18
- ### Abstract
19
-
20
- 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.
21
-
22
- ### Key Features
23
-
24
- - Generates unified embeddings for single-cell expression profiles
25
- - Enables efficient querying and annotation across large-scale datasets
26
- - Generalizes to new studies without retraining
27
- - Supports discovery of novel cell state associations across diseases and tissues
28
-
29
- ## Intended Use
30
-
31
- 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:
32
-
33
- - Generating cell embeddings from scRNA-seq data
34
- - Querying for similar cell states across large datasets
35
- - Annotating cell types in new datasets
36
- - Discovering novel associations between cell states and diseases
37
-
38
- ## Training Data
39
-
40
- 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.
41
-
42
- ## Performance
43
-
44
- SCimilarity has demonstrated:
45
-
46
- - Accurate integration and annotation across a large corpus of cells
47
- - Efficient querying for similar cell states across tissues and diseases
48
- - Ability to reveal novel biological insights, as validated experimentally
49
-
50
- For specific performance metrics, please refer to the original paper.
51
-
52
- ## Limitations
53
-
54
- - The model's performance may vary for cell types or states that are underrepresented in the training data
55
- - As with any embedding model, care should be taken when interpreting similarities, especially across different experimental conditions or protocols
56
-
57
- ## Ethical Considerations
58
-
59
- 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.
60
-
61
- ## Usage
62
-
63
- To use the SCimilarity model within the DeepLife ML Infra:
64
-
65
- 1. Install the package:
66
- ```
67
- pip install deeplife-mlinfra
68
- ```
69
-
70
- 2. Import and use the model:
71
- ```python
72
- import anndata as ad
73
- from huggingface_hub import hf_hub_download
74
- from dl_models.models.scimilarity.model import SCimilarityEmbedModel
75
- from dl_models.models.scimilarity.processor import SCimilarityProcessor
76
-
77
- # Load the model and preprocessor
78
- model = SCimilarityEmbedModel.from_pretrained("deeplife/scimilarity_model")
79
- preprocessor = SCimilarityProcessor.from_pretrained("deeplife/scimilarity_model")
80
- model.eval()
81
-
82
- # Load your data (example using a sample dataset)
83
- filepath = hf_hub_download(
84
- repo_id="deeplife/h5ad_samples",
85
- filename="GSE136831small.h5ad",
86
- repo_type="dataset",
87
- )
88
- adata = ad.read_h5ad(filepath)
89
-
90
- # Preprocess and create a dataloader
91
- dataloader = preprocessor.transform_to_dataloader(adata, batch_size=256)
92
-
93
- # Get embeddings
94
- for batch in dataloader:
95
- embed = model.get_cell_embeddings(batch)
96
- break # This gets embeddings for the first batch
97
-
98
- # You can now use these embeddings for downstream tasks
99
- ```
100
-
101
- For visualization of the embeddings, you can use techniques like PCA or UMAP:
102
-
103
- ```python
104
- import numpy as np
105
- from sklearn.decomposition import PCA
106
- import matplotlib.pyplot as plt
107
- import umap
108
-
109
- # Convert embed to numpy
110
- embed_np = embed.detach().cpu().numpy()
111
-
112
- # Perform PCA
113
- pca = PCA(n_components=2)
114
- embed_pca = pca.fit_transform(embed_np)
115
-
116
- # Perform UMAP
117
- umap_reducer = umap.UMAP(n_components=2, random_state=42)
118
- embed_umap = umap_reducer.fit_transform(embed_np)
119
-
120
- # Plot the results
121
- fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 8))
122
-
123
- # PCA plot
124
- scatter1 = ax1.scatter(embed_pca[:, 0], embed_pca[:, 1], alpha=0.7)
125
- ax1.set_title('SCimilarity Embeddings - PCA')
126
- ax1.set_xlabel('PC1')
127
- ax1.set_ylabel('PC2')
128
- plt.colorbar(scatter1, ax=ax1)
129
-
130
- # UMAP plot
131
- scatter2 = ax2.scatter(embed_umap[:, 0], embed_umap[:, 1], alpha=0.7)
132
- ax2.set_title('SCimilarity Embeddings - UMAP')
133
- ax2.set_xlabel('UMAP1')
134
- ax2.set_ylabel('UMAP2')
135
- plt.colorbar(scatter2, ax=ax2)
136
-
137
- plt.tight_layout()
138
- plt.show()
139
- ```
140
-
141
- For more detailed usage instructions, please refer to the [documentation](https://github.com/deeplifeai/deeplife-mlinfra).
142
-
143
- ## Citation
144
-
145
- If you use this model in your research, please cite both the original SCimilarity paper and the DeepLife ML Infra package:
146
-
147
- ```
148
- @article{yoo2023scimilarity,
149
- title={SCimilarity: a scalable and universal cell state similarity metric for single cell RNA-sequencing data},
150
- author={Yoo, Byungjin and Nawy, Tal and Hu, Yuanjie and Szeto, Gregory L and Wuster, Arthur},
151
- journal={bioRxiv},
152
- pages={2023.07.18.549537},
153
- year={2023},
154
- publisher={Cold Spring Harbor Laboratory}
155
- }
156
-
157
- @software{deeplife_mlinfra,
158
- title={DeepLife ML Infra: Infrastructure for Biological Deep Learning Models},
159
- author={DeepLife AI Team},
160
- year={2023},
161
- url={https://github.com/deeplifeai/deeplife-mlinfra},
162
- version={1.0.0}
163
- }
164
- ```
165
-
166
- ## License
167
-
168
- ### Code License
169
-
170
- The SCimilarity code is licensed under the Apache License, Version 2.0. The full text of the license is as follows:
171
-
172
- ```
173
- Copyright 2023 Genentech, Inc.
174
-
175
- Licensed under the Apache License, Version 2.0 (the "License");
176
- you may not use this file except in compliance with the License.
177
- You may obtain a copy of the License at
178
-
179
- http://www.apache.org/licenses/LICENSE-2.0
180
-
181
- Unless required by applicable law or agreed to in writing, software
182
- distributed under the License is distributed on an "AS IS" BASIS,
183
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184
- See the License for the specific language governing permissions and
185
- limitations under the License.
186
- ```
187
-
188
- ### Model Weights License
189
-
190
- 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:
191
-
192
- - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
193
- - ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
194
-
195
- For the full text of this license, please visit: [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
196
-
197
- ## Additional Resources
198
-
199
- - [SCimilarity Documentation](https://genentech.github.io/scimilarity/index.html)
200
- - [Pretrained Model Weights and Data](https://zenodo.org/records/10685499)
201
-
202
- ## Contact
203
-
204
- 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).
205
-
206
- For questions about the original SCimilarity model, please refer to the [original repository](https://github.com/genentech/scimilarity).
 
1
+ ---
2
+ tags:
3
+ - model_hub_mixin
4
+ - pytorch_model_hub_mixin
5
+ ---
6
+
7
+ This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
8
+ - Library: [More Information Needed]
9
+ - Docs: [More Information Needed]