Skip to content

Commit

Permalink
Merge branch 'main' into enhancement/issue-742
Browse files Browse the repository at this point in the history
  • Loading branch information
aGuyLearning committed Jan 15, 2025
2 parents 90dcabd + bddb1f3 commit c437f27
Show file tree
Hide file tree
Showing 24 changed files with 654 additions and 250 deletions.
8 changes: 4 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

<!-- Please fill in the appropriate checklist below (delete whatever is not relevant). These are the most common things requested on pull requests (PRs). -->

- [ ] This comment contains a description of changes (with reason)
- [ ] Referenced issue is linked
- [ ] If you've fixed a bug or added code that should be tested, add tests!
- [ ] Documentation in `docs` is updated
- [ ] This comment contains a description of changes (with reason)
- [ ] Referenced issue is linked
- [ ] If you've fixed a bug or added code that should be tested, add tests!
- [ ] Documentation in `docs` is updated

**Description of changes**

Expand Down
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.11.0 🌈"
tag-template: 0.11.0
name-template: "0.12.0 🌈"
tag-template: 0.12.0
exclude-labels:
- "skip-changelog"

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/run_notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Run Notebooks

on:
- push
- pull_request

jobs:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ default_stages:
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.9.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
Expand All @@ -27,7 +27,7 @@ repos:
- id: trailing-whitespace
- id: check-case-conflict
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
Expand Down
28 changes: 14 additions & 14 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual
attention or advances
- Trolling, insulting/derogatory comments, and personal or political
attacks
- Public or private harassment
- Publishing others’ private information, such as a physical or
electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual
attention or advances
- Trolling, insulting/derogatory comments, and personal or political
attacks
- Public or private harassment
- Publishing others’ private information, such as a physical or
electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

## Features

- Exploratory and targeted analysis of Electronic Health Records
- Quality control & preprocessing
- Visualization & Exploration
- Clustering & trajectory inference
- Exploratory and targeted analysis of Electronic Health Records
- Quality control & preprocessing
- Visualization & Exploration
- Clustering & trajectory inference

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/_ext/typed_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _process_return(lines: Iterable[str]) -> Iterator[str]:
m = re.fullmatch(r"(?P<param>\w+)\s+:\s+(?P<type>[\w.]+)", line)
if m:
# Once this is in scanpydoc, we can use the fancy hover stuff
yield f'**{m["param"]}** : :class:`~{m["type"]}`'
yield f"**{m['param']}** : :class:`~{m['type']}`"
else:
yield line

Expand Down
18 changes: 9 additions & 9 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ in the cookiecutter-scverse template.

Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features:

- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- Google-style docstrings
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- Google-style docstrings
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)

See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information
on how to write documentation.
Expand All @@ -144,10 +144,10 @@ These notebooks come from [pert-tutorials](https://github.com/theislab/ehrapy-tu

#### Hints

- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`

#### Building the docs locally

Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ medRxiv 2023.12.11.23299816; doi: https://doi.org/10.1101/2023.12.11.23299816 ](

# Indices and tables

- {ref}`genindex`
- {ref}`modindex`
- {ref}`search`
- {ref}`genindex`
- {ref}`modindex`
- {ref}`search`

[scanpy genome biology (2018)]: https://doi.org/10.1186/s13059-017-1382-0
8 changes: 4 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ pip install ehrapy[medcat]

Available language models are

- en_core_web_md (python -m spacy download en_core_web_md)
- en-core-sci-sm (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_sm-0.4.0.tar.gz>)
- en-core-sci-md (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_md-0.4.0.tar.gz>)
- en-core-sci-lg (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_lg-0.4.0.tar.gz>)
- en_core_web_md (python -m spacy download en_core_web_md)
- en-core-sci-sm (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_sm-0.4.0.tar.gz>)
- en-core-sci-md (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_md-0.4.0.tar.gz>)
- en-core-sci-lg (pip install <https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_lg-0.4.0.tar.gz>)

[github repo]: https://github.com/theislab/ehrapy
[pip]: https://pip.pypa.io
Expand Down
7 changes: 6 additions & 1 deletion ehrapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

__author__ = "Lukas Heumos"
__email__ = "[email protected]"
__version__ = "0.9.0"
__version__ = "0.12.0"

import os

# https://docs.scipy.org/doc/scipy/dev/api-dev/array_api.html
os.environ["SCIPY_ARRAY_API"] = "1"

from ehrapy._settings import EhrapyConfig, ehrapy_settings

Expand Down
9 changes: 7 additions & 2 deletions ehrapy/_compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Since we might check whether an object is an instance of dask.array.Array
# without requiring dask installed in the environment.
# This would become obsolete should dask become a requirement for ehrapy

from collections.abc import Callable

try:
import dask.array as da
Expand All @@ -11,6 +10,12 @@
DASK_AVAILABLE = False


def _raise_array_type_not_implemented(func: Callable, type_: type) -> NotImplementedError:
raise NotImplementedError(
f"{func.__name__} does not support array type {type_}. Must be of type {func.registry.keys()}." # type: ignore
)


def is_dask_array(array):
if DASK_AVAILABLE:
return isinstance(array, da.Array)
Expand Down
4 changes: 2 additions & 2 deletions ehrapy/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def file_format_data(self, file_format: str):
_type_check(file_format, "file_format_data", str)
file_format_options = {"csv", "h5ad"}
if file_format not in file_format_options:
raise ValueError(f"Cannot set file_format_data to {file_format}. " f"Must be one of {file_format_options}")
raise ValueError(f"Cannot set file_format_data to {file_format}. Must be one of {file_format_options}")
self._file_format_data = file_format

@property
Expand Down Expand Up @@ -237,7 +237,7 @@ def cache_compression(self) -> str | None:
@cache_compression.setter
def cache_compression(self, cache_compression: str | None):
if cache_compression not in {"lzf", "gzip", None}:
raise ValueError(f"`cache_compression` ({cache_compression}) " "must be in {'lzf', 'gzip', None}")
raise ValueError(f"`cache_compression` ({cache_compression}) must be in {{'lzf', 'gzip', None}}")
self._cache_compression = cache_compression

@property
Expand Down
2 changes: 1 addition & 1 deletion ehrapy/anndata/_feature_specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def infer_feature_types(

if verbose:
logger.warning(
f"{'Features' if len(uncertain_features) >1 else 'Feature'} {str(uncertain_features)[1:-1]} {'were' if len(uncertain_features) >1 else 'was'} detected as categorical features stored numerically."
f"{'Features' if len(uncertain_features) > 1 else 'Feature'} {str(uncertain_features)[1:-1]} {'were' if len(uncertain_features) > 1 else 'was'} detected as categorical features stored numerically."
f"Please verify and correct using `ep.ad.replace_feature_types` if necessary."
)

Expand Down
51 changes: 10 additions & 41 deletions ehrapy/core/meta_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import sys
from datetime import datetime

import session_info
from rich import print
from scanpy.logging import _versions_dependencies

from ehrapy import __version__

Expand All @@ -17,56 +15,27 @@ def print_versions(): # pragma: no cover
>>> import ehrapy as ep
>>> ep.print_versions()
"""
try:
session_info.show(
dependencies=True,
html=False,
excludes=[
"builtins",
"stdlib_list",
"importlib_metadata",
"jupyter_core"
# Special module present if test coverage being calculated
# https://gitlab.com/joelostblom/session_info/-/issues/10
"$coverage",
],
)
except AttributeError:
print("[bold yellow]Unable to fetch versions for one or more dependencies.")
pass
print_header()


def print_version_and_date(*, file=None): # pragma: no cover
"""Useful for starting a notebook so you see when you started working."""
if file is None:
file = sys.stdout
print(
f"Running ehrapy {__version__}, " f"on {datetime.now():%Y-%m-%d %H:%M}.",
f"Running ehrapy {__version__}, on {datetime.now():%Y-%m-%d %H:%M}.",
file=file,
)


def print_header(*, file=None): # pragma: no cover
"""Versions that might influence the numerical results.
"""Versions that might influence the numerical results."""
from session_info2 import session_info

Matplotlib and Seaborn are excluded from this.
"""
_DEPENDENCIES_NUMERICS = [
"scanpy",
"anndata",
"umap",
"numpy",
"scipy",
"pandas",
("sklearn", "scikit-learn"),
"statsmodels",
("igraph", "python-igraph"),
"leidenalg",
"pynndescent",
]
sinfo = session_info(os=True, cpu=True, gpu=True, dependencies=True)

modules = ["ehrapy"] + _DEPENDENCIES_NUMERICS
print(
" ".join(f"{mod}=={ver}" for mod, ver in _versions_dependencies(modules)),
file=file or sys.stdout,
)
if file is not None:
print(sinfo, file=file)
return

return sinfo
13 changes: 10 additions & 3 deletions ehrapy/plot/_scanpy_pl_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,10 @@ def tsne(adata, **kwargs) -> Axes | list[Axes] | None: # pragma: no cover
.. image:: /_static/docstring_previews/tsne_1.png
>>> ep.pl.tsne(
... adata, color=["day_icu_intime", "service_unit"], wspace=0.5, title=["Day of ICU admission", "Service unit"]
... adata,
... color=["day_icu_intime", "service_unit"],
... wspace=0.5,
... title=["Day of ICU admission", "Service unit"],
... )
.. image:: /_static/docstring_previews/tsne_2.png
Expand Down Expand Up @@ -1233,7 +1236,10 @@ def umap(adata: AnnData, **kwargs) -> Axes | list[Axes] | None: # pragma: no co
.. image:: /_static/docstring_previews/umap_1.png
>>> ep.pl.umap(
... adata, color=["day_icu_intime", "service_unit"], wspace=0.5, title=["Day of ICU admission", "Service unit"]
... adata,
... color=["day_icu_intime", "service_unit"],
... wspace=0.5,
... title=["Day of ICU admission", "Service unit"],
... )
.. image:: /_static/docstring_previews/umap_2.png
Expand Down Expand Up @@ -1984,7 +1990,8 @@ def paga_compare(
save=save,
title_graph=title_graph,
groups_graph=groups_graph,
pos=pos**paga_graph_params,
pos=pos,
**paga_graph_params,
)


Expand Down
Loading

0 comments on commit c437f27

Please sign in to comment.