weighted_graph: Construct a weighted graph adjacency matrix

Description Usage Arguments Value Examples

View source: R/embeddr.R

Description

Construct a weighted graph adjacency matrix

Usage

1
2
3
4
weighted_graph(x, kernel = c("nn", "dist", "heat"),
  metric = c("correlation", "euclidean", "cosine"),
  nn = round(log(ncol(x))), eps = NULL, t = NULL, symmetrize = c("mean",
  "ceil", "floor"))

Arguments

x

The feature-by-sample (e.g. genes are rows, cells are columns) data matrix

kernel

The choice of kernel. 'nn' will give nearest neighbours, 'dist' gives minimum distance and 'heat' gives a heat kernel. Discussed in detail in 'Laplacian Eigenmaps and Spectral Techniques for Embedding and Clustering', Belkin & Niyogi

metric

The metric with which to assess 'closeness' for nearest neighbour selection, one of 'correlation' (pearson) or 'euclidean'. Default is 'correlation'.

nn

Number of nearest neighbours if kernel == 'nn'

eps

Maximum distance parameter if kernel == 'dist'

t

'time' for heat kernel if kernel == 'heat'

symmetrize

How to make the adjacency matrix symmetric. Note that slightly counterintuitively, node i having node j as a nearest neighbour doesn't guarantee node j has node i. There are several ways to get round this:

  • mean If the above case occurs make the link weight 0.5 so the adjacency matrix becomes 0.5(A + A')

  • ceil If the above case occurs set the link weight to 1 (ie take the ceiling of the mean case)

  • floor If the above case occurs set the link weight to 0 (ie take the floor of the mean case)

Value

An n by n adjacency matrix

Examples

1
2
x <- matrix(rnorm(50), ncol = 10) # synthetic data matrix
wg <- weighted_graph(x)

kieranrcampbell/embeddr documentation built on May 20, 2019, 9:24 a.m.