defineMSTPaths: Define paths through the MST

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/defineMSTPaths.R

Description

Define paths through the MST, either from pre-specified root nodes or based on external timing information.

Usage

1
defineMSTPaths(g, roots, times = NULL, clusters = NULL, use.median = FALSE)

Arguments

g

A graph object containing a minimum spanning tree, e.g., from createClusterMST.

roots

A character vector specifying the root node for each component in g.

times

A numeric vector of length equal to the number of nodes in g, specifying the external time associated with each node. This should be named with the name of each node. Alternatively, a numeric vector of length equal to the number of cells, in which case clusters must be specified.

clusters

A vector or factor specifying the assigned cluster for each cell, where each cluster corresponds to a node in g.

Alternatively, a matrix with number of rows equal to nrow(x), containing soft assignment weights for each cluster (column). All weights should be positive and sum to 1 for each row.

This only has an effect if times is set to a vector of length equal to the number of cells.

use.median

Logical scalar indicating whether the time for each cluster is defined as the median time across its cells. The mean is used by default. This only has an effect if clusters is specified.

Details

When roots is specified, a path is defined from the root to each endpoint node (i.e., with degree 1) in g. We expect one root node to be specified for each component in g.

When times is specified, a path is defined from each local minima in time to the nearest local maxima within each component of g. Timing information can be defined from experimental metadata or with computational methods like RNA velocity.

Value

A list of character vectors. Each vector contains the names of nodes in g and defines a path through the MST from a root to an endpoint node.

Author(s)

Aaron Lun

See Also

guessMSTRoots, to obtain roots without any prior information.

splitByBranches, for a root-free way of obtaining paths.

Examples

1
2
3
4
5
6
7
8
library(igraph)
test.g <- make_graph(c("A", "B", "B", "C", "B", "D"), directed=FALSE)
defineMSTPaths(test.g, roots="A")
defineMSTPaths(test.g, roots="B")

defineMSTPaths(test.g, times=c(A=0, B=1, C=2, D=3))
defineMSTPaths(test.g, times=c(A=0, B=-1, C=2, D=3))
defineMSTPaths(test.g, times=c(A=0, B=5, C=2, D=3))

LTLA/TrajectoryUtils documentation built on Aug. 8, 2021, 8:51 a.m.