Plot graph using visNetwork.
plot_graph_visnetwork(
g,
label_var = "name",
size_var = "degree",
colour_var = size_var,
invert_colour_var = TRUE,
columns = get_graph_colnames(g),
node_opacity = 0.75,
edge_opacity = 0.5,
preferred_palettes = NULL,
selectedBy = label_var,
show_plot = TRUE,
layout = "layout_with_kk",
solver = "forceAtlas2Based",
physics = FALSE,
forceAtlas2Based = list(avoidOverlap = 0.5, gravitationalConstant = -50),
scaling = NULL,
arrows = "from",
smooth = list(enabled = TRUE, type = "cubicBezier", roundness = 0.5),
add_visExport = FALSE,
degree = 1,
width = "100%",
height = "90vh",
highlight_color = "#00FFFFCF",
randomSeed = 2024,
main = NULL,
submain = NULL,
save_path = tempfile(fileext = "_visnetwork.html")
)
ggnetwork object (or an igraph/tbl_graph to be converted to ggnetwork format).
Column containing the label for each node in a graph (e.g. "hpo_name").
Column to scale node size by.
Column to color nodes by.
Invert colour variable.
Names of columns to map colour palettes to.
Node opacity.
Edge opacity.
Preferred palettes to use for each column.
: Custom option. Character or a named list. Add a multiple selection based on column of node data.frame creating an HTML select element. Not available for DOT and Gephi.
"variable" : Character. Column name of selection variable.
"values : Optional. Vector of possible values. Default to all values in nodes data.frame.
"selected" : Optional. Integer/Character. Initial selection. Default to NULL
"style" : Optional. Character. HTML style of list. Default to 'width: 150px; height: 26px'.
"multiple" : Optional. Boolean. Default to FALSE. If TRUE, you can affect multiple groups per nodes using a comma ("gr1,gr2")
"hideColor" : Optional. String. Color for hidden nodes/edges. Use a rgba definition. Default to rgba(200,200,200,0.5)
"main" : Optional. Default to "Select by variable"
"sort" : Optional. If values is NULL, sort all possible values ?. Default to TRUE
"highlight" : Optional. Boolean. Run highlightNearest if defined on each selected node ? Default to FALSE
Print the plot after it's been generated.
: Character Name of igraph layout function to use. Default to "layout_nicely"
: String. Default to 'barnesHut'. You can select your own solver. Possible options: 'barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'. When setting the hierarchical layout, the hierarchical repulsion solver is automaticaly selected, regardless of what you fill in here.
: Boolean. Default to FALSE. Enabled physics on nodes ?
named list of options
"theta" : Number. Default to 0.5. This parameter determines the boundary between consolidated long range forces and individual short range forces. To oversimplify higher values are faster but generate more errors, lower values are slower but with less errors.
"gravitationalConstant" : Number. Default to -50. Gravity attracts. We like repulsion. So the value is negative. If you want the repulsion to be stronger, decrease the value (so -10000, -50000).
"centralGravity" : Number. Default to 0.01. There is a central gravity attractor to pull the entire network back to the center.
"springLength" : Number. Default to 100. The edges are modelled as springs. This springLength here is the the rest length of the spring.
"springConstant" : Number. Default to 0.08. This is how 'sturdy' the springs are. Higher values mean stronger springs.
"damping" : Number. Default to 0.4. Accepted range: [0 .. 1]. The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration.
"avoidOverlap" : Number. Default to 0. Accepted range: [0 .. 1]. When larger than 0, the size of the node is taken into account. The distance will be calculated from the radius of the encompassing circle of the node for both the gravity model. Value 1 is maximum overlap avoidance.
: Named list. If the value option is specified, the size of the nodes will be scaled according to the properties in this object.
"min" : Number. Default to 10. If nodes have a value, their sizes are determined by the value, the scaling function and the min max values.
"max" : Number. Default to 30. This is the maximum allowed size when the nodes are scaled using the value option.
"label" : Named list or Boolean. Default to Named list. This can be false if the label is not allowed to scale with the node. If true it will scale using default settigns. For further customization, you can supply an object.
"enabled" : Boolean. Default to false. Toggle the scaling of the label on or off. If this option is not defined, it is set to true if any of the properties in this object are defined.
"min" : Number. Default to 14. The minimum font-size used for labels when scaling.
"max" : Number. Default to 30. The maximum font-size used for labels when scaling.
"maxVisible" : Number. Default to 30. When zooming in, the font is drawn larger as well. You can limit the perceived font size using this option. If set to 30, the font will never look larger than size 30 zoomed at 100%.
"drawThreshold" : Number. Default to 5. When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn. When using font scaling, you can use this together with the maxVisible to first show labels of important nodes when zoomed out and only show the rest when zooming in.
"customScalingFunction" : Function. If nodes have value fields, this function determines how the size of the nodes are scaled based on their values.
: Named list or String. To draw an arrow with default settings a string can be supplied. For example: 'to, from,middle' or 'to;from', any combination with any seperating symbol is fine. If you want to control the size of the arrowheads, you can supply an object. See visDocumentation
: Boolean. Default to FALSE. Use smooth edges ?
Add PDF download button.
The number of degrees away from the selected nodes to highlight.
Width of the heatmap body.
Height of the heatmap body.
Colour to highlight selected nodes.
: Number. The nodes are randomly positioned initially. This means that the settled result is different every time. If you provide a random seed manually, the layout will be the same every time.
: For add a title. Character or a named list.
"text" : Character. Title.
"style" : Optional. Character. HTML style of title. Default to 'font-family:Georgia, Times New Roman, Times, serif;font-weight:bold;font-size:20px;text-align:center;'.
: For add a subtitle. Character or a named list.
"text" : Character. Subtitle.
"style" : Optional. Character. HTML style of submain. Default to 'font-family:Georgia, Times New Roman, Times, serif;font-size:12px;text-align:center;'.
Path to save interactive plot to as a self-contained HTML file.
ont <- get_ontology("hp", terms=10)
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/hp.rds
#> Randomly sampling 10 term(s).
g <- ontology_to(ont, to="tbl_graph")
#> Translating ontology terms to ids.
#> Converted ontology to: tbl_graph
out <- plot_graph_visnetwork(g)
#> Creating visNetwork plot.
#> Making hoverboxes from: 'name', 'short_id', 'label', 'namespace', 'definition', 'IC', 'depth', 'n_children', 'n_ancestors', 'n_parents', 'n_offspring', 'n_connected_leaves', 'ancestor', 'ancestor_name', 'n_edges', 'ontLvl'
#> Adding hoverboxes to data.table.
#> Using palette: okabe
#> Warning: Can't find 'name' in node data.frame
#> Saving plot --> /tmp/RtmpqihAUi/file1b5b12f55ae7_visnetwork.html