View source: R/plotInteractions.R
plotInteractions | R Documentation |
This function takes in a matrix with the predicted proportions
for each spot and returns a heatmap which = plotHeatmap
or a network
graph which = plotNetwork
to show which cells are interacting
spatially.
plotInteractions(
x,
which = c("heatmap", "network"),
metric = c("prop", "jaccard"),
min_prop = 0,
...
)
x |
numeric matrix with rows = samples and columns = groups. Must have at least one row and column, and at least two columns. |
which |
character string specifying the type of visualization: one of "heatmap" or "network". |
metric |
character string specifying which metric to show: one of "prop" or "jaccard". |
min_prop |
scalar specifying the value above which
a group is considered to be contributing to a given sample.
An interaction between groups i and j is counted for sample s
only when both x[s, i] and x[s, j] fall above |
... |
additional graphical parameters passed
to |
base R plot
Marc Elosua Bayes & Helena L Crowell
library(ggplot2)
mat <- replicate(8, rnorm(100, runif(1, -1, 1)))
# Basic example
plotInteractions(mat)
### heatmap ###
# This returns a ggplot object that can be modified as such
plotInteractions(mat, which = "heatmap") +
scale_fill_gradient(low = "#f2e552", high = "#850000") +
labs(title = "Interaction heatmap", fill = "proportion")
### Network ###
# specify node names
nms <- letters[seq_len(ncol(mat))]
plotInteractions(mat, which = "network", vertex.label = nms)
# or set column names instead
colnames(mat) <- nms
plotInteractions(mat, which = "network")
# pass additional graphical parameters for aesthetics
plotInteractions(mat,
which = "network",
edge.color = "cyan",
vertex.color = "pink",
vertex.label.font = 2,
vertex.label.color = "maroon")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.