projectedNeighbors: Computes composite distances between all cell pairs and...

View source: R/projectedNeighbors.R

projectedNeighborsR Documentation

Computes composite distances between all cell pairs and returns k-nearest neighbors and edge weights needed to build VeloViz graph.

Description

Computes composite distances between all cell pairs and returns k-nearest neighbors and edge weights needed to build VeloViz graph.

Usage

projectedNeighbors(
  observed,
  projected,
  k,
  distance_metric = "L2",
  similarity_metric = "cosine",
  distance_weight = 1,
  distance_threshold = 1,
  similarity_threshold = -1
)

Arguments

observed

PCs (rows) x cells (columns) matrix of observed transcriptional state projected into PC space

projected

PCs (rows) x cells (columns) matrix of projected transcriptional states. Cells should be in same order as in observed

k

Number of nearest neighbors to assign each cell

distance_metric

Method to compute distance component of composite distance. "L1" or "L2", default = "L2"

similarity_metric

Method to compute similarity between velocity and cell transition matrices. "cosine" or "pearson", default = "cosine"

distance_weight

Weight of distance component of composite distance, default = 1

distance_threshold

quantile threshold for distance component above which to remove edges, default = 1 i.e. no edges removed

similarity_threshold

similarity threshold below which to remove edges, default = -1 i.e. no edges removed

Value

kNNs cells (rows) x k (columns) matrix of indices of each cell's nearest neighbors computed based on composite distance. Edges removed based on distance or similarity threshold will be NA.

edge_weights cells (rows) x k (columns) matrix of edge weights computed based on composite distance. Edges removed based on distance or similarity threshold will be NA.

all_dists cells x cells matrix of all pairwise composite distances

dist_comp components of composite distance: invDist distance component, negSim similarity component

See Also

graphViz

Examples

data(vel)
curr <- vel$current
proj <- vel$projected

projectedNeighbors(curr, proj, 10)


JEFworks-Lab/veloviz documentation built on Sept. 14, 2022, 4:03 p.m.