Skip to content

Commit

Permalink
Merge pull request #14 from RasmussenLab/slim_default_installation
Browse files Browse the repository at this point in the history
🎨 ➖ remove umap-learn. also remove lifelines dependency for default pkg
  • Loading branch information
enryH authored Oct 16, 2024
2 parents 90b57d5 + d072239 commit 752389b
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ jobs:
strategy:
matrix:
python:
- version: "3.12"
toxenv: "py312"
- version: "3.11"
toxenv: "py311"
- version: "3.10"
toxenv: "py310"
- version: "3.9"
toxenv: "py39"
- version: "3.8"
toxenv: "py38"
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -139,4 +139,4 @@ jobs:
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ python:
path: .
extra_requirements:
- docs
- all
2 changes: 1 addition & 1 deletion docs/tutorial/explorative_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"outputs": [],
"source": [
"%pip install njab openpyxl"
"%pip install 'njab[all]' openpyxl"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/explorative_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# First install the dependencies:

# %% tags=["hide-output"]
# %pip install njab openpyxl
# %pip install 'njab[all]' openpyxl

# %% tags=["hide-cell"]
from functools import partial
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/log_reg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"source": [
"# Setup colab installation\n",
"# You need to restart the runtime after running this cell\n",
"%pip install njab heatmapz openpyxl plotly"
"%pip install njab heatmapz openpyxl plotly umap-learn"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/log_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# %% tags=["hide-output"]
# Setup colab installation
# You need to restart the runtime after running this cell
# %pip install njab heatmapz openpyxl plotly
# %pip install njab heatmapz openpyxl plotly umap-learn

# %% tags=["hide-input"]
import itertools
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "njab"
authors = [{ name = "Henry Webel", email = "[email protected]" }]
description = "not Just Another Biomarker"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = ["bioinformatics", "biomarker"]
license = { file = "LICENSE" }
classifiers = [
Expand All @@ -15,12 +15,10 @@ classifiers = [
]
dependencies = [
"omegaconf",
"lifelines",
"numpy",
"pandas",
"scikit-learn",
"statsmodels",
"umap-learn",
"matplotlib",
"mrmr_selection",
"pingouin",
Expand All @@ -29,6 +27,9 @@ dependencies = [
dynamic = ["version"]

[project.optional-dependencies]
all = [
"lifelines",
]
docs = [
"sphinx",
"sphinx-book-theme",
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ based_on_style = pep8
######################

[mypy]
python_version = 3.8
python_version = 3.10
warn_unused_configs = True
show_error_context = True
pretty = True
Expand Down Expand Up @@ -39,7 +39,7 @@ source =
#########################

[tox:tox]
envlist = py38,py39,py310,py311
envlist = py39,py310,py311,py312
isolated_build = True

[testenv]
Expand Down
1 change: 0 additions & 1 deletion src/njab/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
import pathlib


Expand Down
10 changes: 5 additions & 5 deletions src/njab/plotting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Matplotlib functionality for custom plots."""

import numpy as np
import pandas as pd
import matplotlib
import logging
import pathlib
from typing import Iterable

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from njab.plotting.lifelines import plot_lifelines
from njab.plotting.km import compare_km_curves

__all__ = ['plot_lifelines', 'compare_km_curves']
__all__ = ['plot_lifelines']

plt.rcParams['figure.figsize'] = [4.0, 3.0]
plt.rcParams['pdf.fonttype'] = 42
Expand Down
28 changes: 19 additions & 9 deletions src/njab/plotting/km.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from __future__ import annotations
from matplotlib.axes import Axes
import lifelines.statistics
from lifelines import KaplanMeierFitter
try:
import lifelines.statistics
from lifelines import KaplanMeierFitter
except ModuleNotFoundError as e:
msg = (
"lifelines not available. Please install all njab dependencies typing:"
"\n\tpip install 'njab[all]'"
"\nor separately typing:\n\tpip install lifelines")
e.args = (msg, *e.args[1:])
raise ModuleNotFoundError(*e.args) from e
import pandas as pd
from matplotlib.axes import Axes


def compare_km_curves(
Expand Down Expand Up @@ -56,13 +63,16 @@ def compare_km_curves(
mask = pred
kmf_1 = KaplanMeierFitter()
kmf_1.fit(time.loc[mask], event_observed=y.loc[mask])
ax = kmf_1.plot(xlim=xlim,
ylim=ylim,
xlabel=xlabel,
ylabel=ylabel,
legend=False)
ax = kmf_1.plot(
xlim=xlim,
ylim=ylim,
xlabel=xlabel,
ylabel=ylabel,
legend=False,
)
if add_risk_counts:
from lifelines.plotting import add_at_risk_counts

add_at_risk_counts(kmf_0, kmf_1, ax=ax)
return ax, kmf_0, kmf_1

Expand Down
2 changes: 1 addition & 1 deletion src/njab/sklearn/pca.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Optional

import matplotlib
import pandas as pd
import sklearn.decomposition
Expand Down
1 change: 0 additions & 1 deletion src/njab/stats/ancova.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Analysis of covariance using pingouin and statsmodels."""
from __future__ import annotations

import numpy as np
import pandas as pd
import pingouin as pg
Expand Down
1 change: 0 additions & 1 deletion src/njab/stats/groups_comparision.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Bionomial test and t-test for groups comparision."""
from __future__ import annotations
import logging
import pandas as pd
import pingouin as pg
Expand Down

0 comments on commit 752389b

Please sign in to comment.