BioProfileKit 1.0.0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- analysis/__init__.py +6 -0
- analysis/categorical_analysis.py +47 -0
- analysis/data_quality.py +62 -0
- analysis/multivariate_analysis.py +612 -0
- analysis/numeric_analysis.py +77 -0
- analysis/outlier_detection.py +68 -0
- analysis/overview.py +153 -0
- analysis/plot_utils.py +119 -0
- biological/__init__.py +6 -0
- biological/functional_annotation.py +271 -0
- biological/measurement_data.py +50 -0
- biological/plot_utils.py +189 -0
- biological/sequence_data.py +466 -0
- biological/sequence_detection.py +61 -0
- biological/taxonomy.py +286 -0
- biological/taxonomy_utils.py +47 -0
- biological/uniprot_swissprot.py +172 -0
- bioprofilekit-1.0.0.dist-info/METADATA +223 -0
- bioprofilekit-1.0.0.dist-info/RECORD +102 -0
- bioprofilekit-1.0.0.dist-info/WHEEL +5 -0
- bioprofilekit-1.0.0.dist-info/entry_points.txt +3 -0
- bioprofilekit-1.0.0.dist-info/licenses/LICENSE +21 -0
- bioprofilekit-1.0.0.dist-info/top_level.txt +10 -0
- cli/__init__.py +1 -0
- cli/app.py +202 -0
- cli/report_flags.py +199 -0
- cli/report_json.py +356 -0
- cli/report_writer.py +57 -0
- cli/update_remote_data.py +64 -0
- cli/utils.py +27 -0
- cython_wrapper/__init__.py +0 -0
- cython_wrapper/medcouple_fast.c +17110 -0
- cython_wrapper/medcouple_fast.cp314-win_amd64.pyd +0 -0
- cython_wrapper/medcouple_fast.pyx +176 -0
- cython_wrapper/taxonomy_validator.c +10121 -0
- cython_wrapper/taxonomy_validator.cp314-win_amd64.pyd +0 -0
- cython_wrapper/taxonomy_validator.pyx +68 -0
- cython_wrapper/wrapper_utils.c +10079 -0
- cython_wrapper/wrapper_utils.cp314-win_amd64.pyd +0 -0
- cython_wrapper/wrapper_utils.pyx +62 -0
- data_utils/__init__.py +2 -0
- data_utils/file_reader.py +91 -0
- data_utils/remote_data.py +249 -0
- enums/__init__.py +3 -0
- enums/cog_enum.py +54 -0
- enums/measurement_enum.py +8 -0
- enums/sequence_enum.py +7 -0
- models/__init__.py +8 -0
- models/categorical.py +22 -0
- models/measurement.py +9 -0
- models/multivariate.py +30 -0
- models/numeric.py +30 -0
- models/outliers.py +20 -0
- models/overview.py +50 -0
- models/quality.py +26 -0
- models/sequence.py +77 -0
- quality_assessment/__init__.py +1 -0
- quality_assessment/biological_quality.py +163 -0
- quality_assessment/column_quality.py +150 -0
- quality_assessment/dataset_quality.py +70 -0
- quality_assessment/quality_assessment.py +83 -0
- quality_assessment/relationships.py +42 -0
- quality_assessment/utils.py +10 -0
- static/__init__.py +0 -0
- static/assets/__init__.py +0 -0
- static/assets/favicon/__init__.py +0 -0
- static/assets/favicon/android-chrome-192x192.png +0 -0
- static/assets/favicon/android-chrome-512x512.png +0 -0
- static/assets/favicon/favicon-16x16.png +0 -0
- static/assets/favicon/favicon-32x32.png +0 -0
- static/assets/favicon.ico +0 -0
- static/assets/github.svg +3 -0
- static/assets/logo.png +0 -0
- static/css/__init__.py +0 -0
- static/css/bootstrap-grid.css +4085 -0
- static/css/bootstrap-grid.rtl.css +4084 -0
- static/css/bootstrap-reboot.css +597 -0
- static/css/bootstrap-reboot.rtl.css +594 -0
- static/css/bootstrap-utilities.css +5402 -0
- static/css/bootstrap-utilities.rtl.css +5393 -0
- static/css/bootstrap.css +12063 -0
- static/css/bootstrap.rtl.css +12030 -0
- static/css/cb.css +410 -0
- static/js/__init__.py +0 -0
- static/js/bootstrap.bundle.js +6314 -0
- static/js/bootstrap.bundle.js.map +1 -0
- static/js/bootstrap.bundle.min.js +7 -0
- static/js/bootstrap.bundle.min.js.map +1 -0
- static/js/bootstrap.esm.js +4447 -0
- static/js/bootstrap.esm.js.map +1 -0
- static/js/bootstrap.esm.min.js +7 -0
- static/js/bootstrap.esm.min.js.map +1 -0
- static/js/bootstrap.js +4494 -0
- static/js/bootstrap.js.map +1 -0
- static/js/bootstrap.min.js +7 -0
- static/js/bootstrap.min.js.map +1 -0
- static/js/bpk_plot.js +30 -0
- templates/LandingPage.jinja +136 -0
- templates/__init__.py +0 -0
- templates/columns.jinja +3208 -0
- templates/general_statistics.jinja +735 -0
- templates/numeric_overview.jinja +611 -0
analysis/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from .overview import overview, column_overview
|
|
2
|
+
from .numeric_analysis import numeric_columns
|
|
3
|
+
from .categorical_analysis import categorical_columns
|
|
4
|
+
from .multivariate_analysis import get_correlation, multivariate_analysis
|
|
5
|
+
from .data_quality import check_mixed_types, check_suspect_values
|
|
6
|
+
from .plot_utils import plot_overview, fig_html, _config
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
from models.categorical import CategoricalColumns
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def categorical_columns(df: pd.DataFrame, col: str, top_n: int = 20) -> CategoricalColumns:
|
|
8
|
+
value_counts = df[col].value_counts()
|
|
9
|
+
n = int(df[col].notna().sum())
|
|
10
|
+
frequencies = value_counts / n if n > 0 else value_counts
|
|
11
|
+
rare = np.sum(value_counts <= value_counts.sum() * 0.01)
|
|
12
|
+
cib_ratio = value_counts.max() / value_counts.min()
|
|
13
|
+
top_coverage = df[col].value_counts(normalize=True).head(5).sum()
|
|
14
|
+
|
|
15
|
+
if n > 0:
|
|
16
|
+
entropy = -(frequencies * np.log2(frequencies)).sum()
|
|
17
|
+
gini = 1 - (frequencies ** 2).sum()
|
|
18
|
+
simpson = 1 / (frequencies ** 2).sum()
|
|
19
|
+
cardinality_ratio = df[col].nunique() / n
|
|
20
|
+
mode_value = df[col].mode().iloc[0]
|
|
21
|
+
else:
|
|
22
|
+
entropy = np.nan
|
|
23
|
+
gini = np.nan
|
|
24
|
+
simpson = np.nan
|
|
25
|
+
cardinality_ratio = np.nan
|
|
26
|
+
mode_value = ""
|
|
27
|
+
lengths = df[col].astype(str).str.len()
|
|
28
|
+
|
|
29
|
+
return CategoricalColumns(
|
|
30
|
+
name=col,
|
|
31
|
+
unique_categories=df[col].nunique(),
|
|
32
|
+
mode=mode_value,
|
|
33
|
+
entropy=round(entropy, 2),
|
|
34
|
+
frequencies=df[col].value_counts(normalize=True).head(top_n).to_dict(),
|
|
35
|
+
gini=round(gini, 2),
|
|
36
|
+
simpson_diversity=round(simpson, 2),
|
|
37
|
+
value_counts=df[col].value_counts().head(top_n).to_dict(),
|
|
38
|
+
max_category_length=lengths.max(),
|
|
39
|
+
min_category_length=lengths.min(),
|
|
40
|
+
cardinality_ratio=round(cardinality_ratio, 3),
|
|
41
|
+
rare_categories=rare,
|
|
42
|
+
top_5_coverage=top_coverage,
|
|
43
|
+
cib_ratio=cib_ratio,
|
|
44
|
+
top_1_coverage=(df[col].value_counts(normalize=True).max() if n > 0 else np.nan), # Near Zero Variance (NZV)
|
|
45
|
+
effective_cardinality=((df[col].nunique()/len(df[col]))*100),
|
|
46
|
+
memory = df[col].memory_usage(deep=True),
|
|
47
|
+
)
|
analysis/data_quality.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from pandas.api.types import infer_dtype
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _split_numeric_string(series):
|
|
7
|
+
inferred = infer_dtype(series)
|
|
8
|
+
|
|
9
|
+
if 'mixed' in inferred:
|
|
10
|
+
is_numeric = series.apply(lambda x: isinstance(x, (int, float, complex)))
|
|
11
|
+
return series[is_numeric], series[~is_numeric]
|
|
12
|
+
|
|
13
|
+
if str(series.dtype) in ('str', 'string', 'object'):
|
|
14
|
+
numeric_mask = pd.to_numeric(series, errors='coerce').notna() & series.notna()
|
|
15
|
+
return series[numeric_mask], series[~numeric_mask]
|
|
16
|
+
|
|
17
|
+
return None, None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def check_mixed_types(df, col, suspect_threshold=0.125):
|
|
21
|
+
series = df[col].dropna()
|
|
22
|
+
if series.empty:
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
numeric_part, string_part = _split_numeric_string(series)
|
|
26
|
+
if numeric_part is None or len(numeric_part) == 0 or len(string_part) == 0:
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
minority_count = min(len(numeric_part), len(string_part))
|
|
30
|
+
minority_ratio = minority_count / len(series)
|
|
31
|
+
if len(numeric_part) >= len(string_part):
|
|
32
|
+
majority_type = "Numeric"
|
|
33
|
+
minority = string_part
|
|
34
|
+
else:
|
|
35
|
+
majority_type = "String"
|
|
36
|
+
minority = numeric_part
|
|
37
|
+
|
|
38
|
+
if minority_ratio < suspect_threshold:
|
|
39
|
+
return majority_type, minority
|
|
40
|
+
else:
|
|
41
|
+
return majority_type, None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def check_suspect_values(df, col):
|
|
45
|
+
series = df[col].dropna()
|
|
46
|
+
if series.empty:
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
if str(series.dtype) in ('str', 'string', 'object'):
|
|
50
|
+
numeric_part, _ = _split_numeric_string(series)
|
|
51
|
+
if numeric_part is None or len(numeric_part) == 0:
|
|
52
|
+
return None
|
|
53
|
+
if len(numeric_part) / len(series) < 0.15:
|
|
54
|
+
return numeric_part
|
|
55
|
+
|
|
56
|
+
if pd.api.types.is_numeric_dtype(series):
|
|
57
|
+
sentinels = {np.inf, -np.inf}
|
|
58
|
+
found = [v for v in sentinels if v in series.values]
|
|
59
|
+
if found:
|
|
60
|
+
return pd.Series([str(v) for v in found])
|
|
61
|
+
|
|
62
|
+
return None
|