|
def embedDistanceMatrix(dmatDf, method='kpca', n_components=2, **kwargs): |
|
"""Two-dimensional embedding of sequence distances in dmatDf, |
|
returning Nx2 x,y-coords: tsne, isomap, pca, mds, kpca, sklearn-tsne""" |
|
if isinstance(dmatDf, pd.DataFrame): |
|
dmat = dmatDf.values |
|
else: |
|
dmat = dmatDf |
Note that the upper portion of the function is meant to accomodate either numpy.array or pd.DataFrame passed to dmatDf, but if numpy array is supplied then L111 will raise an error:
|
xyDf = pd.DataFrame(xy[:, :n_components], index=dmatDf.index, columns=np.arange(n_components)) |
Example
embedDistanceMatrix(dmatDf = pd.DataFrame(tr.pw_beta[0:10,:][:,0:10]), method = "mds")
👍
embedDistanceMatrix(dmatDf = tr.pw_beta[0:10,:][:,0:10], method = "mds")
👎
AttributeError: 'numpy.ndarray' object has no attribute 'index'
utils/embedding.py
Lines 63 to 69 in b61935a
Note that the upper portion of the function is meant to accomodate either numpy.array or pd.DataFrame passed to dmatDf, but if numpy array is supplied then L111 will raise an error:
utils/embedding.py
Line 111 in b61935a
Example
👍
👎