Skip to content

Commit 917ad7f

Browse files
committed
Improve SnapCCESS usability and citation guidance
1 parent 20fdd20 commit 917ad7f

14 files changed

Lines changed: 360 additions & 285 deletions

File tree

CHAGES.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Change Log
2+
3+
## 2024-07-26
4+
5+
- Updated the PyTorch dependency version to pass GitHub security checks.

CITATION.cff

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cff-version: 1.2.0
2+
message: "If you use SnapCCESS, please cite the associated Bioinformatics paper."
3+
title: "SnapCCESS: Ensemble deep learning of embeddings for clustering multimodal single-cell omics data"
4+
version: 0.2.2
5+
license: GPL-3.0-only
6+
repository-code: "https://github.com/PYangLab/SnapCCESS"
7+
authors:
8+
- family-names: Yu
9+
given-names: Lijia
10+
- family-names: Liu
11+
given-names: Chunlei
12+
- family-names: Yang
13+
given-names: "Jean Yee Hwa"
14+
- family-names: Yang
15+
given-names: Pengyi
16+
preferred-citation:
17+
type: article
18+
title: "Ensemble deep learning of embeddings for clustering multimodal single-cell omics data"
19+
authors:
20+
- family-names: Yu
21+
given-names: Lijia
22+
- family-names: Liu
23+
given-names: Chunlei
24+
- family-names: Yang
25+
given-names: "Jean Yee Hwa"
26+
- family-names: Yang
27+
given-names: Pengyi
28+
journal: Bioinformatics
29+
year: 2023
30+
volume: 39
31+
issue: 6
32+
article-number: btad382
33+
doi: "10.1093/bioinformatics/btad382"
34+
url: "https://doi.org/10.1093/bioinformatics/btad382"

README.md

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,99 @@
11
# SnapCCESS <a href="https://github.com/PYangLab/SnapCCESS"><img src="https://i.imgur.com/XHEB9j1.png" title="SnapCCESS hex sticker" align="right" height="138" /></a>
22

3-
SnapCCESS: Ensemble deep learning of embeddings for clustering multimodal single-cell omics data.
3+
SnapCCESS is an unsupervised ensemble deep learning framework for clustering
4+
multimodal single-cell omics data. It creates snapshots of multimodal variational
5+
autoencoder embeddings, which can then be used with downstream clustering
6+
methods to generate consensus cell clusters.
47

8+
The repository contains both:
59

6-
We propose SnapCCESS for clustering cells by integrating data modalities in multimodal
7-
single-cell omics data using an unsupervised ensemble deep learning framework. By creating snapshots
8-
of embeddings of multimodality using variational autoencoders, SnapCCESS can be coupled with
9-
various clustering algorithms for generating consensus clustering of cells.
10+
- `snapccess-py/`: the Python implementation distributed through PyPI.
11+
- `snapccess-r/SnapCCESS/`: an R wrapper that calls the Python package through
12+
`reticulate`.
1013

14+
![SnapCCESS workflow](https://i.imgur.com/krfBTGP.png)
1115

12-
![img](https://i.imgur.com/krfBTGP.png)
16+
## Publication
1317

18+
SnapCCESS accompanies:
1419

20+
> Yu, L., Liu, C., Yang, J. Y. H. & Yang, P. Ensemble deep learning of
21+
> embeddings for clustering multimodal single-cell omics data.
22+
> *Bioinformatics* 39(6), btad382 (2023).
23+
> <https://doi.org/10.1093/bioinformatics/btad382>
1524
1625
## Installation
1726

1827
### Python
1928

29+
```bash
30+
pip install snapccess --index-url https://pypi.org/simple
2031
```
21-
pip install snapccess --index-url https://pypi.org/simple
22-
```
23-
24-
For detailed description of each function, please see [https://github.com/PYangLab/SnapCCESS/tree/main/snapccess-py](https://github.com/PYangLab/SnapCCESS/tree/main/snapccess-py)
2532

33+
The Python package depends on PyTorch. GPU acceleration is optional and depends
34+
on the local PyTorch/CUDA or PyTorch/ROCm installation.
2635

27-
### R
36+
### R Wrapper
2837

38+
```r
39+
remotes::install_github(
40+
repo = "PYangLab/SnapCCESS",
41+
branch = "main",
42+
subdir = "snapccess-r/SnapCCESS"
43+
)
2944
```
30-
remotes::install_github(repo='PYangLab/SnapCCESS',branch='main',subdir='snapccess-r/SnapCCESS')
45+
46+
After installing the R wrapper, install the Python package into a reticulate
47+
environment:
48+
49+
```r
50+
SnapCCESS::install_SnapCCESS(envname = "SnapCCESS", method = "conda")
3151
```
3252

33-
For detailed description of each function, please see [https://github.com/PYangLab/SnapCCESS/tree/main/snapccess-r](https://github.com/PYangLab/SnapCCESS/tree/main/snapccess-r)
53+
If Python dependencies are already managed through Conda, virtualenv, or a
54+
cluster module, configure `reticulate` to use that environment before loading
55+
the R wrapper.
56+
57+
## Input Data
3458

59+
SnapCCESS expects a list of modalities measured across the same cells, for
60+
example RNA and ADT matrices from CITE-seq. Each modality should be arranged as
61+
features by cells before preprocessing in the R wrapper. The Python API expects
62+
the combined PyTorch data loader used by the training routine.
3563

36-
## [Tutorial](https://github.com/PYangLab/SnapCCESS/tree/main/tutorials)
37-
### NOTE: This tutorial only explains how to use this package; it doesn't recommend the best parameters for your datasets. For the datasets used in the published paper associated with this package, the parameters are listed in the same paper. Please refer to the paper to guide you in finding the best parameters.
64+
The tutorial data in `tutorials/in/` includes small CITE-seq RNA, ADT, and cell
65+
type files that can be used to run the examples.
3866

67+
## Tutorials
3968

40-
For python version of script, please see [an_example_of_generate_embedding_using_SnapCCESS_python_version](https://github.com/PYangLab/SnapCCESS/blob/main/tutorials/src/an_example_of_generate_embedding_using_SnapCCESS_python_version.ipynb)
69+
- Python example:
70+
[`tutorials/src/an_example_of_generate_embedding_using_SnapCCESS_python_version.ipynb`](tutorials/src/an_example_of_generate_embedding_using_SnapCCESS_python_version.ipynb)
71+
- R example:
72+
[`tutorials/src/SnapCCESS_R_example.html`](tutorials/src/SnapCCESS_R_example.html)
73+
- Tutorial overview:
74+
[`tutorials/README.md`](tutorials/README.md)
75+
76+
The tutorials demonstrate package usage. The best hyperparameters can vary by
77+
dataset; for the datasets used in the publication, refer to the paper.
78+
79+
## Citation
80+
81+
If you use SnapCCESS, please cite:
82+
83+
```bibtex
84+
@article{Yu2023SnapCCESS,
85+
title = {Ensemble deep learning of embeddings for clustering multimodal single-cell omics data},
86+
author = {Yu, Lijia and Liu, Chunlei and Yang, Jean Yee Hwa and Yang, Pengyi},
87+
journal = {Bioinformatics},
88+
year = {2023},
89+
volume = {39},
90+
number = {6},
91+
pages = {btad382},
92+
doi = {10.1093/bioinformatics/btad382},
93+
url = {https://doi.org/10.1093/bioinformatics/btad382}
94+
}
95+
```
4196

42-
For R version of script, please see
43-
[SnapCCESS_R_example](https://htmlpreview.github.io/?https://github.com/PYangLab/SnapCCESS/blob/main/tutorials/src/SnapCCESS_R_example.html)
97+
## License
4498

45-
## References
46-
Lijia Yu, Chunlei Liu, Jean Yee Hwa Yang, Pengyi Yang. Ensemble deep learning of embeddings for clustering multimodal single-cell omics data. *Bioinformatics*, 39(6), btad382, doi: [https://doi.org/10.1093/bioinformatics/btad382](https://doi.org/10.1093/bioinformatics/btad382), (2023).
99+
SnapCCESS is distributed under the GPL-3 license.

snapccess-py/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Change Log
2+
3+
## 2024-07-26
4+
5+
- Updated the PyTorch dependency version to pass GitHub security checks.

snapccess-py/README.md

Lines changed: 57 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,93 @@
1-
## SnapCCESS
2-
3-
A python package to generate ensemble deep learning of embeddings for clustering multimodal single-cell omics data
1+
# snapccess
42

3+
Python implementation of SnapCCESS, an ensemble deep learning framework for
4+
learning multimodal single-cell embeddings for downstream clustering.
55

66
## Installation
77

8-
### Stable version
8+
```bash
9+
pip install snapccess --index-url https://pypi.org/simple
910
```
10-
pip install snapccess --index-url https://pypi.org/simple
11-
```
12-
13-
https://pypi.org/project/snapccess/
1411

12+
Development builds, when available, can be installed from TestPyPI:
1513

16-
### Development version
14+
```bash
15+
pip install snapccess --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple
1716
```
18-
pip install snapccess --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple
19-
```
20-
21-
https://test.pypi.org/project/snapccess/
22-
2317

24-
## The functions in this package are described below.
18+
## Main Functions
2519

26-
### snapshotVAE
20+
### `snapshotVAE`
2721

28-
#### Description
22+
Create the multimodal variational autoencoder model.
2923

30-
To create the VAE model
24+
```python
25+
from snapccess.model import snapshotVAE
3126

32-
#### Usage
33-
34-
```
35-
model = snapshotVAE(num_features=[nfeatures_rna,nfeatures_pro], num_hidden_features=[hidden_rna2,hidden_pro2], z_dim=z_dim)
27+
model = snapshotVAE(
28+
num_features=[nfeatures_rna, nfeatures_protein],
29+
num_hidden_features=[hidden_rna, hidden_protein],
30+
z_dim=100,
31+
)
3632
```
3733

38-
#### Arguments
39-
40-
- num_features: a list of number of features of each modality
41-
- num_hidden_features: the number of hidden features we will used in training the model, in our paper, we use `hidden_rna=185`, and `hidden_pro=30`
42-
- z_dim: dimension of the latent space, in our paper, we use `z_dim=100`
43-
44-
45-
#### Output
34+
### `train_model`
4635

47-
A VAE model
36+
Train a VAE with either snapshot learning-rate cycles or a constant learning
37+
rate.
4838

39+
```python
40+
from snapccess.train import train_model
4941

50-
----------------------
51-
52-
### train_model
53-
54-
#### Description
55-
56-
Training a VAE model with Snapshot learning rate or constant learning rate
57-
58-
59-
#### Usage
60-
42+
model, history, embeddings = train_model(
43+
model,
44+
train_dl,
45+
valid_dl,
46+
lr=0.02,
47+
epochs=50,
48+
epochs_per_cycle=2,
49+
save_path="",
50+
snapshot=True,
51+
)
6152
```
62-
model,histroy,embedding = train_model(model, train_dl, valid_dl, lr=lr, epochs=epochs,epochs_per_cycle=epochs_per_cycle, save_path=\"\",snapshot=True,embedding_number=1)
63-
```
64-
65-
#### Arguments
6653

67-
- model: a vae model
68-
- train_dl: training dataset
69-
- valid_dl: validation dataset
70-
- lr: initial learning rate
71-
- epochs: total number of train cycles for snapshot ensemble vae
72-
- epochs_per_cycle: the number of epochs per cycle
73-
- save_path: the output file path of embeddings, by default leave it blank will not save any embeddings into the `save_path`, but the `train_model` will return the embeddings
74-
- snapshot: a boolean value to indicate the model whether to use the snapshot ensemble method or the traditional VAE method (with constant learning rate)
75-
- embeddings_number: a value to indicate the index of embeddings in the output filename when apply the traditional VAE
54+
The function returns the trained model, training/validation loss history, and a
55+
list of latent-space embeddings. When `save_path` is provided, embeddings are
56+
also written as gzip-compressed CSV files.
7657

58+
### `get_encodings`
7759

78-
#### Output
60+
Return embeddings from a trained model.
7961

80-
This function will return the model, the loss of training and validation dataset (history) and a list of the latent space embeddings (for Snapshot ensemble method) or a single embedding for traditional VAE method.
81-
82-
83-
-------------------
84-
85-
### get_encodings
86-
87-
#### Description
88-
89-
To get the embeddings from model after training.
90-
91-
#### Usage
62+
```python
63+
from snapccess.util import get_encodings
9264

65+
embedding = get_encodings(model, valid_dl)
9366
```
94-
embedding = get_encodings(model,valid_dl)
95-
```
96-
9767

98-
#### Arguments
68+
Convert the result to a pandas data frame with:
9969

100-
- model: a VAE model
101-
- valid_dl: the dataset that used as input to training the VAE model
70+
```python
71+
import pandas as pd
10272

103-
#### Output
104-
105-
Embedding of the `valid_dl` dataset in the VAE model, to convert it to a matrix, try `pd.DataFrame(embedding.cpu().numpy())`
106-
107-
108-
-------------------
109-
110-
### nvidia_info
73+
embedding_df = pd.DataFrame(embedding.cpu().numpy())
74+
```
11175

112-
#### Description
76+
### `nvidia_info`
11377

114-
To monitor the memory usage of GPU
78+
Monitor GPU memory usage for a process when NVIDIA drivers and `pynvml` are
79+
available.
11580

116-
#### Usage
81+
```python
82+
from snapccess.util import nvidia_info
11783

84+
memory = nvidia_info(pid)["memory"]
11885
```
119-
memory = nvidia_info(pid)['memory']
120-
```
121-
122-
#### Arguments
123-
124-
- pid: the pid of running script
12586

87+
## Citation
12688

127-
#### Output
89+
If you use SnapCCESS, please cite:
12890

129-
This function will return the memory usage of the pid process.
91+
Yu, L., Liu, C., Yang, J. Y. H. & Yang, P. Ensemble deep learning of embeddings
92+
for clustering multimodal single-cell omics data. *Bioinformatics* 39(6),
93+
btad382 (2023). <https://doi.org/10.1093/bioinformatics/btad382>

snapccess-py/pyproject.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
[tool.poetry]
2-
name = "SnapCCESS"
2+
name = "snapccess"
33
version = "0.2.2"
44
description = "Ensemble deep learning of embeddings for clustering multimodal single-cell omics data"
5-
authors = ["Lijia Yu <[email protected]>"]
5+
authors = [
6+
"Lijia Yu <[email protected]>",
7+
"Chunlei Liu",
8+
"Jean Yee Hwa Yang",
9+
"Pengyi Yang <[email protected]>"
10+
]
11+
license = "GPL-3.0-only"
612
readme = "README.md"
13+
repository = "https://github.com/PYangLab/SnapCCESS"
14+
homepage = "https://github.com/PYangLab/SnapCCESS"
15+
keywords = ["single-cell", "multimodal", "clustering", "deep-learning", "vae"]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Science/Research",
19+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
20+
"Programming Language :: Python :: 3",
21+
"Topic :: Scientific/Engineering :: Bio-Informatics",
22+
]
723

824
[tool.poetry.dependencies]
925
python = ">=3.8"
@@ -13,7 +29,7 @@ torch = ">=2.2.0"
1329
pynvml = ">=11.4.1"
1430

1531
[project.urls]
16-
Changelog = "https://github.com/PYangLab/SnapCCESS/CHANGES.md"
32+
Changelog = "https://github.com/PYangLab/SnapCCESS/blob/main/CHANGES.md"
1733
Homepage = "https://github.com/PYangLab/SnapCCESS"
1834

1935
[tool.hatch.metadata.hooks.fancy-pypi-readme]

snapccess-py/snapccess/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.0'
1+
__version__ = "0.2.2"

0 commit comments

Comments
 (0)