提交 f20c1f47 编写于 作者: rictjo's avatar rictjo

associations

上级 d0b41ff2
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name = "impetuous-gfa",
version = "0.49.1",
version = "0.50.0",
author = "Richard Tjörnhammar",
author_email = "richard.tjornhammar@gmail.com",
description = "Impetuous Quantification, a Statistical Learning library for Humans : Alignments, Clustering, Enrichments and Group Analysis",
......
......@@ -468,6 +468,33 @@ def multivariate_factorisation ( analyte_df , journal_df , formula ,
return ( res_df )
def associations ( M , W = None , bRanked = True ) :
ispanda = lambda P : 'pandas' in str(type(P)).lower()
if not ispanda( M ) :
print ( "FUNCTION ",'recast_alignments'," REQUIRES ", 'M'," TO BE A PANDAS DATAFRAME" )
bValid = False
if not W is None :
if not len(W.columns.values) == len(M.columns.values):
W = M
else:
bValid = True
else :
W = M
if bRanked :
from scipy.stats import rankdata
M = ( M.T.apply(lambda x:rankdata(x,'average')).T-0.5 )/len(M.columns)
W = ( W.T.apply(lambda x:rankdata(x,'average')).T-0.5 )/len(W.columns)
rho1 = M.T.apply( lambda x:np.sqrt( np.dot( x,x ) ) )
rho2 = rho1
if bValid :
rho2 = W.T.apply( lambda x:np.sqrt( np.dot( x,x ) ) )
R2 = pd.DataFrame( np.array([np.array([r]) for r in rho1.values])*[rho2.values] ,
index = rho1.index, columns = rho2.index )
PQ = pd.DataFrame( np.dot( M,W.T ), index = rho1.index, columns = rho2.index )
res = PQ/R2
return ( res )
crop = lambda x,W:x[:,:W]
def run_shape_alignment_regression( analyte_df , journal_df , formula ,
bVerbose = False , synonyms = None , blur_cutoff = 99.8 ,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册