leastCostPath {distantia} | R Documentation |
Uses the original distance matrix created by distanceMatrix
and the least cost path matrix created by leastCostMatrix
to find the least cost path between the first and the last cells of the matrix. If diagonal
was TRUE
in leastCostMatrix
, then it must be TRUE
when using this function. Otherwise, the default is FALSE
in both.
leastCostPath(
distance.matrix = NULL,
least.cost.matrix = NULL,
diagonal = FALSE,
parallel.execution = TRUE
)
distance.matrix |
numeric matrix or list of numeric matrices, a distance matrix produced by |
least.cost.matrix |
numeric matrix or list of numeric matrices produced by |
diagonal |
boolean, if |
parallel.execution |
boolean, if |
Alist of dataframes if least.cost.matrix
is a list, or a dataframe if least.cost.matrix
is a matrix. The dataframe/s have the following columns:
A row/sample of one of the sequences.
B row/sample of one the other sequence.
distance distance between both samples, extracted from distance.matrix
.
cumulative.distance cumulative distance at the samples A
and B
.
#loading data
data(sequenceA)
data(sequenceB)
#preparing datasets
AB.sequences <- prepareSequences(
sequence.A = sequenceA,
sequence.A.name = "A",
sequence.B = sequenceB,
sequence.B.name = "B",
merge.mode = "complete",
if.empty.cases = "zero",
transformation = "hellinger"
)
#computing distance matrix
AB.distance.matrix <- distanceMatrix(
sequences = AB.sequences,
grouping.column = "id",
method = "manhattan",
parallel.execution = FALSE
)
#computing least cost matrix
AB.least.cost.matrix <- leastCostMatrix(
distance.matrix = AB.distance.matrix,
diagonal = FALSE,
parallel.execution = FALSE
)
AB.least.cost.path <- leastCostPath(
distance.matrix = AB.distance.matrix,
least.cost.matrix = AB.least.cost.matrix,
parallel.execution = FALSE
)
#plot
plotMatrix(distance.matrix = AB.distance.matrix,
least.cost.path = AB.least.cost.path,
)