Skip to main content

comparative embedding visualization

Project description

Comparative Embedding Visualization with cev

pypi version pypi version build status notebook examples ISMB BioVis 2023 Poster

cev is an interactive Jupyter widget for comparing a pair of 2D embeddings with shared labels.
Its novel metric allows to surface differences in label confusion, neighborhood composition, and label size.


Teaser

The figure shows data from Mair et al. (2022) that were analyzed with Greene et al.'s (2021) FAUST method.
The embeddings were generated with Greene et al.'s (2021) annotation transformation and UMAP.


cev is implemented with anywidget and builds upon jupyter-scatter.

Installation

Warning: cev is new and under active development. It is not yet ready for production and APIs are subject to change.

pip install cev

Getting Started

import pandas as pd
from cev.widgets import Embedding, EmbeddingComparisonWidget

umap_embedding = Embedding.from_ozette(df=pd.read_parquet("../data/mair-2022-tissue-138-umap.pq"))
ozette_embedding = Embedding.from_ozette(df=pd.read_parquet("../data/mair-2022-tissue-138-ozette.pq"))

umap_vs_ozette = EmbeddingComparisonWidget(
    umap_embedding,
    ozette_embedding,
    titles=["Standard UMAP", "Annotation-Transformed UMAP"],
    metric="confusion",
    selection="synced",
    auto_zoom=True,
    row_height=320,
)
umap_vs_ozette
User interface of cev's comparison widget

See notebooks/getting-started.ipynb for the complete example.

Development

First, create a virtual environment with all the required dependencies. We highly recommend to use hatch, which installs and sync all dependencies from pyproject.toml automatically.

hatch shell

Alternatively, you can also use conda.

conda env create -n cev python=3.11
conda activate cev

Next, install cev with all development assets.

pip install -e ".[notebooks,dev]"

Finally, you can now run the notebooks with:

jupyterlab

Commands Cheatsheet

If using hatch CLI, the following commands are available in the default environment:

Command Action
hatch run fix Format project with black . and apply linting with ruff --fix .
hatch run fmt Format project with black . and apply linting with ruff --fix .
hatch run check Check formatting and linting with black --check . and ruff ..
hatch run test Run unittests with pytest in base environment.
hatch run test:test Run unittests with pytest in all supported environments.

Alternatively, you can devlop cev by manually creating a virtual environment and managing dependencies with pip.

Our CI linting/formatting checks are configured with pre-commit. We recommend installing the git hook scripts to allow pre-commit to run automatically on git commit.

pre-commit install # run this once to install the git hooks

This will ensure that code pushed to CI meets our linting and formatting criteria. Code that does not comply will fail in CI.

Release

releases are triggered via tagged commits

git tag -a vX.X.X -m "vX.X.X"
git push --follow-tags

License

cev is distributed under the terms of the Apache License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cev-0.2.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

cev-0.2.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file cev-0.2.1.tar.gz.

File metadata

  • Download URL: cev-0.2.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for cev-0.2.1.tar.gz
Algorithm Hash digest
SHA256 736b677ee47c3be701eacd064a1fffe3a5d0b25a4062932667a9085f769b5626
MD5 35f503716a2e45ec98eb265629246952
BLAKE2b-256 d932bff78ef9957bf140a42edf7ba81f430fcc108e614f3392402df73c1b7897

See more details on using hashes here.

File details

Details for the file cev-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cev-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for cev-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e7a1d31fb6b49b382d1c7210fc30a9db26cabdb79546d59857628f37ec60663
MD5 3f186d42d930ac82e32a22b898ea3f1d
BLAKE2b-256 c857e772d8b161212970ecb5e19e9377068fdb5471424389b5da8040deb1197d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page