defineMSTPaths: Define paths through the MST

View source: R/defineMSTPaths.R

defineMSTPathsR Documentation

Define paths through the MST


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


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



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


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


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.


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.


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.


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.


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.


Aaron Lun

See Also

guessMSTRoots, to obtain roots without any prior information.

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


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 Feb. 5, 2024, 11:56 a.m.