Skip to content

Commit

Permalink
updating workflow action versions, adding latest python version to ac…
Browse files Browse the repository at this point in the history
…tions, adding repo link to readme, adding error handling test functions to pytest, adding latest python version to pytest
  • Loading branch information
harryhaller001 committed Nov 1, 2024
1 parent fca5815 commit 58a247a
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ jobs:
- os: ubuntu-latest
python: "3.9"
- os: ubuntu-latest
python: "3.12"
python: "3.10"
- os: ubuntu-latest
python: "3.11"
- os: ubuntu-latest
python: "3.12"
- os: ubuntu-latest
python: "3.13"
- os: ubuntu-latest
python: "3.13"
pip-flags: "--pre"
name: PRE-RELEASE DEPENDENCIES

Expand All @@ -39,9 +45,9 @@ jobs:
PYTHON: ${{ matrix.python }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9
3.10
12 changes: 6 additions & 6 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cff-version: 1.2.0
message: "If you use pyclustree, please cite it as below. Please also cite the original clustree package."
authors:
- family-names: "Kuehl"
given-names: "Malte"
- family-names: "Hellmig"
given-names: "Malte"
- family-names: "Puelles"
given-names: "Victor G."
- family-names: "Kuehl"
given-names: "Malte"
- family-names: "Hellmig"
given-names: "Malte"
- family-names: "Puelles"
given-names: "Victor G."
title: "pyclustree: Visualizing cluster resolution optimization for biomedical data"
version: 0.3.1
date-released: 2024-10-24
Expand Down
55 changes: 38 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
.DEFAULT_GOAL := test


.DEFAULT_GOAL := help


.PHONY : help
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)


#
# Virtual environment setup
# You may want to replace python3 with the path to your python3 executable,
# e.g. the output of `pyenv which python3`when using pyenv
#
create-venv:
python3 -m venv '.venv'
.PHONY : create-venv
create-venv: ## Create virtualenv
python3 -m virtualenv '.venv'
echo "Don't forget to activate with 'source .venv/bin/activate'"

#
# Install requirements
#
install:
python3 -m pip install --upgrade pip
python3 -m pip install flit poetry
.PHONY : install
install: ## Install dependencies for production
python3 -m pip --require-virtualenv install --upgrade pip
python3 -m pip --require-virtualenv install flit poetry
python3 -m flit install --deps production

install-dev: install
python3 -m pip install '.[dev]'
.PHONY : install-dev
install-dev: install ## Install dependencies for development and production
python3 -m pip --require-virtualenv install '.[dev]'
python3 -m certifi
pre-commit install --hook-type pre-commit --hook-type pre-push
echo "Please also install pandoc to create the documentation."

upload: check
flit publish

#
# Testing
# Build and upload package
#
unittest:
coverage run -m pytest --maxfail=10
.PHONY : build
build: ## Build python package
python3 -m build
python3 -m twine check --strict dist/*.whl

.PHONY : upload
upload: ## Publish package with flit
python3 -m flit publish

coverage-report: unittest
coverage report
coverage html
#
# Testing
#
.PHONY : pytest
pytest: ## Run pytest with coverage
python3 -m coverage run -m pytest --maxfail=10

test: check unittest
.PHONY : coverage-report
coverage-report: pytest ## Generate coverage report
python3 -m coverage report -m
python3 -m coverage html
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Visualize cluster assignments at different resolutions. Possbile applications include finding the optimal resolution for
single-cell RNA-sequencing clusterings.

`pyclustree` is inspired by the R package `clustree`, however, while we aim to provide the same functionality, the API
`pyclustree` is inspired by the R package `clustree` ([Github repository](https://github.com/lazappi/clustree)), however, while we aim to provide the same functionality, the API
will differ between the implementations.

## Getting started
Expand Down
4 changes: 1 addition & 3 deletions pyclustree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from ._clustree import clustree

pyclustree = clustree

__all__ = ["clustree", "pyclustree"]
__all__ = ["clustree"]

__version__ = version("pyclustree")
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Visualize cluster assignments at different resolutions"
readme = "README.md"
license = { file = "LICENSE" }
maintainers = [
{ name = "Malte Hellmig", email = "[email protected]" },
{ name = "Malte Hellmig", email = "[email protected]" },
{ name = "Malte Kuehl", email = "[email protected]" },
]
authors = [ { name = "Malte Hellmig" }, { name = "Malte Kuehl" } ]
Expand Down Expand Up @@ -47,6 +47,7 @@ optional-dependencies.dev = [
"furo",
"ipykernel",
"ipython",
"ipywidgets",
"myst-parser",
"nbsphinx",
"pandas",
Expand Down
29 changes: 29 additions & 0 deletions tests/test_pyclustree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import matplotlib.pyplot as plt
import pytest
import scanpy as sc

import pyclustree
Expand Down Expand Up @@ -61,3 +62,31 @@ def test_scatter_reference():
)

assert isinstance(fig, plt.Figure), "pyclustree should return a matplotlib Figure object."

# Testing errorhandling

# Testing none existing gene fo node color
with pytest.raises(AssertionError):
clustree(
adata,
[f"leiden_{str(resolution).replace('.', '_')}" for resolution in [0.2, 1.0]],
node_color_gene="Non-existing gene",
)

with pytest.raises(AssertionError):
clustree(
adata,
[f"leiden_{str(resolution).replace('.', '_')}" for resolution in [0.2, 1.0]],
node_color_gene="Non-existing gene",
node_color_gene_use_raw=False,
)

# Testing node colormap argument
with pytest.raises(AssertionError):
cluster_keys = [f"leiden_{str(resolution).replace('.', '_')}" for resolution in [0.2, 1.0]]
clustree(adata, cluster_keys, node_colormap=["#FF0000"] * (len(cluster_keys) + 1))

# Testing node_color_gene when node colormap argument is provided
with pytest.raises(AssertionError):
cluster_keys = [f"leiden_{str(resolution).replace('.', '_')}" for resolution in [0.2, 1.0]]
clustree(adata, cluster_keys, node_colormap=["#FF0000"] * len(cluster_keys), node_color_gene="CD8A")

0 comments on commit 58a247a

Please sign in to comment.