Constructing zenpaths and tools for extracting, connecting and displaying pairs, as well as grouping and indexing data structures.
Usage
zenpath(x, pairs = NULL,
method = c("front.loaded", "back.loaded",
"balanced", "eulerian.cross",
"greedy.weighted", "strictly.weighted"),
decreasing = TRUE)Arguments
- x
-
method
- pairs
a two-column
matrixcontaining (row-wise) the pairs of connected variables to be sorted according to the weights. Note that the resulting graph must be connected (i.e. any variable can be reached from any other variable following the connections given bypairs). Thepairsargument is only used for themethodsgreedy.weightedandstrictly.weightedand can beNULL(in which case a default is constructed in lexicographical order).- method
characterstring indicating the sorting method to be used. Available methods are:"front.loaded":Sort all pairs such that the first variables appear the most frequently early in the sequence; an Eulerian path; note that it might be slightly longer than the number of pairs because, first, an even graph has to be made.
"back.loaded":Sort all pairs such that the later variables appear the most frequently later in the sequence; an Eulerian path (+ see front.loaded concerning length)
"balanced":Sort all pairs such that all variables appear in balanced blocks throughout the sequence (a Hamiltonian Decomposition; Eulerian, too).
"eulerian.cross":Generate a sequence of pairs such that each is formed with one variable from each group.
"greedy.weighted":Sort all pairs according to a greedy (heuristic) Euler path with
xas weights visiting each edge precisely once."strictly.weighted":Strictly respect the order of the weights - so the first, second, third, and so on, adjacent pair of numbers of the output of
zenpath()corresponds to the pair with largest, second-largest, third-largest, and so on, weight.
- decreasing
A
logicalindicating whether the sorting is done according to increasing or decreasing weights.
Value
Returns a sequence of variables (indices or names,
possibly a list of such), which can then be used to index the data
(via groupData() for plotting via zenplot().
Details
Most methods do not require any non-CRAN packages. However,
method = "greedy.weighted" constructs an Eulerian path via a
graphNEL object and therefore
requires Bioconductor package graph at runtime.
The "strictly.weighted" method does not require graph.
Note
For method = "greedy.weighted" only, graph must be installed.
If graph is unavailable, an informative error should be raised by the function.
See also
zenplot() which provides the zenplot.
Other tools related to constructing zenpaths:
connect_pairs(),
extract_pairs(),
graph_pairs(),
groupData(),
indexData()
Examples
## Methods that do not need Bioconductor:
zenpath(5, method = "front.loaded")
#> [1] 5 1 2 3 1 4 2 5 3 4 5
zenpath(5, method = "balanced")
#> [1] 1 2 3 5 4 1 3 4 2 5 1
## Greedy weighted (requires Bioconductor 'graph' at runtime):
## Not run:
## if (requireNamespace("graph", quietly = TRUE)) {
## w <- runif(choose(5, 2))
## zp <- zenpath(w, method = "greedy.weighted")
## }
