Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
canergen committed Feb 15, 2024
1 parent f3d0c74 commit e5cde62
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions popv/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ def celltype_ratio_bar_plot(
prop.loc[x, "query"] = np.sum(labels[is_query] == x)
prop.loc[x, "ref"] = np.sum(labels[~is_query] == x)
if normalize:
prop = prop.div(prop.sum(axis=1))
prop = prop.div(prop.sum(axis=0), axis=1)

ax = prop.loc[cell_types].plot(kind="bar", figsize=(len(cell_types) * 0.5, 4), logy=True)
ax = prop.loc[cell_types].plot(kind="bar", figsize=(len(cell_types) * 0.5, 4), logy=(not normalize))
ax.set_ylabel("Celltype")
ax.set_ylabel("log Celltype Abundance")
ax.set_ylabel("Celltype Abundance")
if save_folder is not None:
save_path = os.path.join(save_folder, "celltype_prop_barplot.pdf")
ax.get_figure().savefig(save_path, bbox_inches="tight", dpi=300)
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exclude = ["resources/*", "tests/*", "dataset/*"]

[project]
name = "PopV"
version = "0.4.1"
version = "0.4.2"
description = "Consensus prediction of cell type labels with popV"
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -33,8 +33,6 @@ dependencies = [
"gdown>4.6.0",
"h5py>3.7.0",
"huggingface-hub>=0.11.1",
"jax<0.4.24", # Remove with scvi-tools 1.1
"jaxlib<0.4.24",
"onclass>=1.3",
"scanorama>1.7.2",
"scanpy>1.9.0",
Expand Down
11 changes: 8 additions & 3 deletions tests/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ def test_celltypist():
def test_annotation():
"""Test Annotation and Plotting pipeline."""
adata = _get_test_anndata().adata
popv.annotation.annotate_data(adata, methods=["svm", "rf"], save_path="tests/tmp_testing/popv_test_results/")
popv.annotation.annotate_data(
adata, methods=["svm", "rf"],
save_path="tests/tmp_testing/popv_test_results/")
popv.visualization.agreement_score_bar_plot(adata)
popv.visualization.prediction_score_bar_plot(adata)
popv.visualization.make_agreement_plots(adata, prediction_keys=adata.uns["prediction_keys"])
Expand All @@ -190,11 +192,14 @@ def test_annotation():
def test_annotation_no_ontology():
"""Test Annotation and Plotting pipeline without ontology."""
adata = _get_test_anndata(cl_obo_folder=False).adata
popv.annotation.annotate_data(adata, methods=["svm", "rf"], save_path="tests/tmp_testing/popv_test_results/")
popv.annotation.annotate_data(
adata, methods=["svm", "rf"],
save_path="tests/tmp_testing/popv_test_results/")
popv.visualization.agreement_score_bar_plot(adata)
popv.visualization.prediction_score_bar_plot(adata)
popv.visualization.make_agreement_plots(adata, prediction_keys=adata.uns["prediction_keys"])
popv.visualization.celltype_ratio_bar_plot(adata)
popv.visualization.celltype_ratio_bar_plot(adata, save_folder="tests/tmp_testing/popv_test_results/")
popv.visualization.celltype_ratio_bar_plot(adata, normalize=False)

assert "popv_majority_vote_prediction" in adata.obs.columns
assert not adata.obs["popv_majority_vote_prediction"].isnull().any()
Expand Down

0 comments on commit e5cde62

Please sign in to comment.