diff --git a/docs/notebooks/tabula_sapiens_tutorial.ipynb b/docs/notebooks/tabula_sapiens_tutorial.ipynb index 03dd337..f380c47 100644 --- a/docs/notebooks/tabula_sapiens_tutorial.ipynb +++ b/docs/notebooks/tabula_sapiens_tutorial.ipynb @@ -1254,4 +1254,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/tabula_sapiens_tutorial.ipynb b/tabula_sapiens_tutorial.ipynb index 2722a92..fb07b36 100644 --- a/tabula_sapiens_tutorial.ipynb +++ b/tabula_sapiens_tutorial.ipynb @@ -1582,4 +1582,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/tests/core/test_models.py b/tests/core/test_models.py index dad6c1d..0a0b3f3 100644 --- a/tests/core/test_models.py +++ b/tests/core/test_models.py @@ -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" @@ -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)