annoyance - single-cell AnnData wrapper of Spotify's Annoy library.
Project description
annoy for the annotation of cell types.
Annoyance is a simple API for classifying cell types as annotated in an adata.obs
table. An example notebook may be found here.
Overview
import annoyance
from anndata import read_h5ad
# load data
adata = read_h5ad("./data/pbmc3k.processed.h5ad")
Step 1. Instantiate the model and split the data on categorical labels
annoy = annoyance.SpotifyAnnoy()
annoy.split_data(
adata, annot_col="Annotation", labels=["Monocyte", "Neutrophil"], on="X_pca"
)
label mask created:
CD4 T cells 1144
CD14+ Monocytes 480
B cells 342
CD8 T cells 316
NK cells 154
FCGR3A+ Monocytes 150
Dendritic cells 37
Megakaryocytes 15
Name: louvain, dtype: int64
Step 2. Build and evaluate the predictive model based on the data split
annoy.prebuild()
precision recall f1-score support
B cells 1.00 1.00 1.00 86
CD14+ Monocytes 0.94 0.99 0.97 120
CD4 T cells 0.98 0.98 0.98 286
CD8 T cells 0.91 0.91 0.91 79
Dendritic cells 1.00 0.67 0.80 9
FCGR3A+ Monocytes 0.95 0.95 0.95 37
Megakaryocytes 1.00 0.75 0.86 4
NK cells 0.97 0.95 0.96 39
accuracy 0.97 660
macro avg 0.97 0.90 0.93 660
weighted avg 0.97 0.97 0.96 660
Step 3. Build the classifier using all of the data then save the AnnoyIndex
.
annoy.build()
annoy.save()
Annoyance annoy index saved to:
annoyance_index/annoyance.annoy_idx.50_dims.20_neighbors.10_trees.ann
annoyance_index/annoyance.annoy_idx.50_dims.20_neighbors.10_trees.txt
Installation
pip install annoyance
To install the development version
git clone https://github.com/mvinyard/annoyance.git
cd ./annoyance/
pip install -e .
Notes
This project uses open-source code from spotify/annoy. However, this repo is in no way affiliated with Spotify.
Interested? Questions and discussion may be directed to Michael Vinyard at: mvinyard@broadinstitute.org.
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
annoyance-0.0.12.tar.gz
(8.8 kB
view hashes)
Built Distribution
annoyance-0.0.12-py3-none-any.whl
(10.6 kB
view hashes)
Close
Hashes for annoyance-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f6422408f65655e4ee38b117098d70846d314d49b3f74c9fb3c63b0b077dac7 |
|
MD5 | 4de86923b703e2b82015bc1fe0a36af3 |
|
BLAKE2b-256 | 185aace23913ee679338d408bd1cb1ba9b34e18b990770e09a7a5db76f2f28b7 |