diffuseMat function

Generic diffusion function

Generic diffusion function

Generic diffusion function using automated individualised sigma calculation

diffuseMat(data, ndims = 20, nsig = 5, removeFirst = TRUE, useARPACK = TRUE, distfun = NULL, sigmas = NULL, sqdistmat = NULL)

Arguments

  • data: Matrix of data with genes in rows and cells in columns.

  • ndims: Number of dimensions to return

  • nsig: For automatic sigma calculation

  • removeFirst: Default TRUE. Removes the first eigenvector

  • useARPACK: Default TRUE. Uses Arnoldi algorithm for eignvector calculations

  • distfun: A different distance function that returns the squared

    distance

  • sigmas: Manually provide sigma

  • sqdistmat: Squared distance matrix. Give your own squared distance matrix.

Returns

List output containing:

valuesEigenvalues, 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)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 .|

Details

Generic diffusion function using automated individualised sigma calculation.

A Gaussian kernel is applied to the chosen distance metric producing an n×nn \times n square unnormalised symmetric transition matrix, AA. Let DD be an n×nn \times n diagonal matrix with row(column) sums of AA as entries. The density corrected transition matrix will now be:

D1AD1D1AD1 D^{-1} A D^{-1}D^{-1} * A * D^{-1}

and can be normalised:

B1D1AD1B1D1AD1 B^{-1} D^{-1} A D^{-1}B^{-1} * D^{-1} * A * D{^-1}

where BB is an n×nn \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:

B12D1AD1B12R= B^{-\frac{1}{2}} D^{-1} A D^{-1} B^{-\frac{1}{2}} R^\prime = %R^\prime \lambda^\prime%B^{-0.5} * D^{-1} * A * D^{-1} * B^{-0.5} = R^\prime * L^\prime

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

B1D1AD1R=Rλ B^{-1} D^{-1} A D^{-1} R = R \lambda%B^{-1} * D^{-1} * A * D^{-1} * R = R * L

in terms of RR^\prime and B12B^{-\frac{1}{2}} is:

B1D1AD1B12R= B^{-1} D^{-1} A D^{-1} B^{-\frac{1}{2}} R^\prime = %B^{-\frac{1}{2}} R^\prime \lambda^\prime%B^{-1} * D^{-1} * A * D^{-1} * B^{-0.5} = B^{-0.5} * R' * L'

and

R=B12R\primeR=B0.5R R = B^{-\frac{1}{2}} R^\primeR = B^{-0.5} * R'

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

Examples

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

References

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

Haghverdi, L., Büttner, M., Wolf, F.A., Buettner, F., Theis, F.J., 2016. Diffusion pseudotime robustly reconstructs lineage branching. Nat Meth 13, 845–848.

Angerer, P., Haghverdi, L., Büttner, M., Theis, F.J., Marr, C., Buettner, F., 2016. destiny: diffusion maps for large-scale single-cell data in R. Bioinformatics 32, 1241–1243.

Author(s)

Wajid Jawaid

  • Maintainer: Wajid Jawaid
  • License: GPL (>= 2)
  • Last published: 2017-07-11

Useful links