Calculate the graph laplacian from a given data set with subjects as rows and features as columns.
kernelLaplacian(
dat,
kernel = c("Gaussian", "ZM", "Spectrum", "Linear"),
laplacian = c("shift", "Ng", "sym", "rw"),
grf.type = c("full", "knn", "e-graph"),
k = 5,
p = 5,
rho = NULL,
epsilon = 0,
mutual = FALSE,
binary.grf = FALSE,
plots = TRUE,
verbose = TRUE
)An n\(\times\)n matrix where n is the number of rows in dat.
A matrix like object with subjects as rows and features as columns.
The type of kernel used to calculate the graph's adjacency matrix: "Gaussian" for the standard Gaussian kernel, "ZM" for the Zelnik-Manor kernel, "Spectrum" for the spectrum kernel, "Linear" for the linear kernel (dot product), and "Cor" for a kernel of pairwise correlations. See references for more details.
One of "shift", "Ng", "rw" or "sym". See details for description
Type of graph to calculate: "full" for adjacency matrix equal to the kernel, "knn" for a k-nearest neighbors graph, "e-graph" for an "epsilon graph"
An integer value for k in the k-nearest neighbors graph. Only the k largest edges (most similar neighbors) will be kept
An integer value for the p-nearest neighbor in the ZM kernel
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
The cutoff value for the e-graph. Edges lower than this value will be removed
Make a "mutual" knn graph. Only keeps edges when two nodes are both in each others k-nearest set
Set all edges >0 to 1
Whether or not to plot the final graph, a heatmap of calculated kernel, and the eigen values of the Laplacian
Whether or not to give some summary statistics of the pairwise distances
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.
https://academic.oup.com/bioinformatics/article/36/4/1159/5566508#199177546
## Generating data with 3 distinct clusters
## Note that 'clustStruct' returns a list
dd <- clustStruct(n=120, p=30, k=3, noiseDat='random')[[1]]
kernelLaplacian(dd, kernel="Spectrum")
Run the code above in your browser using DataLab