src/proteingnn/example/util.py
def visual_pssm_corr(rootdir: Optional[AnyPath] = None, exp_data: Optional[Union[Dict, OrderedDict]] = None,
                     pssm: Optional[AnyPath] = None, **kwargs) -> CorrType:
    """Plot pssm to log2enrichment experiment data and evaluate correlations.

    Args:
        exp_data: Dictionary of mutant name and experiment data, i.e. {mut_name: y}
        pssm: Path to pssm file from psiblast.
        rootdir: Destination directory for exp-pssm.png.
        kwargs: Keyword arguments for seaborn.jointplot.
    """
    if exp_data is None:
        exp_data = read_log2en(return_type='OrderedDict')

    dpssm = pssm2D(pssm=pssm, return_type='OrderedDict', relative=True)  # difference compared to wildtype
    for mut in exp_data.copy():
        if mut not in dpssm:
            warnings.warn(f'{mut} not found in pssm. Skipped.')
            del exp_data[mut]

    dpssm = [dpssm[u] for u in exp_data.keys()]
    exp_data = list(exp_data.values())

    df = pd.DataFrame(zip(exp_data, dpssm), columns=['log2en', 'pssm'])
    jg = sns.jointplot(x=df['pssm'], y=df['log2en'], **kwargs)

    png = 'exp-pssm.png'
    if rootdir is not None:
        png = Path(rootdir) / png
    plt.savefig(png)
    plt.close()

    src = scipy.stats.spearmanr(exp_data, dpssm)
    corr_dict = {
        'pcc': scipy.stats.pearsonr(exp_data, dpssm),
        'src': (src.correlation, src.pvalue),
    }
    return corr_dict
Plot pssm to log2enrichment experiment data and evaluate correlations.

    Args:
        exp_data: Dictionary of mutant name and experiment data, i.e. {mut_name: y}
        pssm: Path to pssm file from psiblast.
        rootdir: Destination directory for exp-pssm.png.
        kwargs: Keyword arguments for seaborn.jointplot.
    
Plot pssm to log2enrichment experiment data and evaluate correlations.
Plot pssm to log2enrichment experiment data and evaluate correlations .
def visual_pssm_corr(rootdir: Optional[AnyPath] = None, exp_data: Optional[Union[Dict, OrderedDict]] = None,
                     pssm: Optional[AnyPath] = None, **kwargs) -> CorrType:
    if exp_data is None:
        exp_data = read_log2en(return_type='OrderedDict')
    dpssm = pssm2D(pssm=pssm, return_type='OrderedDict', relative=True)  
    for mut in exp_data.copy():
        if mut not in dpssm:
            warnings.warn(f'{mut} not found in pssm. Skipped.')
            del exp_data[mut]
    dpssm = [dpssm[u] for u in exp_data.keys()]
    exp_data = list(exp_data.values())
    df = pd.DataFrame(zip(exp_data, dpssm), columns=['log2en', 'pssm'])
    jg = sns.jointplot(x=df['pssm'], y=df['log2en'], **kwargs)
    png = 'exp-pssm.png'
    if rootdir is not None:
        png = Path(rootdir) / png
    plt.savefig(png)
    plt.close()
    src = scipy.stats.spearmanr(exp_data, dpssm)
    corr_dict = {
        'pcc': scipy.stats.pearsonr(exp_data, dpssm),
        'src': (src.correlation, src.pvalue),
    }
    return corr_dict
def visual_pssm_corr ( rootdir : Optional [ AnyPath ] = None , exp_data : Optional [ Union [ Dict , OrderedDict ] ] = None , pssm : Optional [ AnyPath ] = None , ** kwargs ) -> CorrType : if exp_data is None : exp_data = read_log2en ( return_type = 'OrderedDict' ) dpssm = pssm2D ( pssm = pssm , return_type = 'OrderedDict' , relative = True ) for mut in exp_data . copy ( ) : if mut not in dpssm : warnings . warn ( f'{mut} not found in pssm. Skipped.' ) del exp_data [ mut ] dpssm = [ dpssm [ u ] for u in exp_data . keys ( ) ] exp_data = list ( exp_data . values ( ) ) df = pd . DataFrame ( zip ( exp_data , dpssm ) , columns = [ 'log2en' , 'pssm' ] ) jg = sns . jointplot ( x = df [ 'pssm' ] , y = df [ 'log2en' ] , ** kwargs ) png = 'exp-pssm.png' if rootdir is not None : png = Path ( rootdir ) / png plt . savefig ( png ) plt . close ( ) src = scipy . stats . spearmanr ( exp_data , dpssm ) corr_dict = { 'pcc' : scipy . stats . pearsonr ( exp_data , dpssm ) , 'src' : ( src . correlation , src . pvalue ) , } return corr_dict
Plot pssm to log2enrichment experiment data and evaluate correlations.
Plot pssm to log2enrichment experiment data and evaluate correlations .
"""Plot pssm to log2enrichment experiment data and evaluate correlations.

    Args:
        exp_data: Dictionary of mutant name and experiment data, i.e. {mut_name: y}
        pssm: Path to pssm file from psiblast.
        rootdir: Destination directory for exp-pssm.png.
        kwargs: Keyword arguments for seaborn.jointplot.
    """ # difference compared to wildtype
rootdir
Optional[AnyPath]
Destination directory for exp-pssm.png.
Destination directory for exp - pssm . png .
exp_data
Optional[Union[Dict, OrderedDict]]
Dictionary of mutant name and experiment data, i.e. {mut_name: y}
Dictionary of mutant name and experiment data i . e . { mut_name : y }
pssm
Optional[AnyPath]
Path to pssm file from psiblast.
Path to pssm file from psiblast .
kwargs
Keyword arguments for seaborn.jointplot.
Keyword arguments for seaborn . jointplot .