knn_simMat: Calculate stochastic transition matrix between clusters from...

View source: R/knn_simMat.R

knn_simMatR Documentation

Calculate stochastic transition matrix between clusters from a KNN connection matrix

Description

The transition probability from cluster i to j is the fraction of neighbours of all samples in cluster i that belongs to cluster j. Note, this matrix is asymmetric, so as the input KNN connection matrix.

Usage

knn_simMat(KNN_matrix, clusters)

Arguments

KNN_matrix

a sparse binary matrix with size (n_sample, n_sample). x_ij=1 means sample j is a neighbour of sample i. As definition, we expect sum(KNN_matrix) = n_sample * K, where K is the number neighbours.

clusters

a (n_sample, ) vector of cluster id for each sample.

Value

a similarity matrix calculated based on the knn graph.

Examples

data(simulation)
knn_mat = knn_simMat(simulation$knnGraphs, simulation$labels)


huangyh09/DCATS documentation built on Nov. 25, 2022, 7:02 a.m.