diffuseMat: Generic diffusion function

Description Usage Arguments Details Value Author(s) References Examples

View source: R/diffusion.r


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.


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^{-0.5} * D^{-1} * A * D^{-1} * B^{-0.5} = R^\prime * L^\prime

where R^\prime is a matrix of the right eigenvectors that solve the system and L' is the corresponding eigenvalue diagonal matrix. Now the solution of:

B^{-1} * D^{-1} * A * D^{-1} * R = R * L

in terms of R^\prime and B^{-\frac{1}{2}} is:

B^{-1} * D^{-1} * A * D^{-1} * B^{-0.5} = B^{-0.5} * R' * L'


R = B^{-0.5} * R'

This R without the first eigen vector is returned as the diffusion map.


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 1/sqrt(n), 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.


Wajid Jawaid


Haghverdi, L., Buettner, F., Theis, F.J., 2015. Diffusion maps for high-dimensional single-cell analysis of differentiation data. Bioinformatics 31, 2989<e2><80><93>2998.

Haghverdi, L., B<c3><bc>ttner, M., Wolf, F.A., Buettner, F., Theis, F.J., 2016. Diffusion pseudotime robustly reconstructs lineage branching. Nat Meth 13, 845<e2><80><93>848.

Angerer, P., Haghverdi, L., B<c3><bc>ttner, M., Theis, F.J., Marr, C., Buettner, F., 2016. destiny: diffusion maps for large-scale single-cell data in R. Bioinformatics 32, 1241<e2><80><93>1243.


## Not run: 
xx <- diffuseMat(x)

## End(Not run)

wjawaid/roots documentation built on Sept. 12, 2017, 9:51 a.m.