proteometer.utils ================= .. py:module:: proteometer.utils Functions --------- .. autoapisummary:: proteometer.utils.flatten proteometer.utils.generate_index proteometer.utils.check_missingness proteometer.utils.filter_missingness proteometer.utils.expsum Module Contents --------------- .. py:function:: flatten(s: List[Any]) -> List[Any] Flattens a nested list into a single list. :param s: A list that may contain nested lists. :type s: List[Any] :returns: A flattened list containing all elements from the input list. :rtype: List[Any] .. py:function:: generate_index(df: pandas.DataFrame, prot_col: str, level_col: str | None = None, id_separator: str = '@', id_col: str = 'id') -> pandas.DataFrame Generate a unique index for a DataFrame based on protein column identifier and optional level column identifier. :param df: Input DataFrame. :type df: pd.DataFrame :param prot_col: Column name for protein identifiers. :type prot_col: str :param level_col: Column name for level identifiers. Defaults to None. :type level_col: str | None, optional :param id_separator: Separator for combining protein and level identifiers. Defaults to "@". :type id_separator: str, optional :param id_col: Name of the new column for the generated index. Defaults to "id". :type id_col: str, optional :returns: DataFrame with the generated index. :rtype: pd.DataFrame .. py:function:: check_missingness(df: pandas.DataFrame, groups: collections.abc.Sequence[str], group_cols: collections.abc.Sequence[collections.abc.Sequence[str]]) -> pandas.DataFrame Calculate missingness for specified groups in a DataFrame. :param df: Input DataFrame. :type df: pd.DataFrame :param groups: Names of the groups. :type groups: Sequence[str] :param group_cols: Columns corresponding to each group. :type group_cols: Sequence[Sequence[str]] :returns: DataFrame with missingness information added. :rtype: pd.DataFrame .. py:function:: filter_missingness(df: pandas.DataFrame, groups: collections.abc.Sequence[str], group_cols: collections.abc.Sequence[collections.abc.Sequence[str]], min_replicates_qc: int = 2, method: Literal['all', 'any'] = 'any') -> pandas.DataFrame Filter rows in a DataFrame based on missingness thresholds for specified groups. :param df: Input DataFrame. :type df: pd.DataFrame :param groups: Names of the groups. :type groups: Sequence[str] :param group_cols: Columns corresponding to each group. :type group_cols: Sequence[Sequence[str]] :param min_replicates_qc: Threshold for minimal number of replicates that are not NA. Defaults to 2. :type min_replicates_qc: float, optional :param method: Method for filtering. Can be "all" or "any". Defaults to "all". If "all", all groups must meet the threshold. If "any", at least one group must meet the threshold. :type method: str, optional :returns: Filtered DataFrame. :rtype: pd.DataFrame .. py:function:: expsum(x: pandas.Series[float]) -> float