/
You are viewing the documentation for metbit 7.3.12. Change release context

metbit.utility

Statistics and utilities module in metbit 7.3.12.

import metbit.utility

Classes

lazypair

Methods

__init__(self, dataset, column_name)
get_index(self)
get_name(self)
get_meta(self)
get_column_name(self)
get_dataset(self)

gen_page

Methods

__init__(self, data_path)

This function takes in the path to the data folder and returns the HTML files for the OPLS-DA plots.

Parameters

data_pathstr

The path to the data folder. gen_page(data_path).get_files()

get_files(self)

oplsda_path

Methods

__init__(self, data_path)
make_path(self)
get_path(self)

Normality_distribution

Methods

__init__(self, data: pd.DataFrame)
plot_distribution(self, feature)
pca_distributions(self)

Normalise

Methods

__init__(self, data: pd.DataFrame, compute_missing: bool=True)

This function takes in a dataframe and returns the normalised dataframe.

Parameters

datapandas dataframe

The dataframe to be used. Normalise(data).normalise()

pqn_normalise(self, ref_index: list=None, plot: bool=True)
decimal_place_normalisation(self, decimals: int=2)

This function returns the dataframe with values rounded to a specified number of decimal places.

Parameters

decimalsint

The number of decimal places to round to.

z_score_normalisation(self)

This function returns the dataframe normalized using Z-Score.

linear_normalisation(self)

This function returns the dataframe normalized using Min-Max (linear normalization).

normalize_to_100(self)

This function returns the dataframe with values normalized to 100.

clipping_normalisation(self, lower: float, upper: float)

This function returns the dataframe with values clipped to the specified range.

Parameters

lowerfloat

The lower bound for clipping.

upperfloat

The upper bound for clipping.

standard_deviation_normalisation(self)

This function returns the dataframe normalized using Standard Deviation.

univar_stats

A class for creating univariate box or violin plots with statistical annotations.

This class supports group comparisons using t-tests, ANOVA, or nonparametric tests, along with effect size computation and multiple testing correction. It outputs interactive Plotly figures.

Parameters

dfpd.DataFrame

Input DataFrame containing the data to plot.

x_colstr

Column name to use for grouping (x-axis categories).

y_colstr

Column name for numeric values (y-axis).

group_orderlist, optional

Custom group ordering (default: inferred from data).

custom_colorsdict, optional

Mapping of group names to Plotly color codes.

stats_optionslist of str, optional

Statistical options to apply. Choices: ['t-test', 'anova', 'nonparametric', 'effect-size'].

p_value_thresholdfloat, default=0.05

Significance threshold for annotations.

annotate_stylestr, default='value'

Annotation format. 'value' shows p-values, 'symbol' shows *, **, ***.

y_offset_factorfloat, default=0.35

Controls vertical spacing of annotation lines.

show_non_significantbool, default=True

Show non-significant comparisons or not.

correct_pstr or None, default='bonferroni'

Correction method for multiple comparisons (e.g., 'bonferroni', 'fdr_bh').

title_str, optional

Plot title. Defaults to y_col if not set.

y_labelstr, optional

Label for y-axis. Defaults to y_col.

x_labelstr, optional

Label for x-axis. Defaults to x_col.

fig_heightint, default=800

Height of the plot in pixels.

fig_widthint, default=600

Width of the plot in pixels.

plot_typestr, default='box'
Type of plot'box' or 'violin'.
show_axis_linesbool, default=True

Whether to show axis lines around the plot.

Returns

plotly.graph_objects.Figure Interactive Plotly figure.

Examples

>>> import pandas as pd >>> from univar_stats import univar_stats >>> import numpy as np

>>> # Create example data >>> df = pd.DataFrame({ ... "group": np.repeat(["A", "B", "C"], 30), ... "value": np.concatenate([ ... np.random.normal(5, 1, 30), ... np.random.normal(6, 1, 30), ... np.random.normal(7, 1, 30) ... ]) ... })

>>> # Initialize the plotting object >>> plotter = univar_stats( ... df, x_col="group", y_col="value", ... stats_options=["t-test", "effect-size"], ... annotate_style="symbol", plot_type="box" ... )

>>> # Generate and show the plot >>> fig = plotter.plot() >>> fig.show()

Methods

__init__(self, df, x_col, y_col, group_order=None, custom_colors=None, stats_options=None, p_value_threshold=0.05, annotate_style='value', y_offset_factor=0.35, show_non_significant=True, correct_p='bonferroni', title_=None, y_label=None, x_label=None, fig_height=800, fig_width=600, plot_type='box', show_axis_lines=True)
plot(self)

Functions

project_name_generator()

Source

metbit/utility.py at v7.3.12
Downloads for metbit 7.3.12PyPI and GitHub measure different distribution channels. Statistics refresh daily.

Counts are distribution activity, not unique users. GitHub source archives and Git clones are not included. Sources: PyPI Stats, Pepy, ClickPy, and GitHub Releases.

metbit 7.3.12 documentation