diff --git a/README.md b/README.md index a316fcc..cab14ba 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,44 @@ # NichePCA +[![Version](https://img.shields.io/pypi/v/nichepca)](https://pypi.org/project/nichepca/) +[![License](https://img.shields.io/pypi/l/nichepca)](https://github.com/imsb-uke/nichepca) +[![Python Version Required](https://img.shields.io/pypi/pyversions/nichepca)](https://pypi.org/project/nichepca/) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) +[![PyPI downloads](https://img.shields.io/pepy/dt/nichepca?label=PyPI%20downloads&logo=pypi)](https://pepy.tech/project/nichepca) [![Tests][badge-tests]][link-tests] + [badge-tests]: https://img.shields.io/github/actions/workflow/status/imsb-uke/nichepca/test.yaml?branch=main [link-tests]: https://github.com/imsb-uke/nichepca/actions/workflows/test.yaml [badge-docs]: https://img.shields.io/readthedocs/nichepca -Package for PCA-based spatial domain identification in single-cell spatial transcriptomics data. The corresonding manuscript was published in [Bioinformatics](https://academic.oup.com/bioinformatics/article/41/1/btaf005/7945104?). +Package for PCA-based spatial domain identification in single-cell spatial transcriptomics data. The corresponding manuscript was published in [Bioinformatics](https://academic.oup.com/bioinformatics/article/41/1/btaf005/7945104?). + +## Installation + +You need to have Python 3.10 or newer installed on your system. If you don't have +Python installed, we recommend installing [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) or [Miniconda](https://docs.anaconda.com/miniconda/miniconda-install/). + +To create a new conda environment with Python 3.11: + +```bash +conda create -n npc-env python=3.11 -y +conda activate npc-env +``` + +NichePCA can be installed from PyPI: + +```bash +pip install nichepca +``` + +To install the latest development version: + +```bash +pip install git+https://github.com/imsb-uke/nichepca.git@main +``` ## Getting started @@ -55,25 +86,8 @@ or without `"pca"` at all: npc.wf.nichepca(adata, knn=25, pipeline=["norm", "log1p", "agg"]) ``` -## Setting parameters +## Hyperparameter choice We found that higher number of neighbors e.g., `knn=25` lead to better results in brain tissue, while `knn=10` works well for kidney data. We recommend to qualitatively optimize these parameters on a small subset of your data. The number of PCs (`n_comps=30` by default) seems to have negligible effect on the results. -## Installation - -You need to have Python 3.10 or newer installed on your system. If you don't have -Python installed, we recommend installing [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) or [Miniconda](https://docs.anaconda.com/miniconda/miniconda-install/). - -To create a new conda environment with Python 3.10: - -```bash -conda create -n npc-env python=3.10 -y -conda activate npc-env -``` - -Install the latest development version: - -```bash -pip install git+https://github.com/imsb-uke/nichepca.git@main -``` ## Contributing diff --git a/pyproject.toml b/pyproject.toml index 1caae08..929a791 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,14 @@ maintainers = [ urls.Documentation = "https://nichepca.readthedocs.io/" urls.Source = "https://github.com/imsb-uke/nichepca" urls.Home-page = "https://github.com/imsb-uke/nichepca" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] dependencies = [ "scanpy (>=1.11.4,<2.0.0)", "torch (>=2.8.0,<3.0.0)", diff --git a/src/nichepca/workflows/_nichepca.py b/src/nichepca/workflows/_nichepca.py index a83f12b..38cc304 100644 --- a/src/nichepca/workflows/_nichepca.py +++ b/src/nichepca/workflows/_nichepca.py @@ -32,6 +32,7 @@ def nichepca( aggr: str = "mean", allow_harmony: bool = True, max_iter_harmony: int = 50, + remove_graph: bool = False, **kwargs, ): """ @@ -67,6 +68,9 @@ def nichepca( Whether to allow Harmony integration. max_iter_harmony : int, optional Maximum number of iterations for Harmony. + remove_graph : bool, optional + Whether to remove the constructed graph from ``adata.uns`` after the workflow + completes. **kwargs : dict Additional keyword arguments. @@ -195,3 +199,6 @@ def nichepca( index=ad_tmp.var_names, columns=[f"PC{i}" for i in range(n_comps)], ) + + if remove_graph and "graph" in adata.uns: + del adata.uns["graph"] diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 57ebfcb..cb7549d 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -68,6 +68,11 @@ def test_nichepca_single(): assert np.all(X_npca_0 == X_npca_1) + # test graph removal + adata = generate_dummy_adata() + npc.wf.nichepca(adata, knn=5, pipeline=pipeline, remove_graph=True) + assert "graph" not in adata.uns + # test with pca on raw counts pipeline = ("pca", "agg")