plotMRF_hm {MRFcov} | R Documentation |
Plot MRF interaction parameters as a heatmap
Description
This function uses outputs from fitted MRFcov
and
bootstrap_MRF
models to plot a heatmap of node interaction coefficients.
Usage
plotMRF_hm(MRF_mod, node_names, main, plot_observed_vals, data)
Arguments
MRF_mod |
A fitted |
node_names |
A character vector of species names for axis labels. Default
is to use rownames from the |
main |
An optional character title for the plot |
plot_observed_vals |
Logical. If |
data |
Optional |
Details
Interaction parameters from MRF_mod
are plotted as a heatmap, where
red colours indicate positive interactions and blue indicate negative interactions. If
plot_observed_vals == TRUE
, raw observed values of single occurrences (on the diagonal)
and co-occurrences for each species in data
are overlaid on the plot
(only avaiable for family = 'binomial'
models). Note, this option is not
available for bootstrap_MRF
models
Value
A ggplot2
object
See Also
Examples
data("Bird.parasites")
CRFmod <- MRFcov(data = Bird.parasites, n_nodes = 4, family = 'binomial')
plotMRF_hm(MRF_mod = CRFmod)
plotMRF_hm(MRF_mod = CRFmod, plot_observed_vals = TRUE, data = Bird.parasites)
#To plot as an igraph network instead, we can simply extract the adjacency matrix
net <- igraph::graph.adjacency(CRFmod$graph, weighted = TRUE, mode = "undirected")
igraph::plot.igraph(net, layout = igraph::layout.circle,
edge.width = abs(igraph::E(net)$weight),
edge.color = ifelse(igraph::E(net)$weight < 0, 'blue', 'red'))