Skip to content

An AnnData accessor powered by Narwhals to perform DataFrame-style selection, filtering and group by operations on AnnData Objects.

License

Notifications You must be signed in to change notification settings

srivarra/annsel

Repository files navigation

annsel

Status Build Tests Documentation codecov pre-commit
Meta Hatch project Ruff uv License gitmoji
Package PyPI PyPI

Annsel is a user-friendly library that brings familiar dataframe-style operations to AnnData objects.

It's built on the narwhals compatibility layer for dataframes.

Take a look at the GitHub Projects board for features and future plans: Annsel Features

Getting started

Please refer to the documentation, in particular, the API documentation.

Installation

You need to have Python 3.10 or newer installed on your system. If you don't have Python installed, we recommend installing uv. There are several ways to install annsel:

  1. Install the most recent release:

    With uv:

    uv add annsel

    With pip:

    pip install annsel
  2. Install the latest development version:

    With uv:

    uv add git+https://github.com/srivarra/annsel

    With pip:

    pip install git+https://github.com/srivarra/annsel.git@main

Examples

import annsel as an

adata=an.datasets.leukemic_bone_marrow_dataset()

Filter

adata.an.filter(
    obs=(
        an.col(["Cell_label"]).is_in(["Classical Monocytes", "CD8+CD103+ tissue resident memory T cells"]),
        an.col(["sex"]) == "male",
    ),
    var=an.col(["vst.mean"]) >= 3,
)

Select

adata.an.select(
    obs=an.col(["Cell_label"]),
    var=an.col(["vst.mean", "vst.std"]),
)

Group By

adata.an.group_by(
    obs=an.col(["Cell_label"]),
    var=an.col(["feature_type"]),
    return_group_names=True,
)

Release notes

See the changelog.

Contact

For questions and help requests, you can reach out in the scverse discourse or the discussions tab. If you found a bug, please use the issue tracker.

Citation

Varra, S. R. annsel [Computer software]. https://github.com/srivarra/annsel

About

An AnnData accessor powered by Narwhals to perform DataFrame-style selection, filtering and group by operations on AnnData Objects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages