Laplacian {MMOC} | R Documentation |
Calculate the graph Laplacian from a given adjacency matrix
Description
Calculate the graph laplacian from a given kernel matrix that represents the full graph weighted adjacency matrix
Usage
Laplacian(
A,
laplacian = c("shift", "Ng", "sym", "rw"),
grf.type = c("full", "knn", "e-graph"),
k = 5,
rho = NULL,
epsilon = 0,
mutual = FALSE,
binary.grf = FALSE,
plots = TRUE
)
Arguments
A |
An n by n kernel matrix, where n is the sample size, that represents your initial adjacency matrix. Kernel matrices are symmetric, positive semi-definite distance matrices |
laplacian |
One of |
grf.type |
Type of graph to calculate: |
k |
An integer value for |
rho |
A value for the dispersion parameter in the Gaussian kernel. It is in the denominator of the exponent, so higher values correspond to lower similarity. By default it is the median pairwise Gaussian distance |
epsilon |
The cutoff value for the |
mutual |
Make a "mutual" knn graph. Only keeps edges when two nodes are both in each others k-nearest set |
binary.grf |
Set all edges >0 to 1 |
plots |
Whether or not to plot the final graph, a heatmap of calculated kernel, and the eigen values of the Laplacian |
Details
The four Lapalacians are defined as L_{shift}=I+D^{-1/2}AD^{-1/2}
, L_{Ng}=D^{-1/2}AD^{-1/2}
, L_{sym}=I-D^{-1/2}AD^{-1/2}
, and L_{rw}=I-D^{-1}A
. The shifted Laplacian, L_{shift}=I+D^{-1/2}AD^{-1/2}
, is recommended for multi-view spectral clustering.
Value
An n\times
n matrix where n
is the number of rows in dat
.
References
https://academic.oup.com/bioinformatics/article/36/4/1159/5566508#199177546
Examples
## Generating data with 3 distinct clusters
## Note that 'clustStruct' returns a list
dd <- clustStruct(n=120, p=30, k=3, noiseDat='random')[[1]]
## Gaussian kernel
rho <- median(dist(dd))
A <- exp(-(1/rho)*as.matrix(dist(dd, method = "euclidean", upper = TRUE)^2))
Laplacian(A, laplacian='shift', grf.type = 'knn')