A tool for evalauting single-cell embeddings using graph-based relations
Project description
scgraph-eval
A tool for evaluating single-cell embeddings using graph-based relationships. This package helps analyze the consistency of cell type relationships across different batches in single-cell data.
Features
- Calculate trimmed means for cell type centroids
- Compute pairwise distances between cell types
- Process multiple batches to assess embedding consistency
- Support for both PCA and custom embeddings
- Built-in handling for highly variable genes (HVG)
- Option to analyze only 2D embeddings (like UMAP or t-SNE)
Installation
You can install the package via pip:
pip install scgraph-eval
Usage
Python API
from scgraph import scGraph
# Initialize the graph analyzer
scgraph = scGraph(
adata_path="path/to/your/data.h5ad", # Path to AnnData object
batch_key="batch", # Column name for batch information
label_key="cell_type", # Column name for cell type labels
trim_rate=0.05, # Trim rate for robust mean calculation
thres_batch=100, # Minimum number of cells per batch
thres_celltype=10 # Minimum number of cells per cell type
only_umap=True, # Only evaluate 2D embeddings (mostly umaps)
)
# Run the analysis, return a pandas dataframe
results = scgraph.main()
# Save the results
results.to_csv("embedding_evaluation_results.csv")
Command Line Interface
scgraph --adata_path path/to/data.h5ad --batch_key batch --label_key cell_type --savename results
Output
The package outputs comparison metrics between different embeddings:
- Rank-PCA: Spearman correlation with PCA-based relationships
- Corr-PCA: Pearson correlation with PCA-based relationships
- Corr-Weighted: Weighted correlation considering distance-based importance
How It Works
- For each batch, the tool calculates centroids for each cell type in the embedding space
- Pairwise distances between cell types are computed to establish relationship graphs
- A consensus relationship graph is derived by combining information across all batches
- Each embedding is evaluated by comparing its cell type relationships to the consensus
Requirements
- numpy
- pandas
- scanpy
- tqdm
- scipy
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this package in your research, please cite:
@article{wang2024metric, title={Metric mirages in cell embeddings}, author={Wang, Hanchen and Leskovec, Jure and Regev, Aviv}, journal={BioRxiv}, pages={2024--04}, year={2024}, publisher={Cold Spring Harbor Laboratory} }
Contact
For questions and feedback:
- Hanchen Wang
- Email: hanchen.wang.sc@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scgraph_eval-0.1.2.tar.gz.
File metadata
- Download URL: scgraph_eval-0.1.2.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80a041ce84ea76881661cf872bd151eef6f0c859440453e9f8945ab093acdefa
|
|
| MD5 |
6005394240786632026825af12ba152d
|
|
| BLAKE2b-256 |
fcbe53a721f841bdf6a5c5b3dac89c44411fca9c453b7bee3a603e40b0bf9f8b
|
File details
Details for the file scgraph_eval-0.1.2-py3-none-any.whl.
File metadata
- Download URL: scgraph_eval-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c171a8f5107f9582f2ebc47589e243e624f0e4aa1df58b697d7f53947e596704
|
|
| MD5 |
0c322141dcc080b33ff790b7959ff8cf
|
|
| BLAKE2b-256 |
5dfe3518f032bf6ae6ba0aa1f89d67c101746f42779bb634524f126765ae8659
|