Beispiel #1
0
def crossCompartmentCorr(dfA, dfB, method='pearson'):
    """Cytokine correlation for those that are common to both A and B"""
    cyList = np.array([cy for cy in dfA.columns if cy in dfB.columns])
    joinedDf = pd.merge(dfA[cyList], dfB[cyList], suffixes=('_A','_B'), left_index=True, right_index=True)
    tmpCorr = np.zeros((len(cyList),3))
    for i,cy in enumerate(cyList):
        tmp = joinedDf[[cy + '_A',cy + '_B']].dropna()
        tmpCorr[i,:2] = partialcorr(tmp[cy + '_A'], tmp[cy + '_B'], method=method)
    sorti = np.argsort(tmpCorr[:,0])
    tmpCorr = tmpCorr[sorti,:]
    _, tmpCorr[:,2], _, _ = sm.stats.multipletests(tmpCorr[:,1], method='fdr_bh')
    return pd.DataFrame(tmpCorr, index=cyList[sorti], columns=['rho','pvalue','qvalue'])
Beispiel #2
0
def meanCorr(cyDf, meanVar, cyList=None, method='pearson'):
    """Each cytokine's correlation with the mean."""
    if cyList is None:
        cyList = np.array([c for c in cyDf.columns if not c == meanVar])
    cyList = np.asarray(cyList)

    tmpCorr = np.zeros((len(cyList), 3))
    for i, s in enumerate(cyList):
        tmpCorr[i, :2] = partialcorr(cyDf[s], cyDf[meanVar], method=method)
    sorti = np.argsort(tmpCorr[:, 0])
    tmpCorr = tmpCorr[sorti,:]
    _, tmpCorr[:, 2], _, _ = sm.stats.multipletests(tmpCorr[:, 1], alpha=0.2, method='fdr_bh')
    return pd.DataFrame(tmpCorr, index=cyList[sorti], columns=['rho', 'pvalue', 'qvalue'])
Beispiel #3
0
def meanCorr(cyDf, meanVar, cyList=None, method='pearson'):
    """Each cytokine's correlation with the mean."""
    if cyList is None:
        cyList = np.array([c for c in cyDf.columns if not c == meanVar])
    cyList = np.asarray(cyList)

    tmpCorr = np.zeros((len(cyList),3))
    for i,s in enumerate(cyList):
        tmpCorr[i,:2] = partialcorr(cyDf[s], cyDf[meanVar], method=method)
    sorti = np.argsort(tmpCorr[:,0])
    tmpCorr = tmpCorr[sorti,:]
    _, tmpCorr[:,2], _, _ = sm.stats.multipletests(tmpCorr[:,1], alpha=0.2, method='fdr_bh')
    return pd.DataFrame(tmpCorr, index=cyList[sorti], columns=['rho','pvalue','qvalue'])
Beispiel #4
0
def crossCompartmentCorr(dfA, dfB, method='pearson'):
    """Cytokine correlation for those that are common to both A and B"""
    cyList = np.array([cy for cy in dfA.columns if cy in dfB.columns])
    joinedDf = pd.merge(dfA[cyList],
                        dfB[cyList],
                        suffixes=('_A', '_B'),
                        left_index=True,
                        right_index=True)
    tmpCorr = np.zeros((len(cyList), 3))
    for i, cy in enumerate(cyList):
        tmp = joinedDf[[cy + '_A', cy + '_B']].dropna()
        tmpCorr[i, :2] = partialcorr(tmp[cy + '_A'],
                                     tmp[cy + '_B'],
                                     method=method)
    sorti = np.argsort(tmpCorr[:, 0])
    tmpCorr = tmpCorr[sorti, :]
    _, tmpCorr[:, 2], _, _ = sm.stats.multipletests(tmpCorr[:, 1],
                                                    method='fdr_bh')
    return pd.DataFrame(tmpCorr,
                        index=cyList[sorti],
                        columns=['rho', 'pvalue', 'qvalue'])