def ttest_1samp(df, is_log2=False, fillna=None):
    """
    Perform 1 sample t-test on a dataframe df1

     The mean of
    each group is calculated along the y-axis (per protein) and used to generate a log2 ratio. If a log2-transformed
    dataset is supplied set `islog2=True` (a warning will be given when negative values are present).

    :param df: Pandas `dataframe`
    :param is_log2: `bool` is the data log2 transformed already?
    :param fillna: `float` fill NaN values with value (default: 0)
    :return:
    """
    df = df.copy()

    if np.any(df.values[~pd.isnull(df.values)] < 0) and not is_log2:
        warnings.warn("Input data has negative values. If data is log2 transformed, set is_log2=True.")

    if fillna is not None:
        df = df.fillna(fillna)

    g1 = df[a].values

    # Calculate the p value one sample t
    g1 = np.ma.masked_where(np.isnan(g1), g1)
    t, p = sp.stats.mstats.ttest_1samp(g1.T, popmean=0)

    p = np.array(p)  # Unmask

    return np.array(t), np.array(p)
def ttest_1samp ( df , is_log2 = False , fillna = None ) : df = df . copy ( ) if np . any ( df . values [ ~ pd . isnull ( df . values ) ] < 0 ) and not is_log2 : warnings . warn ( "Input data has negative values. If data is log2 transformed, set is_log2=True." ) if fillna is not None : df = df . fillna ( fillna ) g1 = df [ a ] . values g1 = np . ma . masked_where ( np . isnan ( g1 ) , g1 ) t , p = sp . stats . mstats . ttest_1samp ( g1 . T , popmean = 0 ) p = np . array ( p ) return np . array ( t ) , np . array ( p )
Perform 1 sample t-test on a dataframe df1

     The mean of
    each group is calculated along the y-axis (per protein) and used to generate a log2 ratio. If a log2-transformed
    dataset is supplied set `islog2=True` (a warning will be given when negative values are present).

    :param df: Pandas `dataframe`
    :param is_log2: `bool` is the data log2 transformed already?
    :param fillna: `float` fill NaN values with value (default: 0)
    :return: