Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 12, 2024
1 parent a8a1bdb commit c76664e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# PopV

PopV uses popular vote of a variety of cell-type transfer tools to classify cell-types in a query dataset based on a test dataset.
PopV uses popular vote of a variety of cell-type transfer tools to classify cell-types in a query dataset based on a test dataset.
Using this variety of algorithms, we compute the agreement between those algorithms and use this agreement to predict which cell-types are with a high likelihood the same cell-types observed in the reference.

## Algorithms
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/tabula_sapiens_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1254,4 +1254,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
2 changes: 1 addition & 1 deletion tabula_sapiens_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1582,4 +1582,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
30 changes: 14 additions & 16 deletions tests/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from popv.reproducibility import _accuracy


def _get_test_anndata(cl_obo_folder="resources/ontology/", mode='retrain'):
def _get_test_anndata(cl_obo_folder="resources/ontology/", mode="retrain"):
print("UUU", os.getcwd())
save_folder = "tests/tmp_testing/popv_test_results/"
fn = save_folder + "annotated_query.h5ad"
Expand Down Expand Up @@ -180,41 +180,39 @@ 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"], show=False)
popv.visualization.celltype_ratio_bar_plot(adata)
obo_fn = "resources/ontology/cl.obo"
_accuracy._ontology_accuracy(adata[adata.obs['_dataset']=='ref'], obofile=obo_fn, gt_key='cell_ontology_class', pred_key='popv_prediction')
_accuracy._fine_ontology_sibling_accuracy(adata[adata.obs['_dataset']=='ref'], obofile=obo_fn, gt_key='cell_ontology_class', pred_key='popv_prediction')
_accuracy._ontology_accuracy(
adata[adata.obs["_dataset"] == "ref"], obofile=obo_fn, gt_key="cell_ontology_class", pred_key="popv_prediction"
)
_accuracy._fine_ontology_sibling_accuracy(
adata[adata.obs["_dataset"] == "ref"], obofile=obo_fn, gt_key="cell_ontology_class", pred_key="popv_prediction"
)

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

adata = _get_test_anndata(mode='inference').adata
popv.annotation.annotate_data(
adata, save_path="tests/tmp_testing/popv_test_results/")
adata = _get_test_anndata(mode="inference").adata
popv.annotation.annotate_data(adata, save_path="tests/tmp_testing/popv_test_results/")

adata = _get_test_anndata(mode='fast').adata
popv.annotation.annotate_data(
adata, save_path="tests/tmp_testing/popv_test_results/")
adata = _get_test_anndata(mode="fast").adata
popv.annotation.annotate_data(adata, save_path="tests/tmp_testing/popv_test_results/")


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, save_folder="tests/tmp_testing/popv_test_results/")
popv.visualization.celltype_ratio_bar_plot(adata, normalize=False)
adata.obs['empty_columns'] = 'a'
adata.obs["empty_columns"] = "a"
input_data = adata.obs[["empty_columns", "popv_rf_prediction"]].values.tolist()
popv.reproducibility._alluvial.plot(input_data)

Expand Down

0 comments on commit c76664e

Please sign in to comment.