plotMatrix.Rd
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
)
numeric matrix or list of numeric matrices either produced by distanceMatrix
or leastCostMatrix
.
dataframe or list of fdataframes produced by leastCostPath
. If a list, must have the same number of slots as distance.matrix
.
number of columns of the output plot if the inputs are lists. If not provided, it is computed automatically by n2mfrow
.
number of rows of the output plot if the inputs are lists. If not provided, it is computed automatically by n2mfrow
.
boolean. If TRUE
, the plot is made with image.plot
, and includes a color scale on the right side. If FALSE
, the plot is made with image
, and the color scale is omitted.
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 colorRampPalette(rev(RColorBrewer::brewer.pal(9, "RdBu")))(100)
, and "viridis", which uses the default settings of the viridis
function to generate the palette. Both settings are color-blind friendly.
string, color of the line representing the least cost path if least.cost.path
is provided.
line width (lwd) of the plotted path.
a numeric vector with four positions indicating the margins of each plotted matrix. Order of margins in this vector is: bottom, left, top, right.
character string with the name, without extension, of the pdf to be written. If NULL
, no pdf is written.
with in inches of the output pdf. Default value is 7.
height in inches of the output pdf. Default value is 4.
base font size of the output pdf.
boolean, if TRUE
, the matrix is rotated. Allows the user to plot the matrix axes in the desired direction.
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
.
# \donttest{
#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))
# }