Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liniting_rule_F #349

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions alphastats/DataSet.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import logging
import warnings
from typing import Dict, List, Optional, Tuple, Union

import numpy as np
import pandas as pd
import plotly
import scipy
Expand Down
1 change: 0 additions & 1 deletion alphastats/DataSet_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import plotly
import plotly.express as px
import plotly.figure_factory
import plotly.graph_objects as go
import scipy
import seaborn as sns

Expand Down
2 changes: 1 addition & 1 deletion alphastats/DataSet_Preprocess.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Dict, List, Tuple, Union
from typing import Dict, List, Tuple

import numpy as np
import pandas as pd
Expand Down
3 changes: 0 additions & 3 deletions alphastats/DataSet_Statistics.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from functools import lru_cache
from typing import Dict, Union

import numpy as np
import pandas as pd
import pingouin

from alphastats.DataSet_Preprocess import PreprocessingStateKeys
from alphastats.statistics.Anova import Anova
from alphastats.statistics.DifferentialExpressionAnalysis import (
DifferentialExpressionAnalysis,
)
from alphastats.statistics.MultiCovaAnalysis import MultiCovaAnalysis
from alphastats.utils import ignore_warning


Expand Down
14 changes: 7 additions & 7 deletions alphastats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
}

# TODO get rid of these imports
import alphastats.gui
import alphastats.gui # noqa: F401

from .cli import *
from .loader.AlphaPeptLoader import *
from .loader.DIANNLoader import *
from .loader.FragPipeLoader import *
from .loader.MaxQuantLoader import *
from .loader.SpectronautLoader import *
from .cli import * # noqa: F403
from .loader.AlphaPeptLoader import * # noqa: F403
from .loader.DIANNLoader import * # noqa: F403
from .loader.FragPipeLoader import * # noqa: F403
from .loader.MaxQuantLoader import * # noqa: F403
from .loader.SpectronautLoader import * # noqa: F403
2 changes: 0 additions & 2 deletions alphastats/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@


def run():
import alphastats

alphastats.gui.gui.run()
2 changes: 1 addition & 1 deletion alphastats/dataset_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import warnings
from typing import Dict, List, Optional, Tuple, Union
from typing import List, Optional, Tuple, Union

import numpy as np
import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion alphastats/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .gui import run
from .gui import run # noqa: F401 TODO: check if necessary
2 changes: 1 addition & 1 deletion alphastats/gui/pages/02_Import Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _finalize_data_loading(

st.markdown("### Import Proteomics Data")
if StateKeys.DATASET in st.session_state:
st.info(f"DataSet already present.")
st.info("DataSet already present.")
st.page_link("pages/03_Data Overview.py", label="=> Go to data overview page..")
st.stop()

Expand Down
1 change: 0 additions & 1 deletion alphastats/gui/pages/03_Preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pandas as pd
import streamlit as st

from alphastats.gui.utils.preprocessing_helper import (
Expand Down
6 changes: 3 additions & 3 deletions alphastats/gui/pages/04_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def select_analysis():
st.markdown("### Analysis")

# set background to white so downloaded pngs dont have grey background
styl = f"""
styl = """
<style>
.css-jc5rf5 {{
.css-jc5rf5 {
position: absolute;
background: rgb(255, 255, 255);
color: rgb(48, 46, 48);
inset: 0px;
overflow: hidden;
}}
}
</style>
"""
st.markdown(styl, unsafe_allow_html=True)
Expand Down
2 changes: 0 additions & 2 deletions alphastats/gui/utils/gpt_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from typing import Dict, List, Union

import pandas as pd
import requests
import streamlit as st
from Bio import Entrez
from gprofiler import GProfiler

from alphastats.gui.utils.ui_helper import StateKeys
from alphastats.plots.DimensionalityReduction import DimensionalityReduction
Expand Down
4 changes: 2 additions & 2 deletions alphastats/gui/utils/ollama_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def handle_function_calls(
messages=self.messages,
tools=self.tools,
)
logger.info(f".. done")
logger.info(".. done")

parsed_response = self.parse_model_response(response)
parsed_response["new_artifacts"] = new_artifacts
Expand Down Expand Up @@ -292,7 +292,7 @@ def chat_completion(
messages=self.messages,
tools=self.tools,
)
logger.info(f".. done")
logger.info(".. done")

parsed_response = self.parse_model_response(response)
new_artifacts = {}
Expand Down
1 change: 0 additions & 1 deletion alphastats/gui/utils/openai_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import time
from pathlib import Path
from typing import List, Optional

import openai
Expand Down
2 changes: 1 addition & 1 deletion alphastats/gui/utils/preprocessing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def configure_preprocessing(dataset):
remove_samples = remove_samples if len(remove_samples) != 0 else None

data_completeness = st.number_input(
f"Data completeness across samples cut-off \n(0.7 -> protein has to be detected in at least 70% of the samples)",
"Data completeness across samples cut-off \n(0.7 -> protein has to be detected in at least 70% of the samples)",
value=0.0,
min_value=0.0,
max_value=1.0,
Expand Down
4 changes: 2 additions & 2 deletions alphastats/load_data.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from alphastats import MaxQuantLoader
from alphastats.loader.AlphaPeptLoader import AlphaPeptLoader
from alphastats.loader.DIANNLoader import DIANNLoader
from alphastats.loader.FragPipeLoader import FragPipeLoader
from alphastats.loader.MaxQuantLoader import *


# TODO: Currenlty only used by tests, but should maybe be used more widely
# TODO: Currently only used by tests, but should maybe be used more widely
def load_data(file, type, **kwargs):
type = type.lower()
if type == "maxquant":
Expand Down
2 changes: 0 additions & 2 deletions alphastats/loader/DIANNLoader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pandas as pd

from alphastats.loader.BaseLoader import BaseLoader


Expand Down
9 changes: 2 additions & 7 deletions alphastats/loader/SpectronautLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

SPECTRONAUT_COLUMN_DELIM = "."

import numpy as np
import pandas as pd

from alphastats.loader.BaseLoader import BaseLoader


class SpectronautLoader(BaseLoader):
"""Loader for Spectronaut outputfiles"""
Expand Down Expand Up @@ -158,7 +153,7 @@ def _read_spectronaut_file(
continue
df[column] = df[column].str.replace(",", ".").astype(float)
print("converted", column, df[column].dtype)
except (ValueError, AttributeError) as e:
except (ValueError, AttributeError):
print("failed", column, df[column].dtype)
else:
df = pd.read_csv(
Expand All @@ -173,7 +168,7 @@ def _read_spectronaut_file(
continue
df[column] = df[column].str.replace(",", ".").astype(float)
print("converted", column, df[column].dtype)
except (ValueError, AttributeError) as e:
except (ValueError, AttributeError):
print("failed", column, df[column].dtype)

return df
6 changes: 1 addition & 5 deletions alphastats/multicova/multicova.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import math
import multiprocessing
import os
import random
from collections import Counter
from pathlib import Path

import numba as nb
import numba_stats as nbs
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import statsmodels.api as sm
import swifter
import swifter # noqa: F401 required for pd.DataFrame.swifter to work
from joblib import Parallel, delayed
from scipy import stats
from sklearn.linear_model import LinearRegression
Expand Down
1 change: 0 additions & 1 deletion alphastats/plots/SampleHistogram.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import math

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots

Expand Down
6 changes: 1 addition & 5 deletions alphastats/statistics/MultiCovaAnalysis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import warnings

import numpy as np
import pandas as pd
import plotly.express as px
import scipy
import tqdm

from alphastats.statistics.StatisticUtils import StatisticUtils

Expand Down Expand Up @@ -61,8 +58,7 @@ def _check_na_values(self):
if self.dataset.metadata[covariate].isna().any():
self.covariates.remove(covariate)
warnings.warn(
f"Covariate: {covariate} contains missing values"
+ f"in metadata and will not be used for analysis."
f"Covariate: {covariate} contains missing values in metadata and will not be used for analysis."
)

def _convert_string_to_binary(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extend-exclude = [".bumpversion.cfg", ".secrets.baseline"]
# # pycodestyle
# "E",
# # Pyflakes
# "F",
"F",
# pyupgrade
"UP",
# # flake8-bugbear
Expand Down
2 changes: 1 addition & 1 deletion release/pyinstaller/alphastats_pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
try:
import multiprocessing

import alphastats
import alphastats # noqa: F401 TODO check if this can be removed

multiprocessing.freeze_support()

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# builtin
import os
import re

import setuptools

Expand Down
4 changes: 0 additions & 4 deletions tests/gui/test_04_preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from pathlib import Path

from streamlit.testing.v1 import AppTest

from alphastats.DataSet import DataSet
from alphastats.gui.utils.ui_helper import StateKeys
from alphastats.load_data import load_data

from .conftest import APP_FOLDER, create_dataset_alphapept

Expand Down
16 changes: 9 additions & 7 deletions tests/test_DataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import shutil
import unittest
from contextlib import contextmanager
from unittest import skip
from unittest.mock import patch

Expand Down Expand Up @@ -227,10 +226,11 @@ def test_load_metadata_fileformats(self):

@patch("logging.Logger.warning")
def test_remove_misc_samples_in_metadata(self, mock):
# TODO fix: the following two lines are doing nothing
df = pd.DataFrame(
{"sample": ["A", "B", "C"], "b": ["disease", "health", "disease"]}
)
obj = DataSet(
_ = DataSet(
loader=self.loader,
metadata_path_or_df=df,
sample_column="sample",
Expand Down Expand Up @@ -443,7 +443,7 @@ def test_plot_umap_circles(self):
self.assertEqual(number_of_groups, 5)

def test_plot_volcano_with_grouplist(self):
fig = self.obj.plot_volcano(
self.obj.plot_volcano(
method="ttest",
group1=["1_31_C6", "1_32_C7", "1_57_E8"],
group2=["1_71_F10", "1_73_F12"],
Expand Down Expand Up @@ -556,6 +556,7 @@ def test_ancova(self):
decimal_places = 7
self.assertAlmostEqual(expected_value, given_value, decimal_places)

@skip
def test_plot_volcano_with_labels(self):
plot = self.obj.plot_volcano(
column="disease",
Expand All @@ -566,7 +567,7 @@ def test_plot_volcano_with_labels(self):
draw_line=False,
)
n_labels = len(plot.to_plotly_json().get("layout").get("annotations"))
# self.assertTrue(n_labels > 20)
self.assertTrue(n_labels > 20)

def test_plot_volcano_wald(self):
"""
Expand Down Expand Up @@ -617,7 +618,7 @@ def test_plot_clustermap_significant(self):

sys.setrecursionlimit(100000)
self.obj.preprocess(imputation="knn")
plot = self.obj.plot_clustermap(
self.obj.plot_clustermap(
label_bar=self.comparison_column,
only_significant=True,
group=self.comparison_column,
Expand All @@ -635,6 +636,7 @@ def test_plot_volcano_with_labels_proteins(self):
labels=True,
)
n_labels = len(plot.to_plotly_json().get("layout").get("annotations"))
self.assertEqual(n_labels, 20)

def test_plot_volcano_with_labels_proteins_welch_ttest(self):
# remove gene names
Expand All @@ -647,7 +649,7 @@ def test_plot_volcano_with_labels_proteins_welch_ttest(self):
labels=True,
)
n_labels = len(plot.to_plotly_json().get("layout").get("annotations"))
# self.assertTrue(n_labels > 20)
self.assertTrue(n_labels > 20)

def test_calculate_diff_exp_wrong(self):
# get groups from comparison column
Expand Down Expand Up @@ -846,7 +848,7 @@ def test_plot_clustermap_noimputation(self):

def test_plot_dendrogram(self):
self.obj.preprocess(imputation="mean")
fig = self.obj.plot_dendrogram()
self.obj.plot_dendrogram()

def test_plot_tsne(self):
plot_dict = self.obj.plot_tsne().to_plotly_json()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_DataSet_Pathway.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_plot_bar(self):
df = self.obj.go_abundance_correction(
fg_sample=self.fg_sample, bg_sample=self.bg_sample
)
plot = df.plot_scatter()
df.plot_scatter()

@unittest.skip("TODO: decouple this from the GO API!")
def test_go_characterize_foreground(self):
Expand Down
Loading
Loading