Skip to main content

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

  1. For each batch, the tool calculates centroids for each cell type in the embedding space
  2. Pairwise distances between cell types are computed to establish relationship graphs
  3. A consensus relationship graph is derived by combining information across all batches
  4. 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:

Metadata

Release files for scgraph-eval 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scgraph-eval 0.1.2
File Size Uploaded Provenance Actions
scgraph_eval-0.1.2.tar.gz 7.3 kB Without provenance Details for scgraph_eval-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scgraph-eval 0.1.2
File Interpreter ABI Platform Actions
scgraph_eval-0.1.2-py3-none-any.whl Python 3 none any Details for scgraph_eval-0.1.2-py3-none-any.whl

Total release size: 15.1 kB

Release files / scgraph_eval-0.1.2.tar.gz

Download URL scgraph_eval-0.1.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
80a041ce84ea76881661cf872bd151eef6f0c859440453e9f8945ab093acdefa
BLAKE2b-256 checksum
How to use checksums
fcbe53a721f841bdf6a5c5b3dac89c44411fca9c453b7bee3a603e40b0bf9f8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.20

Release files / scgraph_eval-0.1.2-py3-none-any.whl

Download URL scgraph_eval-0.1.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c171a8f5107f9582f2ebc47589e243e624f0e4aa1df58b697d7f53947e596704
BLAKE2b-256 checksum
How to use checksums
5dfe3518f032bf6ae6ba0aa1f89d67c101746f42779bb634524f126765ae8659
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.20

Security for scgraph-eval 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page