From 2d81f11a0ca864b309d67ec36185c8f9e6d96831 Mon Sep 17 00:00:00 2001 From: henninggaertner Date: Mon, 6 Nov 2023 13:40:33 +0100 Subject: [PATCH 1/2] ran pre-commit hooks to fix inconsistencies --- .../differential_expression_linear_model.py | 1 - .../data_analysis/dimension_reduction.py | 1 - .../data_analysis/model_evaluation_plots.py | 1 - .../data_integration/database_download.py | 4 +-- protzilla/data_preprocessing/imputation.py | 28 ++++++++++--------- protzilla/history.py | 1 - .../data_analysis/test_dimension_reduction.py | 1 - .../importing/test_ms_data_import.py | 4 +-- tests/protzilla/test_run_helper.py | 2 +- ui/main/views.py | 5 ++-- 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/protzilla/data_analysis/differential_expression_linear_model.py b/protzilla/data_analysis/differential_expression_linear_model.py index 752b8a0e9..1a0b3440c 100644 --- a/protzilla/data_analysis/differential_expression_linear_model.py +++ b/protzilla/data_analysis/differential_expression_linear_model.py @@ -4,7 +4,6 @@ import pandas as pd import statsmodels.api as sm from django.contrib import messages -from scipy import stats from .differential_expression_helper import apply_multiple_testing_correction diff --git a/protzilla/data_analysis/dimension_reduction.py b/protzilla/data_analysis/dimension_reduction.py index 2b35a6051..d38eab6bc 100644 --- a/protzilla/data_analysis/dimension_reduction.py +++ b/protzilla/data_analysis/dimension_reduction.py @@ -1,4 +1,3 @@ -import numpy as np import pandas as pd from django.contrib import messages from sklearn.manifold import TSNE diff --git a/protzilla/data_analysis/model_evaluation_plots.py b/protzilla/data_analysis/model_evaluation_plots.py index abe146c6b..f1167b210 100644 --- a/protzilla/data_analysis/model_evaluation_plots.py +++ b/protzilla/data_analysis/model_evaluation_plots.py @@ -1,5 +1,4 @@ import matplotlib.pyplot as plt -import pandas as pd from sklearn.metrics import PrecisionRecallDisplay, RocCurveDisplay from protzilla.data_analysis.classification_helper import encode_labels diff --git a/protzilla/data_integration/database_download.py b/protzilla/data_integration/database_download.py index aab79d81a..f8ee4830e 100644 --- a/protzilla/data_integration/database_download.py +++ b/protzilla/data_integration/database_download.py @@ -1,11 +1,11 @@ +import json import re +from datetime import date from pathlib import Path import requests from requests.adapters import HTTPAdapter, Retry from tqdm import tqdm -from datetime import date -import json # cannot be imported form constants as package cannot be found external_data_path = Path(__file__).parent.parent.parent / "user_data" / "external_data" diff --git a/protzilla/data_preprocessing/imputation.py b/protzilla/data_preprocessing/imputation.py index 5245a03f9..14409a2f7 100644 --- a/protzilla/data_preprocessing/imputation.py +++ b/protzilla/data_preprocessing/imputation.py @@ -221,41 +221,43 @@ def by_min_per_dataset( return intensity_df_copy, dict() -def by_knn_plot(df, result_df, current_out, graph_type, graph_type_quantites, group_by): +def by_knn_plot( + df, result_df, current_out, graph_type, graph_type_quantities, group_by +): return _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) def by_simple_imputer_plot( - df, result_df, current_out, graph_type, graph_type_quantites, group_by + df, result_df, current_out, graph_type, graph_type_quantities, group_by ): return _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) def by_min_per_sample_plot( - df, result_df, current_out, graph_type, graph_type_quantites, group_by + df, result_df, current_out, graph_type, graph_type_quantities, group_by ): return _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) def by_min_per_protein_plot( - df, result_df, current_out, graph_type, graph_type_quantites, group_by + df, result_df, current_out, graph_type, graph_type_quantities, group_by ): return _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) def by_min_per_dataset_plot( - df, result_df, current_out, graph_type, graph_type_quantites, group_by + df, result_df, current_out, graph_type, graph_type_quantities, group_by ): return _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) @@ -264,7 +266,7 @@ def number_of_imputed_values(input_df, result_df): def _build_box_hist_plot( - df, result_df, graph_type, graph_type_quantites, group_by + df, result_df, graph_type, graph_type_quantities, group_by ) -> list[Figure]: """ This function creates two visualisations: @@ -300,13 +302,13 @@ def _build_box_hist_plot( abs(len(df)), number_of_imputed_values(df, result_df), ] - if graph_type_quantites == "Bar chart": + if graph_type_quantities == "Bar chart": fig2 = create_bar_plot( names_of_sectors=["Non-imputed values", "Imputed values"], values_of_sectors=values_of_sectors, heading="Number of Imputed Values", ) - elif graph_type_quantites == "Pie chart": + elif graph_type_quantities == "Pie chart": fig2 = create_pie_plot( names_of_sectors=["Non-imputed values", "Imputed values"], values_of_sectors=values_of_sectors, diff --git a/protzilla/history.py b/protzilla/history.py index 6a94f9256..8de6f99fd 100644 --- a/protzilla/history.py +++ b/protzilla/history.py @@ -1,5 +1,4 @@ import json -import os import shutil from dataclasses import dataclass from pathlib import Path diff --git a/tests/protzilla/data_analysis/test_dimension_reduction.py b/tests/protzilla/data_analysis/test_dimension_reduction.py index f1ec39572..4e01be1aa 100644 --- a/tests/protzilla/data_analysis/test_dimension_reduction.py +++ b/tests/protzilla/data_analysis/test_dimension_reduction.py @@ -1,4 +1,3 @@ -import numpy as np import pandas as pd import pytest diff --git a/tests/protzilla/importing/test_ms_data_import.py b/tests/protzilla/importing/test_ms_data_import.py index af186ebfd..0cf0ac6a1 100644 --- a/tests/protzilla/importing/test_ms_data_import.py +++ b/tests/protzilla/importing/test_ms_data_import.py @@ -1,8 +1,8 @@ +from unittest.mock import patch + import numpy as np import pandas as pd import pytest -from unittest.mock import patch - from protzilla.constants.paths import PROJECT_PATH from protzilla.importing import ms_data_import diff --git a/tests/protzilla/test_run_helper.py b/tests/protzilla/test_run_helper.py index a6b8a2fd4..88d6a5e2e 100644 --- a/tests/protzilla/test_run_helper.py +++ b/tests/protzilla/test_run_helper.py @@ -1,5 +1,5 @@ import copy -from unittest.mock import MagicMock, Mock, patch +from unittest.mock import MagicMock, Mock import pandas as pd import pytest diff --git a/ui/main/views.py b/ui/main/views.py index 6b791460a..14e36465d 100644 --- a/ui/main/views.py +++ b/ui/main/views.py @@ -1,7 +1,8 @@ -import shutil -import pandas import json +import shutil from datetime import date + +import pandas from django.contrib import messages from django.http import HttpResponseRedirect from django.shortcuts import redirect, render From b8dd8df7feff2fbb273ea027bc73a7b3ca7e69a9 Mon Sep 17 00:00:00 2001 From: henninggaertner Date: Mon, 6 Nov 2023 17:36:27 +0100 Subject: [PATCH 2/2] fix spelling in all places so that tests all finish --- protzilla/constants/workflow_meta.json | 10 +++++----- tests/protzilla/test_run.py | 4 +++- tests/protzilla/test_runner.py | 2 +- tests/test_workflows/example_workflow.json | 2 +- tests/test_workflows/wrong_parameters.json | 2 +- user_data/workflows/BA46_VolcanoPlot.json | 2 +- user_data/workflows/enrichment_analysis.json | 2 +- user_data/workflows/standard.json | 2 +- user_data/workflows/workflow_gsea.json | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/protzilla/constants/workflow_meta.json b/protzilla/constants/workflow_meta.json index 835568e5c..14ba36f09 100644 --- a/protzilla/constants/workflow_meta.json +++ b/protzilla/constants/workflow_meta.json @@ -475,7 +475,7 @@ } }, { - "graph_type_quantites": { + "graph_type_quantities": { "name": "Graph type Imputed Values:", "type": "categorical", "categories": [ @@ -522,7 +522,7 @@ } }, { - "graph_type_quantites": { + "graph_type_quantities": { "name": "Graph type Imputed Values:", "type": "categorical", "categories": [ @@ -569,7 +569,7 @@ } }, { - "graph_type_quantites": { + "graph_type_quantities": { "name": "Graph type Imputed Values:", "type": "categorical", "categories": [ @@ -619,7 +619,7 @@ } }, { - "graph_type_quantites": { + "graph_type_quantities": { "name": "Graph type Imputed Values:", "type": "categorical", "categories": [ @@ -666,7 +666,7 @@ } }, { - "graph_type_quantites": { + "graph_type_quantities": { "name": "Graph type - Imputed Values:", "type": "categorical", "categories": [ diff --git a/tests/protzilla/test_run.py b/tests/protzilla/test_run.py index aea477319..436a8ca05 100644 --- a/tests/protzilla/test_run.py +++ b/tests/protzilla/test_run.py @@ -251,7 +251,9 @@ def test_export_plot(tests_folder_name): run.perform_calculation(data_preprocessing.imputation.by_min_per_sample, {}) run.create_plot( data_preprocessing.imputation.by_min_per_sample_plot, - dict(graph_type="Boxplot", graph_type_quantites="Bar chart", group_by="Sample"), + dict( + graph_type="Boxplot", graph_type_quantities="Bar chart", group_by="Sample" + ), ) assert len(run.plots) > 1 for plot in run.export_plots("tiff"): diff --git a/tests/protzilla/test_runner.py b/tests/protzilla/test_runner.py index 618c9eed9..7bb31388a 100644 --- a/tests/protzilla/test_runner.py +++ b/tests/protzilla/test_runner.py @@ -176,7 +176,7 @@ def test_serialize_workflow_graphs(): serial_imputation_graphs = { "graph_type": "Bar chart", "group_by": "Sample", - "graph_type_quantites": "Pie chart", + "graph_type_quantities": "Pie chart", } serial_filter_graphs = {"graph_type": "Pie chart"} diff --git a/tests/test_workflows/example_workflow.json b/tests/test_workflows/example_workflow.json index d6a465d1a..8a978dd8b 100644 --- a/tests/test_workflows/example_workflow.json +++ b/tests/test_workflows/example_workflow.json @@ -57,7 +57,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Pie chart" + "graph_type_quantities": "Pie chart" } ] }, diff --git a/tests/test_workflows/wrong_parameters.json b/tests/test_workflows/wrong_parameters.json index 73ee4be37..893d790f9 100644 --- a/tests/test_workflows/wrong_parameters.json +++ b/tests/test_workflows/wrong_parameters.json @@ -18,7 +18,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Bar chart" + "graph_type_quantities": "Bar chart" } ] } diff --git a/user_data/workflows/BA46_VolcanoPlot.json b/user_data/workflows/BA46_VolcanoPlot.json index 9e1081c9a..1d8b1d6a4 100644 --- a/user_data/workflows/BA46_VolcanoPlot.json +++ b/user_data/workflows/BA46_VolcanoPlot.json @@ -59,7 +59,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Pie chart" + "graph_type_quantities": "Pie chart" } ], "output_name": null diff --git a/user_data/workflows/enrichment_analysis.json b/user_data/workflows/enrichment_analysis.json index 2ef35afe7..247ff9aba 100644 --- a/user_data/workflows/enrichment_analysis.json +++ b/user_data/workflows/enrichment_analysis.json @@ -57,7 +57,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Pie chart" + "graph_type_quantities": "Pie chart" } ] }, diff --git a/user_data/workflows/standard.json b/user_data/workflows/standard.json index fd146a0da..eec360472 100644 --- a/user_data/workflows/standard.json +++ b/user_data/workflows/standard.json @@ -57,7 +57,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Pie chart" + "graph_type_quantities": "Pie chart" } ] }, diff --git a/user_data/workflows/workflow_gsea.json b/user_data/workflows/workflow_gsea.json index d17d7f55f..f9a9eb8a7 100644 --- a/user_data/workflows/workflow_gsea.json +++ b/user_data/workflows/workflow_gsea.json @@ -61,7 +61,7 @@ "group_by": "Sample" }, { - "graph_type_quantites": "Pie chart" + "graph_type_quantities": "Pie chart" } ], "output_name": null