Skip to content

Commit 82798e3

Browse files
authored
Merge pull request #157 from settylab/main
v1.4.0
2 parents e7f0093 + bb5ab54 commit 82798e3

37 files changed

+4183
-534
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.9", "3.10", "3.11"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2020

2121
steps:
2222
- uses: actions/checkout@v3
@@ -27,8 +27,9 @@ jobs:
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
30-
python -m pip install .[dev]
30+
python -m pip install flake8 pytest pytest-cov coverage typing-extensions
3131
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32+
python -m pip install -e .
3233
- name: Lint with flake8
3334
run: |
3435
# stop the build if there are Python syntax errors or undefined names
@@ -39,6 +40,6 @@ jobs:
3940
env:
4041
PYTHONPATH: ./src/
4142
run: |
42-
coverage run --source=src/palantir/ -m pytest tests/*.py
43+
python -m pytest --cov=src/palantir
4344
- name: Upload coverage reports to Codecov
4445
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ __pycache__/
44
*.h5ad
55
build/
66
palantir.egg-info/
7-
.coverage
7+
.coverage*
88
notebooks/testing.ipynb
9+
.pytest_cache/
910
dist/
1011
.vscode/
1112
data/
12-
venv/

README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ here: https://palantir.readthedocs.io
5151
- [Replicate 2 (Rep2)](https://s3.amazonaws.com/dp-lab-data-public/palantir/human_cd34_bm_rep2.h5ad)
5252
- [Replicate 3 (Rep3)](https://s3.amazonaws.com/dp-lab-data-public/palantir/human_cd34_bm_rep3.h5ad)
5353

54-
This notebook details how to use the data in `Python` and `R`:
55-
https://github.com/dpeerlab/Palantir/blob/master/notebooks/manuscript_data.ipynb
54+
This notebook details how to use the data in `Python` and `R`: http://nbviewer.jupyter.org/github/dpeerlab/Palantir/blob/master/notebooks/manuscript_data.ipynb
5655

5756
## Comparison to trajectory detection algorithms
5857
Notebooks detailing the generation of results comparing Palantir to trajectory detection algorithms are available [here](https://github.com/dpeerlab/Palantir/blob/master/notebooks/comparisons)
@@ -73,6 +72,24 @@ ____
7372

7473
Release Notes
7574
-------------
75+
### Version 1.4.0
76+
* Made pygam an optional dependency that can be installed with `pip install palantir[gam]` or `pip install palantir[full]`
77+
* Added proper conditional imports and improved error handling for pygam
78+
* Enhanced `run_magic_imputation` to return appropriate data types for different inputs
79+
* Updated code to use direct AnnData imports for newer compatibility
80+
* Improved version detection using `importlib.metadata` with graceful fallbacks
81+
* Fixed Series indexing deprecation warnings in early cell detection functions
82+
* Expanded and standardized documentation with NumPy-style docstrings throughout the codebase
83+
* Added comprehensive type hints to improve code quality and IDE support
84+
* Remove dependency from `_` methods in scanpy for plotting.
85+
86+
#### Testing and Quality Improvements
87+
* Added comprehensive tests for optional pygam dependency
88+
* Improved test coverage for run_magic_imputation with various input/output types
89+
* Added integration tests against expected results
90+
* Enhanced test infrastructure to work with newer library versions
91+
* Expanded test coverage to catch edge cases in data processing
92+
7693
### Version 1.3.6
7794
* `run_magic_imputation` now has a boolean parameter `sparse` to control output sparsity
7895
* **bugfix**: `run_local_variability` for dense expression arrays now runs much faster and more accurate
@@ -88,15 +105,15 @@ Release Notes
88105
* compatibility with `scanpy>=1.10.0`
89106

90107
### Version 1.3.2
91-
* require `python>=3.8`
108+
* require `python>=3.9`
92109
* implement CI for testing
93-
* fixes for edge cases discoverd through extended testing
110+
* fixes for edge cases discovered through extended testing
94111
* implement `plot_trajectory` function to show trajectory on the umap
95-
* scale pseudotime to unit intervall in anndata
112+
* scale pseudotime to unit interval in anndata
96113

97114
### Version 1.3.1
98-
* implemented `palantir.plot.plot_stats` to plot arbitray cell-wise statistics as x-/y-positions.
99-
* reduce memory usgae of `palantir.presults.compute_gene_trends`
115+
* implemented `palantir.plot.plot_stats` to plot arbitrary cell-wise statistics as x-/y-positions.
116+
* reduce memory usage of `palantir.presults.compute_gene_trends`
100117
* removed seaborn dependency
101118
* refactor `run_diffusion_maps` to split out `compute_kernel` and `diffusion_maps_from_kernel`
102119
* remove unused dependencies `tables`, `Cython`, `cmake`, and `tzlocal`.
@@ -107,49 +124,49 @@ Release Notes
107124
#### New Features
108125
* Enable an AnnData-centric workflow for improved usability and interoperability with other single-cell analysis tools.
109126
* Introduced new utility functions
110-
* `palantir.utils.early_cell` To automate fining an early cell based on cell type and diffusion components.
127+
* `palantir.utils.early_cell` To automate finding an early cell based on cell type and diffusion components.
111128
* `palantir.utils.find_terminal_states` To automate finding terminal cell states based on cell type and diffusion components.
112129
* `palantir.presults.select_branch_cells` To find cells associated to each branch based on fate probability.
113130
* `palantir.plot.plot_branch_selection` To inspect the cell to branch association.
114131
* `palantir.utils.run_local_variability` To compute local gene expression variability.
115132
* `palantir.utils.run_density` A wrapper for [mellon.DensityEstimator](https://mellon.readthedocs.io/en/latest/model.html#mellon.model.DensityEstimator).
116133
* `palantir.utils.run_density_evaluation` Evaluate computed density on a different dataset.
117134
* `palantir.utils.run_low_density_variability`. To aggregate local gene expression variability in low density.
118-
* `palantir.plot.plot_branch`. To plot branch-selected cells over pseudotime in arbitrary y-postion and coloring.
119-
* `palantir.plot.plot_trend`. To plot the gene trend ontop of `palantir.plot.plot_branch`.
135+
* `palantir.plot.plot_branch`. To plot branch-selected cells over pseudotime in arbitrary y-position and coloring.
136+
* `palantir.plot.plot_trend`. To plot the gene trend on top of `palantir.plot.plot_branch`.
120137
* Added input validation for better error handling and improved user experience.
121138
* Expanded documentation within docstrings, providing additional clarity for users and developers.
122139

123140
#### Enhancements
124141
* Updated tutorial notebook to reflect the new workflow, guiding users through the updated processes.
125142
* Implemented gene trend computation using [Mellon](https://github.com/settylab/Mellon), providing more robust and efficient gene trend analysis.
126-
* Enable annotation in `palantir.plot.highight_cells_on_umap`.
143+
* Enable annotation in `palantir.plot.highlight_cells_on_umap`.
127144

128145
#### Changes
129146
* Replaced PhenoGraph dependency with `scanpy.tl.leiden` for gene trend clustering.
130-
* Deprecated the `run_tsne`, `determine_cell_clusters`, and `plot_cell_clusters` functions. Use corresponding implementations from [Scanpy](https://scanpy.readthedocs.io/en/stable/), widely used single-cell analysis library and direct dependecy of Palantir.
131-
* Rename `palantir.plot.highight_cells_on_tsne` to `palantir.plot.highight_cells_on_umap`
147+
* Deprecated the `run_tsne`, `determine_cell_clusters`, and `plot_cell_clusters` functions. Use corresponding implementations from [Scanpy](https://scanpy.readthedocs.io/en/stable/), widely used single-cell analysis library and direct dependency of Palantir.
148+
* Rename `palantir.plot.highlight_cells_on_tsne` to `palantir.plot.highlight_cells_on_umap`
132149
* Depend on `anndata>=0.8.0` to avoid issues writing dataframes in `ad.obsm`.
133150

134151
#### Fixes
135152
* Addressed the issue of variability when reproducing results ([issue#64](https://github.com/dpeerlab/Palantir/issues/64)), enhancing the reproducibility and reliability of Palantir.
136153

137154

138155
### Version 1.1.0
139-
* Replaced rpy2 with pyGAM for computing gene expression trends.
140-
* Updated tutorial and plotting functions
156+
* Replaced rpy2 with pyGAM for computing gene expression trends.
157+
* Updated tutorial and plotting functions
141158

142159

143160
### Version 1.0.0
144161

145-
* A fix to [issue#41](https://github.com/dpeerlab/Palantir/issues/41)
162+
* A fix to [issue#41](https://github.com/dpeerlab/Palantir/issues/41)
146163
* A fix to [issue#42](https://github.com/dpeerlab/Palantir/issues/42)
147164
* Revamped tutorial with support for Anndata and force directed layouts
148165

149166
### Version 0.2.6
150167

151168
* A fix to [issue#33](https://github.com/dpeerlab/Palantir/issues/33) and [issue#31](https://github.com/dpeerlab/Palantir/issues/31)
152-
169+
153170
### Version 0.2.5
154171

155172
* A fix related to [issue#28](https://github.com/dpeerlab/Palantir/issues/28). When identifying terminal states, duplicate values were generated instead of unique ones.

pyproject.toml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "palantir"
7+
version = "1.4.0"
8+
description = "Palantir for modeling continuous cell state and cell fate choices in single cell data"
9+
authors = [
10+
{name = "Palantir development team", email = "[email protected]"}
11+
]
12+
readme = "README.md"
13+
requires-python = ">=3.9"
14+
license = {text = "MIT"}
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"License :: OSI Approved :: MIT License",
23+
"Operating System :: OS Independent",
24+
"Operating System :: POSIX :: Linux",
25+
"Development Status :: 5 - Production/Stable",
26+
"Topic :: Scientific/Engineering :: Bio-Informatics",
27+
"Topic :: Scientific/Engineering :: Visualization",
28+
]
29+
dependencies = [
30+
"numpy>=1.14.2",
31+
"pandas>=0.22.0",
32+
"scipy>=1.3",
33+
"networkx>=2.1",
34+
"scikit-learn",
35+
"joblib",
36+
"fcsparser>=0.1.2",
37+
"leidenalg>=0.9.1",
38+
"matplotlib>=2.2.2",
39+
"anndata>=0.8.0",
40+
"scanpy>=1.6.0",
41+
"mellon>=1.3.0",
42+
]
43+
44+
[project.optional-dependencies]
45+
gam = [
46+
"pygam",
47+
]
48+
49+
full = [
50+
"pygam",
51+
]
52+
53+
test = [
54+
"pytest>=7.0.0",
55+
"pytest-cov>=4.0.0",
56+
"h5py",
57+
]
58+
59+
[project.urls]
60+
Homepage = "https://github.com/dpeerlab/palantir"
61+
"Bug Tracker" = "https://github.com/dpeerlab/palantir/issues"
62+
63+
[tool.setuptools]
64+
package-dir = {"" = "src"}
65+
66+
[tool.pytest.ini_options]
67+
testpaths = ["tests"]
68+
python_files = "test_*.py"
69+
70+
[tool.black]
71+
line-length = 100
72+
target-version = ['py39']
73+
include = '\.pyi?$'
74+
exclude = '''
75+
/(
76+
\.eggs
77+
| \.git
78+
| \.hg
79+
| \.mypy_cache
80+
| \.tox
81+
| \.venv
82+
| _build
83+
| buck-out
84+
| build
85+
| dist
86+
)/
87+
'''
88+
89+
[tool.coverage.run]
90+
source = ["palantir"]
91+
omit = [
92+
"tests/*",
93+
"*/config.py"
94+
]
95+
96+
[tool.coverage.report]
97+
exclude_lines = [
98+
"pragma: no cover",
99+
"raise NotImplementedError",
100+
"if __name__ == .__main__.:",
101+
"pass",
102+
"raise ImportError",
103+
"def _return_cell",
104+
"print"
105+
]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.
1+
-e .

setup.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,7 @@
11
import sys
22
from setuptools import setup
3-
from warnings import warn
43

5-
# get version and other attributes
6-
version_info = {}
7-
with open("src/palantir/version.py") as f:
8-
exec(f.read(), version_info)
9-
with open("README.md", "r") as fh:
10-
long_description = fh.read()
4+
# For backward compatibility, use setup.py as a proxy to pyproject.toml
5+
# All configuration is in pyproject.toml
116

12-
setup(
13-
name="palantir",
14-
version=version_info['__version__'],
15-
author=version_info['__author__'],
16-
author_email=version_info['__author_email__'],
17-
description="Palantir for modeling continuous cell state and cell fate choices in single cell data",
18-
long_description=long_description,
19-
long_description_content_type="text/markdown",
20-
url="https://github.com/dpeerlab/palantir",
21-
package_dir={"": "src"},
22-
packages=["palantir"],
23-
install_requires=[
24-
"numpy>=1.14.2",
25-
"pandas>=0.22.0",
26-
"scipy>=1.3",
27-
"networkx>=2.1",
28-
"scikit-learn",
29-
"joblib",
30-
"fcsparser>=0.1.2",
31-
"leidenalg>=0.9.1",
32-
"matplotlib>=2.2.2",
33-
"anndata>=0.8.0",
34-
"scanpy>=1.6.0",
35-
"mellon>=1.3.0",
36-
"pygam",
37-
],
38-
extras_require={
39-
'dev': [
40-
'flake8',
41-
'pytest',
42-
'coverage',
43-
'typing-extensions'
44-
]
45-
},
46-
classifiers=[
47-
"Programming Language :: Python :: 3",
48-
"License :: OSI Approved :: MIT License",
49-
"Operating System :: OS Independent",
50-
"Operating System :: POSIX :: Linux",
51-
"Development Status :: 5 - Production/Stable",
52-
"Topic :: Scientific/Engineering :: Bio-Informatics",
53-
"Topic :: Scientific/Engineering :: Visualization",
54-
],
55-
python_requires=">=3.8",
56-
)
7+
setup()

src/palantir/__init__.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1+
"""
2+
Palantir - Modeling continuous cell state and cell fate choices in single cell data.
3+
4+
Palantir is an algorithm to align cells along differentiation trajectories, identify
5+
differentiation endpoints, and estimate cell-fate probabilities in single-cell data.
6+
The package provides functions for preprocessing, visualization, trajectory analysis,
7+
and gene expression modeling along the trajectories.
8+
9+
Modules
10+
-------
11+
config : Configuration settings for Palantir
12+
core : Core functions for running the Palantir algorithm
13+
presults : Class for storing and accessing Palantir results
14+
io : Input/output functions for loading and saving data
15+
preprocess : Preprocessing functions for single-cell data
16+
utils : Utility functions for analysis
17+
plot : Visualization functions
18+
"""
19+
20+
import importlib.metadata
21+
122
from . import config
2-
from . import core
23+
24+
# Import modules in a specific order to avoid circular imports
325
from . import presults
26+
from . import core
427
from . import io
528
from . import preprocess
629
from . import utils
730
from . import plot
8-
from .version import __version__
31+
32+
__version__ = importlib.metadata.version("palantir")
933

1034
__all__ = [
1135
"config",

0 commit comments

Comments
 (0)