You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I am wondering which variable represent the distance matrix that can be used in other dimensional reduction algorithms? I checked the codes and tried to use the affinity matrix (kernel), but it dosen't seem to be right.
calculation of kernel:
data=np.reshape(st_data.obsm['COVET_SQRT'], [st_data.obsm['COVET_SQRT'].shape[0], -1])
k=30nbrs=sklearn.neighbors.NearestNeighbors(n_neighbors=int(k), metric='euclidean', n_jobs=5).fit(data)
kNN=nbrs.kneighbors_graph(data, mode='distance')
# Adaptive k adaptive_k=int(np.floor(k/3))
nbrs=sklearn.neighbors.NearestNeighbors(n_neighbors=int(adaptive_k),
metric='euclidean', n_jobs=5).fit(data)
adaptive_std=nbrs.kneighbors_graph(data, mode='distance').max(axis=1)
adaptive_std=np.ravel(adaptive_std.todense())
# Kernelx, y, dists=scipy.sparse.find(kNN)
# X, y specific stds dists=dists/adaptive_std[x]
N=data.shape[0]
W=scipy.sparse.csr_matrix((np.exp(-dists), (x, y)), shape=[N, N])
# Diffusion componentskernel=W+W.T
calculation of UMAP
st_data.obsp['ME_D_mat'] =kernel# number of neighbors is set to construct ME graphn_neighbors=200sc.pp.neighbors(st_data, n_neighbors=n_neighbors)
kernel=kernel.toarray()
knn_indices, knn_dists, forest=sc.neighbors.compute_neighbors_umap(kernel, n_neighbors=n_neighbors, metric='precomputed' )
st_data.obsp['distances'], st_data.obsp['connectivities'] =sc.neighbors._compute_connectivities_umap(
knn_indices,
knn_dists,
st_data.shape[0],
n_neighbors, # change to neighbors you plan to use
)
# set the ME graph's associated information (connectivity matrix, distance matrix) to neighbors_COVETst_data.uns['neighbors_COVET'] =st_data.uns['neighbors'].copy()
sc.tl.umap(st_data,neighbors_key='neighbors_COVET')
st_data.obsm['X_umap_COVET'] =st_data.obsm['X_umap']
sc.tl.leiden(st_data,neighbors_key='neighbors_COVET',key_added='leiden_COVET')
sc.pl.embedding(st_data,basis='X_umap_COVET',color='leiden_COVET')
the result UAMP graph is very different from the FDL algorithm.
The text was updated successfully, but these errors were encountered:
Hi! I am wondering which variable represent the distance matrix that can be used in other dimensional reduction algorithms? I checked the codes and tried to use the affinity matrix (kernel), but it dosen't seem to be right.
calculation of kernel:
calculation of UMAP
the result UAMP graph is very different from the FDL algorithm.
The text was updated successfully, but these errors were encountered: