From 5fb8aa7a94442b0bbe0d29027b0eb9efa3649f52 Mon Sep 17 00:00:00 2001 From: Can Ergen Date: Sat, 9 Dec 2023 23:34:08 -0800 Subject: [PATCH] Pre-commit. --- popv/algorithms/_bbknn.py | 14 ++++++------- popv/algorithms/_celltypist.py | 10 ++++----- popv/algorithms/_harmony.py | 14 ++++++------- popv/algorithms/_onclass.py | 14 ++++++------- popv/algorithms/_rf.py | 10 ++++----- popv/algorithms/_scaffold_algorithm.py | 16 +++++++-------- popv/algorithms/_scanorama.py | 14 ++++++------- popv/algorithms/_scanvi.py | 20 +++++++++--------- popv/algorithms/_scvi.py | 18 ++++++++--------- popv/algorithms/_svm.py | 10 ++++----- popv/annotation.py | 8 ++++---- popv/preprocessing.py | 28 +++++++++++++------------- popv/visualization.py | 18 ++++++++--------- 13 files changed, 97 insertions(+), 97 deletions(-) diff --git a/popv/algorithms/_bbknn.py b/popv/algorithms/_bbknn.py index 461e4cc..81639fe 100644 --- a/popv/algorithms/_bbknn.py +++ b/popv/algorithms/_bbknn.py @@ -9,13 +9,13 @@ class BBKNN: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - result_key: Optional[str] = "popv_knn_on_bbknn_prediction", - embedding_key: Optional[str] = "X_bbknn_umap_popv", - method_dict: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + result_key: str | None = "popv_knn_on_bbknn_prediction", + embedding_key: str | None = "X_bbknn_umap_popv", + method_dict: dict | None = None, + classifier_dict: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_celltypist.py b/popv/algorithms/_celltypist.py index 5ff2171..9b28427 100644 --- a/popv/algorithms/_celltypist.py +++ b/popv/algorithms/_celltypist.py @@ -7,11 +7,11 @@ class CELLTYPIST: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - result_key: Optional[str] = "popv_celltypist_prediction", - method_dict: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + result_key: str | None = "popv_celltypist_prediction", + method_dict: dict | None = None, + classifier_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_harmony.py b/popv/algorithms/_harmony.py index b854fea..b5e1613 100644 --- a/popv/algorithms/_harmony.py +++ b/popv/algorithms/_harmony.py @@ -12,13 +12,13 @@ class HARMONY: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - result_key: Optional[str] = "popv_knn_on_harmony_prediction", - embedding_key: Optional[str] = "X_umap_harmony_popv", - method_dict: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + result_key: str | None = "popv_knn_on_harmony_prediction", + embedding_key: str | None = "X_umap_harmony_popv", + method_dict: dict | None = None, + classifier_dict: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after Harmony integration. diff --git a/popv/algorithms/_onclass.py b/popv/algorithms/_onclass.py index 490b22a..23acdc1 100644 --- a/popv/algorithms/_onclass.py +++ b/popv/algorithms/_onclass.py @@ -10,13 +10,13 @@ class ONCLASS: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - layers_key: Optional[str] = None, - max_iter: Optional[int] = 30, - cell_ontology_obs_key: Optional[str] = None, - result_key: Optional[str] = "popv_onclass_prediction", - seen_result_key: Optional[str] = "popv_onclass_seen", + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + layers_key: str | None = None, + max_iter: Optionalint] = 30, + cell_ontology_obs_key: str | None = None, + result_key: str | None = "popv_onclass_prediction", + seen_result_key: str | None = "popv_onclass_seen", ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_rf.py b/popv/algorithms/_rf.py index 14e1ac2..25c6f5a 100644 --- a/popv/algorithms/_rf.py +++ b/popv/algorithms/_rf.py @@ -10,11 +10,11 @@ class RF: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - layers_key: Optional[str] = None, - result_key: Optional[str] = "popv_rf_prediction", - classifier_dict: Optional[str] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + layers_key: str | None = None, + result_key: str | None = "popv_rf_prediction", + classifier_dict: str | None = {}, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_scaffold_algorithm.py b/popv/algorithms/_scaffold_algorithm.py index a546ac1..9091548 100644 --- a/popv/algorithms/_scaffold_algorithm.py +++ b/popv/algorithms/_scaffold_algorithm.py @@ -10,14 +10,14 @@ class NEW_ALGORITHM: # Remove embedding key if not an integration method. def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - layers_key: Optional[str] = None, - result_key: Optional[str] = "popv_knn_on_scanorama_prediction", - embedding_key: Optional[str] = "X_umap_scanorma_popv", - method_dict: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + layers_key: str | None = None, + result_key: str | None = "popv_knn_on_scanorama_prediction", + embedding_key: str | None = "X_umap_scanorma_popv", + method_dict: dict | None = None, + classifier_dict: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_scanorama.py b/popv/algorithms/_scanorama.py index df1d69f..5b6416f 100644 --- a/popv/algorithms/_scanorama.py +++ b/popv/algorithms/_scanorama.py @@ -13,13 +13,13 @@ class SCANORAMA: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - result_key: Optional[str] = "popv_knn_on_scanorama_prediction", - embedding_key: Optional[str] = "X_umap_scanorma_popv", - method_dict: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + result_key: str | None = "popv_knn_on_scanorama_prediction", + embedding_key: str | None = "X_umap_scanorma_popv", + method_dict: dict | None = None, + classifier_dict: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/algorithms/_scanvi.py b/popv/algorithms/_scanvi.py index bfe0b4d..5cb7986 100644 --- a/popv/algorithms/_scanvi.py +++ b/popv/algorithms/_scanvi.py @@ -10,16 +10,16 @@ class SCANVI_POPV: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - n_epochs_unsupervised: Optional[int] = None, - n_epochs_semisupervised: Optional[int] = None, - save_folder: Optional[str] = None, - result_key: Optional[str] = "popv_scanvi_prediction", - embedding_key: Optional[str] = "X_scanvi_umap_popv", - model_kwargs: Optional[dict] = {}, - classifier_kwargs: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + n_epochs_unsupervised: int | None = None, + n_epochs_semisupervised: int | None = None, + save_folder: str | None = None, + result_key: str | None = "popv_scanvi_prediction", + embedding_key: str | None = "X_scanvi_umap_popv", + model_kwargs: dict | None = None, + classifier_kwargs: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute classifier in scANVI model and predict labels. diff --git a/popv/algorithms/_scvi.py b/popv/algorithms/_scvi.py index 917fc61..9a8b10a 100644 --- a/popv/algorithms/_scvi.py +++ b/popv/algorithms/_scvi.py @@ -13,15 +13,15 @@ class SCVI_POPV: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - max_epochs: Optional[int] = None, - save_folder: Optional[str] = None, - result_key: Optional[str] = "popv_knn_on_scvi_prediction", - embedding_key: Optional[str] = "X_scvi_umap_popv", - model_kwargs: Optional[dict] = {}, - classifier_dict: Optional[dict] = {}, - embedding_dict: Optional[dict] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + max_epochs: int | None = None, + save_folder: str | None = None, + result_key: str | None = "popv_knn_on_scvi_prediction", + embedding_key: str | None = "X_scvi_umap_popv", + model_kwargs: dict | None = None, + classifier_dict: dict | None = None, + embedding_dict: dict | None = None, ) -> None: """ Class to compute KNN classifier after scVI integration. diff --git a/popv/algorithms/_svm.py b/popv/algorithms/_svm.py index ca2fe1b..110067d 100644 --- a/popv/algorithms/_svm.py +++ b/popv/algorithms/_svm.py @@ -11,11 +11,11 @@ class SVM: def __init__( self, - batch_key: Optional[str] = "_batch_annotation", - labels_key: Optional[str] = "_labels_annotation", - layers_key: Optional[str] = None, - result_key: Optional[str] = "popv_svm_prediction", - classifier_dict: Optional[str] = {}, + batch_key: str | None = "_batch_annotation", + labels_key: str | None = "_labels_annotation", + layers_key: str | None = None, + result_key: str | None = "popv_svm_prediction", + classifier_dict: str | None = {}, ) -> None: """ Class to compute KNN classifier after BBKNN integration. diff --git a/popv/annotation.py b/popv/annotation.py index 747df92..4e24064 100644 --- a/popv/annotation.py +++ b/popv/annotation.py @@ -18,9 +18,9 @@ def annotate_data( adata: anndata.AnnData, - methods: Optional[list] = None, - save_path: Optional[str] = None, - methods_kwargs: Optional[dict] = None, + methods: list | None = None, + save_path: str | None = None, + methods_kwargs: dict | None = None, ) -> None: """ Annotate an AnnData dataset preprocessed by preprocessing.Process_Query by using the annotation pipeline. @@ -127,7 +127,7 @@ def compute_consensus(adata: anndata.AnnData, prediction_keys: list) -> None: def ontology_vote_onclass( adata: anndata.AnnData, prediction_keys: list, - save_key: Optional[str] = "popv_prediction", + save_key: str | None = "popv_prediction", ): """ Compute prediction using ontology aggregation method. diff --git a/popv/preprocessing.py b/popv/preprocessing.py index edaa906..07cddf7 100644 --- a/popv/preprocessing.py +++ b/popv/preprocessing.py @@ -19,20 +19,20 @@ def __init__( ref_adata: anndata.AnnData, ref_labels_key: str = "cell_ontology_class", ref_batch_key: str = "donor_method", - query_labels_key: Optional[str] = None, - query_batch_key: Optional[str] = None, - query_layers_key: Optional[str] = None, - prediction_mode: Optional[str] = "retrain", - cl_obo_folder: Optional[Union[List, str, bool]] = None, - unknown_celltype_label: Optional[str] = "unknown", - n_samples_per_label: Optional[int] = 300, - pretrained_scvi_path: Optional[str] = None, - save_path_trained_models: Optional[str] = "tmp/", - hvg: Optional[int] = 4000, - accelerator: Optional[str] = "cuda", - devices: Optional[Union[int, str]] = "auto", - compute_embedding: Optional[bool] = True, - return_probabilities: Optional[bool] = True, + query_labels_key: str | None = None, + query_batch_key: str | None = None, + query_layers_key: str | None = None, + prediction_mode: str | None = "retrain", + cl_obo_folder: Union[List, str, bool] | None = None, + unknown_celltype_label: str | None = "unknown", + n_samples_per_label: int | None = 300, + pretrained_scvi_path: str | None = None, + save_path_trained_models: str | None = "tmp/", + hvg: int | None = 4000, + accelerator: str | None = "cuda", + devices: Union[int, str] | None = "auto", + compute_embedding: bool = True, + return_probabilities: bool = True, ) -> None: """ Processes the query and reference dataset in preperation for the annotation pipeline. diff --git a/popv/visualization.py b/popv/visualization.py index a380b33..7e450b3 100755 --- a/popv/visualization.py +++ b/popv/visualization.py @@ -89,9 +89,9 @@ def _sample_report(adata, cell_type_key, score_key, pred_keys): def agreement_score_bar_plot( adata, - popv_prediction_key: Optional[str] = "popv_prediction", - consensus_score_key: Optional[str] = "popv_prediction_score", - save_folder: Optional[str] = None, + popv_prediction_key: str | None = "popv_prediction", + consensus_score_key: str | None = "popv_prediction_score", + save_folder: str | None = None, ): """ Create bar-plot of prediction scores in query cells after running popv. @@ -142,8 +142,8 @@ def agreement_score_bar_plot( def prediction_score_bar_plot( adata, - popv_prediction_score: Optional[str] = "popv_prediction_score", - save_folder: Optional[str] = None, + popv_prediction_score: str | None = "popv_prediction_score", + save_folder: str | None = None, ): """ Create bar-plot of prediction scores in query cells after running popv. @@ -181,8 +181,8 @@ def prediction_score_bar_plot( def celltype_ratio_bar_plot( adata, - popv_prediction: Optional[str] = "popv_prediction", - save_folder: Optional[str] = None, + popv_prediction: str | None = "popv_prediction", + save_folder: str | None = None, ): """ Create bar-plot of celltype rations in query as well as reference cells after running popv. @@ -223,8 +223,8 @@ def celltype_ratio_bar_plot( def make_agreement_plots( adata, prediction_keys: list, - popv_prediction_key: Optional[str] = "popv_prediction", - save_folder: Optional[str] = None, + popv_prediction_key: str | None = "popv_prediction", + save_folder: str | None = None, ): """ Create plot of confusion matrix for different popv methods and consensus prediction.