lama/stats/permutation_stats/distributions.py
def null_line(wt_indx_combinations: dict,
              data: pd.DataFrame,
              num_perms=1000) -> pd.DataFrame:
    """
    Generate pvalue null distributions for all labels in 'data'
    NaN values are excluded potentailly resultnig in different sets of specimens for each label. This makes it tricky to
    use Rs vectorised lm() function, so we use statsmodels here and just loop over the data, with each label in its own
    process using joblib.

    Parameters
    ----------
    line_specimen_counts
        The number of specimens in each mutant line. Used to specify the number of synthetic mutants so the null
        matches our data in terms of sample number
    data
        Label data in each column except last 2 which are 'staging' and 'genotype'
    num_perms
        Usually about 10000

    Returns
    -------
    DataFrame of null distributions. Each label in a column

    Notes
    -----
    If QC has been applied to the data, we may have some NANs
    """

    def prepare(label):
        return data[[label, 'staging', 'genotype']]

    data = data.rename(columns={'line': 'genotype'})

    starttime = datetime.datetime.now()

    cols = list(data.drop(['staging', 'genotype'], axis='columns').columns)

    # Run each label on a thread
    pdists = Parallel(n_jobs=-1)(delayed(_null_line_thread)
                                 (prepare(i), num_perms, wt_indx_combinations, i) for i in tqdm(cols))

    line_pdsist_df = pd.DataFrame(pdists).T
    line_pdsist_df.columns = cols

    endtime = datetime.datetime.now()
    elapsed = endtime - starttime
    print(f'Time taken for null distribution calculation: {elapsed}')
    return line_pdsist_df

    Generate pvalue null distributions for all labels in 'data'
    NaN values are excluded potentailly resultnig in different sets of specimens for each label. This makes it tricky to
    use Rs vectorised lm() function, so we use statsmodels here and just loop over the data, with each label in its own
    process using joblib.

    Parameters
    ----------
    line_specimen_counts
        The number of specimens in each mutant line. Used to specify the number of synthetic mutants so the null
        matches our data in terms of sample number
    data
        Label data in each column except last 2 which are 'staging' and 'genotype'
    num_perms
        Usually about 10000

    Returns
    -------
    DataFrame of null distributions. Each label in a column

    Notes
    -----
    If QC has been applied to the data, we may have some NANs
    
Generate pvalue null distributions for all labels in 'data'
NaN values are excluded potentailly resultnig in different sets of specimens for each label. This makes it tricky to
use Rs vectorised lm() function, so we use statsmodels here and just loop over the data, with each label in its own
process using joblib.

Parameters

line_specimen_counts
The number of specimens in each mutant line. Used to specify the number of synthetic mutants so the null
matches our data in terms of sample number
data
Label data in each column except last 2 which are 'staging' and 'genotype'
num_perms
Usually about 10000

Returns

DataFrame of null distributions. Each label in a column

Notes

If QC has been applied to the data, we may have some NANs
Generate pvalue null distributions for all labels in ' data ' NaN values are excluded potentailly resultnig in different sets of specimens for each label . This makes it tricky to use Rs vectorised lm () function so we use statsmodels here and just loop over the data with each label in its own process using joblib . Parameters line_specimen_counts The number of specimens in each mutant line . Used to specify the number of synthetic mutants so the null matches our data in terms of sample number data Label data in each column except last 2 which are ' staging ' and ' genotype ' num_perms Usually about 10000 Returns DataFrame of null distributions . Each label in a column Notes If QC has been applied to the data we may have some NANs
def null_line(wt_indx_combinations: dict,
              data: pd.DataFrame,
              num_perms=1000) -> pd.DataFrame:
    def prepare(label):
        return data[[label, 'staging', 'genotype']]
    data = data.rename(columns={'line': 'genotype'})
    starttime = datetime.datetime.now()
    cols = list(data.drop(['staging', 'genotype'], axis='columns').columns)
    pdists = Parallel(n_jobs=-1)(delayed(_null_line_thread)
                                 (prepare(i), num_perms, wt_indx_combinations, i) for i in tqdm(cols))
    line_pdsist_df = pd.DataFrame(pdists).T
    line_pdsist_df.columns = cols
    endtime = datetime.datetime.now()
    elapsed = endtime - starttime
    print(f'Time taken for null distribution calculation: {elapsed}')
    return line_pdsist_df
def null_line ( wt_indx_combinations : dict , data : pd . DataFrame , num_perms = 1000 ) -> pd . DataFrame : def prepare ( label ) : return data [ [ label , 'staging' , 'genotype' ] ] data = data . rename ( columns = { 'line' : 'genotype' } ) starttime = datetime . datetime . now ( ) cols = list ( data . drop ( [ 'staging' , 'genotype' ] , axis = 'columns' ) . columns ) pdists = Parallel ( n_jobs = - 1 ) ( delayed ( _null_line_thread ) ( prepare ( i ) , num_perms , wt_indx_combinations , i ) for i in tqdm ( cols ) ) line_pdsist_df = pd . DataFrame ( pdists ) . T line_pdsist_df . columns = cols endtime = datetime . datetime . now ( ) elapsed = endtime - starttime print ( f'Time taken for null distribution calculation: {elapsed}' ) return line_pdsist_df
Generate pvalue null distributions for all labels in 'data'
NaN values are excluded potentailly resultnig in different sets of specimens for each label.
Generate pvalue null distributions for all labels in ' data ' NaN values are excluded potentailly resultnig in different sets of specimens for each label .
"""
    Generate pvalue null distributions for all labels in 'data'
    NaN values are excluded potentailly resultnig in different sets of specimens for each label. This makes it tricky to
    use Rs vectorised lm() function, so we use statsmodels here and just loop over the data, with each label in its own
    process using joblib.

    Parameters
    ----------
    line_specimen_counts
        The number of specimens in each mutant line. Used to specify the number of synthetic mutants so the null
        matches our data in terms of sample number
    data
        Label data in each column except last 2 which are 'staging' and 'genotype'
    num_perms
        Usually about 10000

    Returns
    -------
    DataFrame of null distributions. Each label in a column

    Notes
    -----
    If QC has been applied to the data, we may have some NANs
    """ # Run each label on a thread
wt_indx_combinations
dict
data
pd.DataFrame
num_perms