Skip to content

Commit

Permalink
Formatcode for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
drbecavin committed Dec 4, 2024
1 parent 3374073 commit 1e33c4e
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 146 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fmt: ## Format code using black & isort.
lint: ## Run pep8, black, mypy linters.
@echo "Run scMusketeers linting"
$(ENV_PREFIX)poetry run flake8 scmusketeers/
$(ENV_PREFIX)poetry run black -l 79 --check scmusketeers/ tests/
$(ENV_PREFIX)poetry run black -l 100 --check scmusketeers/ tests/
$(ENV_PREFIX)poetry run mypy --ignore-missing-imports scmusketeers/ tests/

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sc-musketeers"
version = "0.3.3"
version = "0.3.4"
description = "A tri-partite modular autoencoder for addressing imbalanced cell type annotation and batch effect reduction"
license = "MIT"
authors = ["AntoineCollin","Christophe Becavin"]
Expand Down
2 changes: 1 addition & 1 deletion scmusketeers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import tools, arguments, transfer
from . import arguments, tools, transfer
5 changes: 2 additions & 3 deletions scmusketeers/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from scmusketeers.arguments.runfile import get_runfile
from scmusketeers.run_musk import run_sc_musketeers
from scmusketeers.arguments.runfile import (
get_runfile,
)


def main_entry_point():
# Get all arguments
Expand Down
1 change: 1 addition & 0 deletions scmusketeers/arguments/class_param.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from scmusketeers.tools.utils import str2bool


class CLASS_PARAM:

class_hidden_size = [64]
Expand Down
14 changes: 4 additions & 10 deletions scmusketeers/run_musk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@

from ax.service.ax_client import AxClient, ObjectiveProperties

from scmusketeers.arguments.neptune_log import (
start_neptune_log,
stop_neptune_log,
)
from scmusketeers.arguments.runfile import (
PROCESS_TYPE,
create_argparser,
get_runfile,
get_default_param
)
from scmusketeers.arguments.neptune_log import (start_neptune_log,
stop_neptune_log)
from scmusketeers.arguments.runfile import (PROCESS_TYPE, create_argparser,
get_default_param, get_runfile)
from scmusketeers.transfer.experiment import MakeExperiment
from scmusketeers.transfer.optimize_model import Workflow

Expand Down
1 change: 0 additions & 1 deletion scmusketeers/tools/clust_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pandas as pd
from anndata import AnnData
from sklearn.metrics import *

# from sklearn.metrics import confusion_matrix, balanced_accuracy_score, accuracy_score,silhouette_samples,f1_score,matthews_corrcoef,cohen_kappa_score
from sklearn.neighbors import NearestNeighbors
from sklearn.preprocessing import LabelEncoder
Expand Down
1 change: 0 additions & 1 deletion scmusketeers/tools/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# from keras.engine.base_layer import InputSpec
import keras.backend as K
import tensorflow as tf

# from keras.engine.topology import Layer
from keras.layers import Dense, Lambda

Expand Down
7 changes: 2 additions & 5 deletions scmusketeers/transfer/experiment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import neptune
import pandas as pd

from ..arguments.neptune_log import (
add_custom_log,
start_neptune_log,
stop_neptune_log,
)
from ..arguments.neptune_log import (add_custom_log, start_neptune_log,
stop_neptune_log)
from ..arguments.runfile import set_hyperparameters
from . import dataset_tf
from .optimize_model import Workflow
Expand Down
52 changes: 17 additions & 35 deletions scmusketeers/transfer/optimize_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@
from . import freeze

import keras
from sklearn.metrics import (
accuracy_score,
adjusted_mutual_info_score,
adjusted_rand_score,
balanced_accuracy_score,
cohen_kappa_score,
confusion_matrix,
davies_bouldin_score,
f1_score,
matthews_corrcoef,
normalized_mutual_info_score,
)
from sklearn.metrics import (accuracy_score, adjusted_mutual_info_score,
adjusted_rand_score, balanced_accuracy_score,
cohen_kappa_score, confusion_matrix,
davies_bouldin_score, f1_score, matthews_corrcoef,
normalized_mutual_info_score)
from sklearn.neighbors import KNeighborsClassifier
from sklearn.utils import compute_class_weight

Expand All @@ -53,32 +46,22 @@
from transfer.dataset_tf import Dataset, load_dataset

try:
from ..tools.clust_compute import (
balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score,
lisi_avg,
nn_overlap,
)
from ..tools.clust_compute import (balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score, lisi_avg,
nn_overlap)
from ..tools.models import DANN_AE
from ..tools.permutation import batch_generator_training_permuted
from ..tools.utils import (
default_value,
nan_to_0,
scanpy_to_input,
str2bool,
)
from ..tools.utils import (default_value, nan_to_0, scanpy_to_input,
str2bool)

except ImportError:
from tools.clust_compute import (
balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score,
lisi_avg,
nn_overlap,
)
from tools.clust_compute import (balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score, lisi_avg,
nn_overlap)
from tools.models import DANN_AE
from tools.permutation import batch_generator_training_permuted
from tools.utils import default_value, nan_to_0, scanpy_to_input, str2bool
Expand All @@ -100,7 +83,6 @@
import seaborn as sns
import tensorflow as tf
from ax.service.managed_loop import optimize

# from numba import cuda
from neptune.utils import stringify_unsupported

Expand Down
2 changes: 1 addition & 1 deletion scmusketeers/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import benchmark_models, benchmark, dataset, hyperparameters
from . import benchmark, benchmark_models, dataset, hyperparameters
58 changes: 16 additions & 42 deletions scmusketeers/workflow/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,22 @@
sys.path.insert(1, os.path.join(sys.path[0], ".."))

try:
from .benchmark_models import (
celltypist_model,
harmony_svm,
pca_knn,
pca_svm,
scanvi,
scBalance_model,
scmap_cells,
scmap_cluster,
uce,
)
from .benchmark_models import (celltypist_model, harmony_svm, pca_knn,
pca_svm, scanvi, scBalance_model,
scmap_cells, scmap_cluster, uce)
from .dataset import Dataset, load_dataset
except ImportError:
from workflow.benchmark_models import (
celltypist_model,
harmony_svm,
pca_svm,
scanvi,
scBalance_model,
scmap_cells,
scmap_cluster,
uce,
)
from workflow.benchmark_models import (celltypist_model, harmony_svm,
pca_svm, scanvi, scBalance_model,
scmap_cells, scmap_cluster, uce)
from workflow.dataset import Dataset, load_dataset

try:
from ..tools.clust_compute import (
balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score,
lisi_avg,
nn_overlap,
)
from ..tools.clust_compute import (balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score, lisi_avg,
nn_overlap)
from ..tools.utils import nan_to_0, str2bool
except ImportError:
from tools.utils import str2bool
Expand All @@ -64,18 +46,11 @@
balanced_cohen_kappa_score,
)

from sklearn.metrics import (
accuracy_score,
adjusted_mutual_info_score,
adjusted_rand_score,
balanced_accuracy_score,
cohen_kappa_score,
confusion_matrix,
davies_bouldin_score,
f1_score,
matthews_corrcoef,
normalized_mutual_info_score,
)
from sklearn.metrics import (accuracy_score, adjusted_mutual_info_score,
adjusted_rand_score, balanced_accuracy_score,
cohen_kappa_score, confusion_matrix,
davies_bouldin_score, f1_score, matthews_corrcoef,
normalized_mutual_info_score)
from sklearn.model_selection import GroupKFold

f1_score = functools.partial(f1_score, average="macro")
Expand All @@ -90,7 +65,6 @@
import pandas as pd
import scanpy as sc
import seaborn as sns

# from numba import cuda
from neptune.utils import stringify_unsupported

Expand Down
4 changes: 2 additions & 2 deletions scmusketeers/workflow/benchmark_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from sklearn.neighbors import KNeighborsClassifier

try:
import celltypist
import scanpy.external as sce
from scmappy import common_genes, scmap_annotate
import scBalance as sb
import scBalance.scbalance_IO as ss
import celltypist
import scvi
from scmappy import common_genes, scmap_annotate
except:
pass
import numpy as np
Expand Down
62 changes: 19 additions & 43 deletions scmusketeers/workflow/hyperparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@
import sys

import keras
from sklearn.metrics import (
accuracy_score,
adjusted_mutual_info_score,
adjusted_rand_score,
balanced_accuracy_score,
cohen_kappa_score,
confusion_matrix,
davies_bouldin_score,
f1_score,
matthews_corrcoef,
normalized_mutual_info_score,
)
from sklearn.metrics import (accuracy_score, adjusted_mutual_info_score,
adjusted_rand_score, balanced_accuracy_score,
cohen_kappa_score, confusion_matrix,
davies_bouldin_score, f1_score, matthews_corrcoef,
normalized_mutual_info_score)
from sklearn.neighbors import KNeighborsClassifier
from sklearn.utils import compute_class_weight

Expand All @@ -38,42 +31,26 @@
from workflow.dataset import Dataset, load_dataset

try:
from ..tools.clust_compute import (
balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score,
lisi_avg,
nn_overlap,
)
from ..tools.clust_compute import (balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score, lisi_avg,
nn_overlap)
from ..tools.models import DANN_AE
from ..tools.permutation import batch_generator_training_permuted
from ..tools.utils import (
check_dir,
default_value,
nan_to_0,
scanpy_to_input,
str2bool,
)
from ..tools.utils import (check_dir, default_value, nan_to_0,
scanpy_to_input, str2bool)

except ImportError:
from tools.clust_compute import (
balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score,
lisi_avg,
nn_overlap,
)
from tools.clust_compute import (balanced_cohen_kappa_score,
balanced_f1_score,
balanced_matthews_corrcoef,
batch_entropy_mixing_score, lisi_avg,
nn_overlap)
from tools.models import DANN_AE
from tools.permutation import batch_generator_training_permuted
from tools.utils import (
check_dir,
default_value,
nan_to_0,
scanpy_to_input,
str2bool,
)
from tools.utils import (check_dir, default_value, nan_to_0,
scanpy_to_input, str2bool)


f1_score = functools.partial(f1_score, average="macro")
Expand All @@ -92,7 +69,6 @@
import seaborn as sns
import tensorflow as tf
from ax.service.managed_loop import optimize

# from numba import cuda
from neptune.utils import stringify_unsupported

Expand Down

0 comments on commit 1e33c4e

Please sign in to comment.