plotMatrix {distantia} | R Documentation |
Plots the output matrices of distanceMatrix
and leastCostMatrix
, and superimposes the least cost path generated by leastCostPath
. This functions relies on image.plot
to plot a color scale along with the matrix plot, or image
when a color scale is not needed.
plotMatrix(
distance.matrix = NULL,
least.cost.path = NULL,
plot.columns = NULL,
plot.rows = NULL,
legend = TRUE,
color.palette = "divergent",
path.color = "black",
path.width = 1,
margins = c(2,3,2,4),
pdf.filename = NULL,
pdf.width = 7,
pdf.height = 4,
pdf.pointsize = 12,
rotate = FALSE
)
distance.matrix |
numeric matrix or list of numeric matrices either produced by |
least.cost.path |
dataframe or list of fdataframes produced by |
plot.columns |
number of columns of the output plot if the inputs are lists. If not provided, it is computed automatically by |
plot.rows |
number of rows of the output plot if the inputs are lists. If not provided, it is computed automatically by |
legend |
boolean. If |
color.palette |
string defining the color palette to be used, or a color palette. Accepted strings are "divergent" (default), which uses a red-white-blue divergent palette produced by the code |
path.color |
string, color of the line representing the least cost path if |
path.width |
line width (lwd) of the plotted path. |
margins |
a numeric vector with four positions indicating the margins of each plotted matrix. Order of margins in this vector is: bottom, left, top, right. |
pdf.filename |
character string with the name, without extension, of the pdf to be written. If |
pdf.width |
with in inches of the output pdf. Default value is 7. |
pdf.height |
height in inches of the output pdf. Default value is 4. |
pdf.pointsize |
base font size of the output pdf. |
rotate |
boolean, if |
A list 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
)
#plot
plotMatrix(distance.matrix = AB.distance.matrix)
#viridis palette
plotMatrix(distance.matrix = AB.distance.matrix,
color.palette = "viridis")
#custom palette
plotMatrix(distance.matrix = AB.distance.matrix,
color.palette = viridis::viridis(8, option = "B", direction = -1))