Specialized plot()
function for KGX graphs
# S3 method for class 'tbl_kgx'
plot(
x,
...,
layout = "auto",
node_color = pcategory,
node_shape = pcategory,
node_size = NULL,
node_alpha = 0.9,
edge_color = predicate,
edge_linetype = NULL,
edge_alpha = 0.5,
max.overlaps = 10,
bundle = FALSE,
palettes = monarch_palettes(),
layer_args = list(theme_bw = list(), theme = list(axis.text = ggplot2::element_blank(),
axis.ticks = ggplot2::element_blank(), axis.title = ggplot2::element_blank(),
legend.key = ggplot2::element_blank(), panel.background = ggplot2::element_blank(),
panel.border = ggplot2::element_blank(), panel.grid = ggplot2::element_blank()),
scale_edge_color_manual = list(values = palettes$edges$discrete, na.value = "grey"),
scale_edge_color_gradientn = list(colors = palettes$continuous[3:1], na.value =
"grey"), scale_color_manual = list(values = palettes$nodes$discrete,
na.value =
"grey"), scale_shape_manual = list(values = palettes$nodes$shape, na.value = 19),
scale_edge_fill_manual = list(values = palettes$nodes$discrete, na.value = "grey",
guide = "none"), geom_edge_fan = list(aes(color = {
{
edge_color
}
}, linetype = {
{
edge_linetype
}
}), arrow = arrow(length =
unit(2, "mm"), type = "open"), end_cap = circle(2.5, "mm"), edge_alpha = edge_alpha,
show.legend = FALSE), geom_edge_loop = list(aes(color = {
{
edge_color
}
}), arrow = arrow(length = unit(2, "mm"), type = "open"), end_cap =
circle(2.5, "mm"), edge_alpha = edge_alpha), geom_edge_bundle_force2 = list(aes(color
= {
{
edge_color
}
}, linetype = {
{
edge_linetype
}
}), edge_alpha = edge_alpha), geom_edge_density = NULL, geom_node_point =
list(aes(color = {
{
node_color
}
}, shape = {
{
node_shape
}
}, size = {
{
node_size
}
}), alpha =
node_alpha), geom_node_label = list(aes(label = str_wrap(name, 20)), box.padding =
0.4, min.segment.length = 0, size = 2, repel = TRUE, segment.colour = alpha("black",
edge_alpha), segment.linetype = "dotted", fill = "#FFFFFF88"))
)
A tbl_kgx graph.
Arguments passed on to ggraph::ggraph
graph
The object containing the graph. See Details for a list
of supported classes. Or a layout_ggraph
object as returned from
create_layout
in which case all subsequent arguments is ignored.
The layout to use for the plot. Default is "sugiyama".
The column to use for node color. Default is "pcategory".
The column to use for node shape. Default is "pcategory".
The column to use for node size. Default is NULL.
The alpha value for nodes. Default is 0.9.
The column to use for edge color. Default is "predicate".
The column to use for edge linetype. Default is NULL.
The alpha value for edges. Default is 0.5.
Exclude text labels when they overlap too many other things. For each text label, we count how many other text labels or other data points it overlaps, and exclude the text label if it has too many overlaps. Defaults to 10.
Whether to bundle edges with geom_edge_bundle_force2. Default is FALSE.
A named list of discrete/continuous palettes for nodes/edges
Default is monarch_palettes
.
A named list of arguments for each ggplot layer.
filename <- system.file("extdata", "eds_marfan_kg.tar.gz", package = "monarchr")
g <- file_engine(filename) |>
fetch_nodes(query_ids = "MONDO:0007525") |>
expand(predicates = "biolink:has_phenotype",
categories = "biolink:PhenotypicFeature")|>
expand(categories = "biolink:Gene")
plot(g)
#> Using "sugiyama" as default layout
#> Warning: ggrepel: 45 unlabeled data points (too many overlaps). Consider increasing max.overlaps