scpviz 0.5.0a0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. scpviz-0.5.0a0/LICENSE +19 -0
  2. scpviz-0.5.0a0/PKG-INFO +98 -0
  3. scpviz-0.5.0a0/README.md +58 -0
  4. scpviz-0.5.0a0/pyproject.toml +56 -0
  5. scpviz-0.5.0a0/setup.cfg +4 -0
  6. scpviz-0.5.0a0/src/scpviz/TrackedDataFrame.py +86 -0
  7. scpviz-0.5.0a0/src/scpviz/__init__.py +23 -0
  8. scpviz-0.5.0a0/src/scpviz/enrichment.py +16 -0
  9. scpviz-0.5.0a0/src/scpviz/pAnnData/__init__.py +3 -0
  10. scpviz-0.5.0a0/src/scpviz/pAnnData/analysis.py +1447 -0
  11. scpviz-0.5.0a0/src/scpviz/pAnnData/base.py +95 -0
  12. scpviz-0.5.0a0/src/scpviz/pAnnData/editing.py +365 -0
  13. scpviz-0.5.0a0/src/scpviz/pAnnData/enrichment.py +865 -0
  14. scpviz-0.5.0a0/src/scpviz/pAnnData/filtering.py +1943 -0
  15. scpviz-0.5.0a0/src/scpviz/pAnnData/history.py +53 -0
  16. scpviz-0.5.0a0/src/scpviz/pAnnData/identifier.py +409 -0
  17. scpviz-0.5.0a0/src/scpviz/pAnnData/io.py +1287 -0
  18. scpviz-0.5.0a0/src/scpviz/pAnnData/metrics.py +135 -0
  19. scpviz-0.5.0a0/src/scpviz/pAnnData/pAnnData.py +287 -0
  20. scpviz-0.5.0a0/src/scpviz/pAnnData/plot.py +118 -0
  21. scpviz-0.5.0a0/src/scpviz/pAnnData/summary.py +200 -0
  22. scpviz-0.5.0a0/src/scpviz/pAnnData/validation.py +181 -0
  23. scpviz-0.5.0a0/src/scpviz/plotting.py +2485 -0
  24. scpviz-0.5.0a0/src/scpviz/setup.py +51 -0
  25. scpviz-0.5.0a0/src/scpviz/utils.py +1680 -0
  26. scpviz-0.5.0a0/src/scpviz.egg-info/PKG-INFO +98 -0
  27. scpviz-0.5.0a0/src/scpviz.egg-info/SOURCES.txt +38 -0
  28. scpviz-0.5.0a0/src/scpviz.egg-info/dependency_links.txt +1 -0
  29. scpviz-0.5.0a0/src/scpviz.egg-info/requires.txt +26 -0
  30. scpviz-0.5.0a0/src/scpviz.egg-info/top_level.txt +1 -0
  31. scpviz-0.5.0a0/tests/test_TrackedDataFrame.py +86 -0
  32. scpviz-0.5.0a0/tests/test_enrichment.py +306 -0
  33. scpviz-0.5.0a0/tests/test_pAnnData_analysis.py +819 -0
  34. scpviz-0.5.0a0/tests/test_pAnnData_base.py +168 -0
  35. scpviz-0.5.0a0/tests/test_pAnnData_editing.py +176 -0
  36. scpviz-0.5.0a0/tests/test_pAnnData_filtering.py +977 -0
  37. scpviz-0.5.0a0/tests/test_pAnnData_import.py +265 -0
  38. scpviz-0.5.0a0/tests/test_pAnnData_summary.py +48 -0
  39. scpviz-0.5.0a0/tests/test_plotting.py +894 -0
  40. scpviz-0.5.0a0/tests/test_utils.py +804 -0
scpviz-0.5.0a0/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.1
2
+ Name: scpviz
3
+ Version: 0.5.0a0
4
+ Summary: A package to visualize single cell proteomics (and more to come!) data
5
+ Author-email: Marion Pang <sr_pang@hotmail.com>
6
+ Project-URL: Homepage, https://github.com/gnaprs/scpviz
7
+ Project-URL: Issues, https://github.com/gnaprs/scpviz/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Requires-Dist: pandas
17
+ Requires-Dist: matplotlib
18
+ Requires-Dist: seaborn
19
+ Requires-Dist: upsetplot
20
+ Requires-Dist: scikit-learn
21
+ Requires-Dist: scipy
22
+ Requires-Dist: umap-learn
23
+ Requires-Dist: adjustText
24
+ Requires-Dist: anndata
25
+ Requires-Dist: requests
26
+ Requires-Dist: matplotlib_venn
27
+ Requires-Dist: pyarrow
28
+ Requires-Dist: scanpy
29
+ Requires-Dist: IPython
30
+ Requires-Dist: igraph
31
+ Requires-Dist: harmonypy
32
+ Requires-Dist: leidenalg
33
+ Requires-Dist: scikit-misc
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest; extra == "dev"
36
+ Requires-Dist: coverage; extra == "dev"
37
+ Requires-Dist: flake8; extra == "dev"
38
+ Requires-Dist: openpyxl; extra == "dev"
39
+ Requires-Dist: pytest-cov; extra == "dev"
40
+
41
+ # scpviz
42
+ <img src="https://raw.githubusercontent.com/gnaprs/scpviz/refs/heads/main/docs/assets/300ppi/logo_white_label@300x.png"
43
+ align="right" width="256"/>
44
+ [![DOI](https://zenodo.org/badge/762480088.svg)](https://doi.org/10.5281/zenodo.17362532)
45
+
46
+ **Build & Tests:**
47
+ [![Build Status](https://github.com/gnaprs/scpviz/actions/workflows/python-package.yml/badge.svg)](https://github.com/gnaprs/scpviz/actions/workflows/python-package.yml)
48
+ [![codecov](https://codecov.io/gh/gnaprs/scpviz/branch/main/graph/badge.svg)](https://codecov.io/gh/gnaprs/scpviz)
49
+
50
+ **Documentation:**
51
+ [![Docs CI](https://github.com/gnaprs/scpviz/actions/workflows/ci.yml/badge.svg)](https://github.com/gnaprs/scpviz/actions/workflows/ci.yml)
52
+ [![Docs](https://img.shields.io/badge/docs-v0.3.0-brightgreen.svg)](https://gnaprs.github.io/scpviz)
53
+
54
+
55
+ **scpviz** is a Python package for single-cell and spatial proteomics data analysis, built around a custom `pAnnData` object.
56
+ It extends the [AnnData](https://anndata.readthedocs.io/) ecosystem with proteomics-specific functionality, enabling seamless integration of proteins, peptides, and relational data.
57
+
58
+ * **Documentation**: https://gnaprs.github.io/scpviz/
59
+ * **Conda**: https://anaconda.org/gnaprs/scpviz (FIX)
60
+ * **Python Package Index (PyPI)**: https://pypi.org/project/scpviz/
61
+
62
+ ## Getting started
63
+ ### Installation
64
+
65
+ `scpviz` requires Python 3.8 or later. It is distributed as a Python package and can be installed with `pip`.
66
+
67
+ python3 -m pip install scpviz
68
+
69
+ This will install all required dependencies, including `scanpy`, `anndata`, `pandas`, and common plotting libraries.
70
+
71
+ Alternatively, scpviz is available on Conda:
72
+
73
+ conda install gnaprs::scpviz
74
+
75
+ For the most up-to-date version of scpviz, clone the repository and
76
+ install the package using pip:
77
+
78
+ conda create -n scpviz python=3.8 numpy pandas pip
79
+ conda activate scpviz
80
+ pip install git+https://github.com/gnaprs/scpviz.git@development
81
+
82
+ ### Quickstart
83
+
84
+ Check out the [quickstart](https://gnaprs.github.io/scpviz/tutorials/quickstart/) guide for a run through import, basic preprocessing and quick visualization
85
+
86
+ ### In-depth Tutorials
87
+ For more in-depth guides on importing, filtering, plotting, and running enrichment, see the [tutorials](https://gnaprs.github.io/scpviz/tutorials/).
88
+
89
+ ### API Reference
90
+
91
+ Full function documentation for the `pAnnData` class and utility modules can be found on our [documentation page](https://gnaprs.github.io/scpviz/reference/).
92
+
93
+ ## Contributing
94
+
95
+ If you'll like to contribute to `scpviz`, please see the [contributing guidelines](https://gnaprs.github.io/scpviz/dev/contributing/). We welcome contributions from the community to help improve, expand, and document the functionality of scpviz.
96
+
97
+ ## License
98
+ `scpviz` was created by Marion Pang. It is licensed under the terms of the MIT license.
@@ -0,0 +1,58 @@
1
+ # scpviz
2
+ <img src="https://raw.githubusercontent.com/gnaprs/scpviz/refs/heads/main/docs/assets/300ppi/logo_white_label@300x.png"
3
+ align="right" width="256"/>
4
+ [![DOI](https://zenodo.org/badge/762480088.svg)](https://doi.org/10.5281/zenodo.17362532)
5
+
6
+ **Build & Tests:**
7
+ [![Build Status](https://github.com/gnaprs/scpviz/actions/workflows/python-package.yml/badge.svg)](https://github.com/gnaprs/scpviz/actions/workflows/python-package.yml)
8
+ [![codecov](https://codecov.io/gh/gnaprs/scpviz/branch/main/graph/badge.svg)](https://codecov.io/gh/gnaprs/scpviz)
9
+
10
+ **Documentation:**
11
+ [![Docs CI](https://github.com/gnaprs/scpviz/actions/workflows/ci.yml/badge.svg)](https://github.com/gnaprs/scpviz/actions/workflows/ci.yml)
12
+ [![Docs](https://img.shields.io/badge/docs-v0.3.0-brightgreen.svg)](https://gnaprs.github.io/scpviz)
13
+
14
+
15
+ **scpviz** is a Python package for single-cell and spatial proteomics data analysis, built around a custom `pAnnData` object.
16
+ It extends the [AnnData](https://anndata.readthedocs.io/) ecosystem with proteomics-specific functionality, enabling seamless integration of proteins, peptides, and relational data.
17
+
18
+ * **Documentation**: https://gnaprs.github.io/scpviz/
19
+ * **Conda**: https://anaconda.org/gnaprs/scpviz (FIX)
20
+ * **Python Package Index (PyPI)**: https://pypi.org/project/scpviz/
21
+
22
+ ## Getting started
23
+ ### Installation
24
+
25
+ `scpviz` requires Python 3.8 or later. It is distributed as a Python package and can be installed with `pip`.
26
+
27
+ python3 -m pip install scpviz
28
+
29
+ This will install all required dependencies, including `scanpy`, `anndata`, `pandas`, and common plotting libraries.
30
+
31
+ Alternatively, scpviz is available on Conda:
32
+
33
+ conda install gnaprs::scpviz
34
+
35
+ For the most up-to-date version of scpviz, clone the repository and
36
+ install the package using pip:
37
+
38
+ conda create -n scpviz python=3.8 numpy pandas pip
39
+ conda activate scpviz
40
+ pip install git+https://github.com/gnaprs/scpviz.git@development
41
+
42
+ ### Quickstart
43
+
44
+ Check out the [quickstart](https://gnaprs.github.io/scpviz/tutorials/quickstart/) guide for a run through import, basic preprocessing and quick visualization
45
+
46
+ ### In-depth Tutorials
47
+ For more in-depth guides on importing, filtering, plotting, and running enrichment, see the [tutorials](https://gnaprs.github.io/scpviz/tutorials/).
48
+
49
+ ### API Reference
50
+
51
+ Full function documentation for the `pAnnData` class and utility modules can be found on our [documentation page](https://gnaprs.github.io/scpviz/reference/).
52
+
53
+ ## Contributing
54
+
55
+ If you'll like to contribute to `scpviz`, please see the [contributing guidelines](https://gnaprs.github.io/scpviz/dev/contributing/). We welcome contributions from the community to help improve, expand, and document the functionality of scpviz.
56
+
57
+ ## License
58
+ `scpviz` was created by Marion Pang. It is licensed under the terms of the MIT license.
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scpviz"
7
+ version = "0.5.0-alpha"
8
+ authors = [
9
+ {name="Marion Pang", email="sr_pang@hotmail.com"},
10
+ ]
11
+ description = "A package to visualize single cell proteomics (and more to come!) data"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Development Status :: 3 - Alpha",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+ dependencies = [
21
+ "numpy",
22
+ "pandas",
23
+ "matplotlib",
24
+ "seaborn",
25
+ "upsetplot",
26
+ "scikit-learn",
27
+ "scipy",
28
+ "umap-learn",
29
+ "adjustText",
30
+ "anndata",
31
+ "requests",
32
+ "matplotlib_venn",
33
+ "pyarrow",
34
+ "scanpy",
35
+ "IPython",
36
+ "igraph",
37
+ "harmonypy",
38
+ "leidenalg",
39
+ "scikit-misc"
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/gnaprs/scpviz"
44
+ Issues = "https://github.com/gnaprs/scpviz/issues"
45
+
46
+ [tool.pytest.ini_options]
47
+ pythonpath = [
48
+ "."
49
+ ]
50
+ filterwarnings = [
51
+ "ignore::DeprecationWarning:jupyter_client.connect",
52
+ "ignore::DeprecationWarning:upsetplot.plotting"
53
+ ]
54
+
55
+ [project.optional-dependencies]
56
+ dev = ["pytest","coverage","flake8","openpyxl","pytest-cov"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,86 @@
1
+ import pandas as pd
2
+
3
+ class TrackedDataFrame(pd.DataFrame):
4
+ """
5
+ A subclass of :class:`pandas.DataFrame` that integrates with a parent
6
+ :class:`pAnnData` object to track when derived tables (e.g., `.summary`)
7
+ have been modified outside the canonical workflow.
8
+
9
+ Any in-place modifications automatically mark the parent object as "stale"
10
+ using the provided callback (`mark_stale_fn`). This ensures downstream
11
+ code can detect unsynchronized changes and prompt recomputation if needed.
12
+
13
+ Attributes:
14
+ _parent (pAnnData): The parent object associated with this DataFrame.
15
+ _mark_stale_fn (callable): Function called when the DataFrame is modified.
16
+ _raw_loc, _raw_iloc: Direct accessors for untracked indexing (safe use).
17
+
18
+ !!! warning "Internal Utility"
19
+ `TrackedDataFrame` is primarily intended for internal use within `pAnnData`.
20
+ Direct use in analysis code is not recommended, as stale-tracking may
21
+ interfere with expected pandas behaviors.
22
+
23
+ !!! tip
24
+ Use `.raw_loc` and `.raw_iloc` to bypass stale-marking when read-only
25
+ access is explicitly desired.
26
+
27
+ """
28
+ _metadata = ["_parent", "_mark_stale_fn"]
29
+
30
+ @property
31
+ def _constructor(self):
32
+ return TrackedDataFrame
33
+
34
+ def __new__(cls, *args, **kwargs):
35
+ return super().__new__(cls)
36
+
37
+ def __init__(self, *args, parent=None, mark_stale_fn=None, **kwargs):
38
+ super().__init__(*args, **kwargs)
39
+ self._parent = parent
40
+ self._mark_stale_fn = mark_stale_fn
41
+ # Bind raw .loc/.iloc for safe use
42
+ self._raw_loc = super().loc
43
+ self._raw_iloc = super().iloc
44
+
45
+ def __repr__(self):
46
+ base = super().__repr__()
47
+ stale_msg = ""
48
+ if getattr(self, "_mark_stale_fn", None) and getattr(self._parent, "_summary_is_stale", False):
49
+ stale_msg = "\n⚠️ [TrackedDataFrame] This summary has been modified and is not synced back to .obs."
50
+ return base + stale_msg
51
+
52
+ def _mark_stale(self):
53
+ """
54
+ Mark the parent pAnnData object as stale.
55
+
56
+ Called internally before any modifying operations (e.g. `__setitem__`,
57
+ `drop`, `assign`). Triggers the parent’s `_mark_stale_fn` if provided.
58
+ """
59
+ if self._mark_stale_fn is not None:
60
+ self._mark_stale_fn()
61
+
62
+ def __setitem__(self, key, value):
63
+ self._mark_stale()
64
+ return super().__setitem__(key, value)
65
+
66
+ def drop(self, *args, **kwargs):
67
+ self._mark_stale()
68
+ return super().drop(*args, **kwargs)
69
+
70
+ def assign(self, *args, **kwargs):
71
+ self._mark_stale()
72
+ return super().assign(*args, **kwargs)
73
+
74
+ def pop(self, *args, **kwargs):
75
+ self._mark_stale()
76
+ return super().pop(*args, **kwargs)
77
+
78
+ @property
79
+ def loc(self):
80
+ self._mark_stale()
81
+ return super().loc
82
+
83
+ @property
84
+ def iloc(self):
85
+ self._mark_stale()
86
+ return super().iloc
@@ -0,0 +1,23 @@
1
+ import pandas as pd
2
+ import numpy as np
3
+ import re
4
+
5
+ import matplotlib.pyplot as plt
6
+ import matplotlib.patches as mpatches
7
+ import matplotlib.colors as mcolors
8
+ from matplotlib.colors import TwoSlopeNorm
9
+ from matplotlib.ticker import MaxNLocator
10
+ import matplotlib.collections as clt
11
+ from upsetplot import plot, generate_counts, from_contents, query, UpSet
12
+ import seaborn as sns
13
+ sns.set_theme(context='paper', style='ticks')
14
+
15
+ from sklearn.decomposition import PCA
16
+ from scipy.stats import ttest_ind
17
+ from decimal import Decimal
18
+
19
+ from .pAnnData import pAnnData # imports the class
20
+ __all__ = ["pAnnData"]
21
+
22
+ import warnings
23
+ warnings.filterwarnings('ignore')
@@ -0,0 +1,16 @@
1
+ # scpviz/enrichment.py
2
+
3
+ """
4
+ Shim module to expose enrichment functions at top-level `scpviz.enrichment`.
5
+ Delegates to `scpviz.pAnnData.enrichment`.
6
+ """
7
+
8
+ from scpviz.pAnnData.enrichment import (
9
+ enrichment_functional,
10
+ enrichment_ppi,
11
+ _resolve_de_key,
12
+ _pretty_vs_key,
13
+ EnrichmentMixin,
14
+ )
15
+
16
+ import requests # so patch("scpviz.enrichment.requests.post") still works
@@ -0,0 +1,3 @@
1
+ from .pAnnData import pAnnData # expose the main class
2
+
3
+ __all__ = ["pAnnData"]