Generic diffusion function using automated individualised sigma calculation
diffuseMat(data, ndims = 20, nsig = 5, removeFirst = TRUE,
useARPACK = TRUE, distfun = NULL, sigmas = NULL, sqdistmat = NULL)
Matrix of data with genes in rows and cells in columns.
Number of dimensions to return
For automatic sigma calculation
Default TRUE. Removes the first eigenvector
Default TRUE. Uses Arnoldi algorithm for eignvector calculations
A different distance function that returns the squared distance
Manually provide sigma
Squared distance matrix. Give your own squared distance matrix.
List output containing:
values | Eigenvalues, excluding the first eigenvalue, which should always be 1. |
vectors | Matrix of eigen vectors in columns, first eigen vector removed. |
nconv | Number of eigen vectors/values that converged. |
niter | Iterations taken for Arnoldi algorithm to converge. |
nops | Number of operations. |
val0 | 1st eigen value - should be 1. If not be suspicious! |
vec0 | 1st eigen vector - should be \(n^{-\frac{1}{2}}\), where n is the number of cells/samples. |
usedARPACK | Predicates use of ARPACK for spectral decomposition. |
distfun | Function used to calculate the squared distance. |
nn | Number of nearest neighbours used for calculating sigmas . |
d2 | Matrix of squared distances, returned from distfun . |
sigmas | Vector of sigmas. Same length as number of cells if individual |
sigmas were calculated, otherwise a scalar if was supplied. | |
gaussian | Unnormalised transition matrix after applying Gaussian. |
markov | Normalised gaussian matrix. |
densityCorrected | Matrix after applying density correction to
markov . |
Generic diffusion function using automated individualised sigma calculation.
A Gaussian kernel is applied to the chosen distance metric producing an \(n \times n\) square unnormalised symmetric transition matrix, \(A\). Let \(D\) be an \(n \times n\) diagonal matrix with row(column) sums of \(A\) as entries. The density corrected transition matrix will now be:
$$D^{-1} A D^{-1}$$
and can be normalised:
$$B^{-1} D^{-1} A D^{-1}$$
where \(B\) is an \(n \times n\) diagonal matrix with row sums of the density corrected transition matrix as entries. The eigen decomposition of this matrix can be simplified by solving the symmetric system:
$$B^{-\frac{1}{2}} D^{-1} A D^{-1} B^{-\frac{1}{2}} R^\prime = % R^\prime \lambda^\prime$$
where \(R^\prime\) is a matrix of the right eigenvectors that solve the system and \(\lambda^\prime\) is the corresponding eigenvalue diagonal matrix. Now the solution of:
$$B^{-1} D^{-1} A D^{-1} R = R \lambda$$
in terms of \(R^\prime\) and \(B^{-\frac{1}{2}}\) is:
$$B^{-1} D^{-1} A D^{-1} B^{-\frac{1}{2}} R^\prime = % B^{-\frac{1}{2}} R^\prime \lambda^\prime$$
and
$$R = B^{-\frac{1}{2}} R^\prime$$
This \(R\) without the first eigen vector is returned as the diffusion map.
Haghverdi, L., Buettner, F., Theis, F.J., 2015. Diffusion maps for high-dimensional single-cell analysis of differentiation data. Bioinformatics 31, 2989<U+2013>2998.
Haghverdi, L., B<U+00FC>ttner, M., Wolf, F.A., Buettner, F., Theis, F.J., 2016. Diffusion pseudotime robustly reconstructs lineage branching. Nat Meth 13, 845<U+2013>848.
Angerer, P., Haghverdi, L., B<U+00FC>ttner, M., Theis, F.J., Marr, C., Buettner, F., 2016. destiny: diffusion maps for large-scale single-cell data in R. Bioinformatics 32, 1241<U+2013>1243.
# NOT RUN {
xx <- diffuseMat(x)
# }
Run the code above in your browser using DataLab