Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorials/notebooks
Submodule notebooks updated 1 files
+5 −36 milo.ipynb
7 changes: 6 additions & 1 deletion pertpy/tools/_augur.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ def create_estimator(
random_state=random_state,
)
elif classifier == "logistic_regression_classifier":
return LogisticRegression(penalty=penalty, random_state=random_state)
# scikit-learn 1.8 deprecated `penalty` in favor of `l1_ratio` (the L1/L2 mix) and `C` (no penalty via C=inf).
if penalty in (None, "none"):
return LogisticRegression(C=np.inf, random_state=random_state)
l1_ratio = {"l2": 0.0, "l1": 1.0, "elasticnet": 0.5}[penalty]
solver = "saga" if l1_ratio > 0.0 else "lbfgs"
return LogisticRegression(l1_ratio=l1_ratio, solver=solver, random_state=random_state)
else:
raise ValueError("Invalid classifier")

Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ filterwarnings = [
"ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning",
"ignore:In the future, the default backend for leiden will be igraph instead of leidenalg:FutureWarning",
"ignore:Transforming to str index:anndata.ImplicitModificationWarning",
"ignore:Failed to correctly find n_neighbors for some samples:UserWarning"
"ignore:Failed to correctly find n_neighbors for some samples:UserWarning",
# pydeseq2 emits these on the small synthetic data used by the Milo and compare_groups tests; they are not actionable in pertpy.
"ignore:The dispersion trend curve fitting did not converge:UserWarning",
"ignore:As the residual degrees of freedom is less than 3:UserWarning",
# Third-party deprecation and runtime notices that pertpy cannot resolve at the source.
"ignore:JAXopt is no longer maintained:DeprecationWarning",
"ignore:A worker stopped while some jobs were given to the executor:UserWarning",
"ignore:Data has categories outside of the nominated levels"
]

[tool.hatch.envs.default]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
pytestmark = pytest.mark.skip(reason="formulaic_contrasts and formulaic not available")


@pytest.mark.parametrize("kwargs", [{}, {"regression_model": sm.GLM, "family": sm.families.NegativeBinomial()}])
@pytest.mark.parametrize(
"kwargs", [{}, {"regression_model": sm.GLM, "family": sm.families.NegativeBinomial(alpha=1.0)}]
)
def test_statsmodels(test_adata, kwargs):
"""Check that the method can be initialized and fitted, and perform basic checks on the result of test_contrasts."""
from pertpy.tools._differential_gene_expression import Statsmodels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ def test_linear_operations():
# Input that has already been differenced — opt out of the auto-diff with ensure_consistency=False.
ps_adata = ps.compute_control_diff(psadata)

ps_adata2 = ps.add(ps_adata, perturbations=["target1", "target2"], ensure_consistency=False)
with pytest.warns(UserWarning, match="Combining perturbations without"):
ps_adata2 = ps.add(ps_adata, perturbations=["target1", "target2"], ensure_consistency=False)

test = ps_adata["control"].X + ps_adata["target1"].X + ps_adata["target2"].X
np.testing.assert_allclose(test, ps_adata2["target1+target2"].X, rtol=1e-4)

ps_adata2 = ps.subtract(ps_adata, reference_key="target1", perturbations=["target1"], ensure_consistency=False)
with pytest.warns(UserWarning, match="Combining perturbations without"):
ps_adata2 = ps.subtract(ps_adata, reference_key="target1", perturbations=["target1"], ensure_consistency=False)
ps_vector = ps_adata2["target1-target1"].X
np.testing.assert_allclose(ps_adata2["control"].X, ps_adata2["target1-target1"].X, rtol=1e-4)

Expand Down
Loading