Plot the output of prioritise_targets as an interactive network with visNetwork. See layout for a list of all layout functions that can be passed to the prioritise_targets_network(layout=) argument as a string (e.g. "layout.fruchterman.reingold" or "layout_as_tree"). See here for some visualized examples of each layout.

prioritise_targets_network(
  top_targets,
  vertex_vars = c("disease_name", "hpo_name", "CellType", "gene_symbol"),
  group_var = vertex_vars[[1]],
  edge_color_var = "fold_change",
  edge_size_var = "fold_change",
  mediator_var = list(),
  show_plot = TRUE,
  save_path = tempfile(fileext = "_prioritise_targets_network.html"),
  layout = "layout_with_kk",
  solver = "forceAtlas2Based",
  physics = FALSE,
  forceAtlas2Based = list(avoidOverlap = 0.5, gravitationalConstant = -50),
  scaling = list(label = list(drawThreshold = 0)),
  smooth = list(enabled = TRUE, type = "cubicBezier", roundness = 0.5),
  add_visExport = FALSE,
  degree = 1,
  width = "100%",
  height = "90vh",
  main = "Rare Disease Celltyping",
  submain = "Prioritised Targets Network",
  node_palette = pals::kovesi.linear_bmy_10_95_c78,
  randomSeed = 2023,
  verbose = TRUE
)

Arguments

top_targets

output of prioritise_targets.

vertex_vars

Columns within top_targets to include as vertices/nodes within the network.

group_var

Variable to group nodes by.

edge_color_var

Variable to color edges by.

edge_size_var

Variable to scale edges by.

mediator_var

Variable to connect cell types and phenotypes by (i.e. "gene_symbol"). If NULL, instead will connect node hierarchically: ancestor_name --> Phenotype --> CellType --> gene_symbol

show_plot

Print the plot after it has been created.

save_path

Path to save HTML version of network to.

layout

: Character Name of igraph layout function to use. Default to "layout_nicely"

solver

: 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.

physics

: Boolean. Default to FALSE. Enabled physics on nodes ?

forceAtlas2Based

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.

scaling

: 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.

smooth

: Boolean. Default to FALSE. Use smooth edges ?

add_visExport

Add PDF download button.

degree

of depth of nodes to be colored. Default to 1. Set high number to have the entire sub-network. In case of "hierarchical" algorithm, you can also pass a list(from = 1, to = 1) to control degree in both direction.

width

: Number. Default to 1. The width of the edge. If value is set, this is not used.

height

: String. Default to "100%". The height of the network in pixels or as a percentage.

main

: 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;'.

submain

: 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;'.

node_palette

Palette function to color nodes by. See the pals package for available options.

randomSeed

: 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.

verbose

Print messages.

Value

A named list containing the visNetwork plot and the the graph used to make the plot.

Examples

res <- MultiEWCE::example_targets
vn <- prioritise_targets_network(top_targets = res$top_targets)
#> Loading required namespace: tidygraph
#> Creating network.
#> Creating plot.
#> Saving plot ==> /tmp/Rtmp0tNWxK/file26a91e080e96_prioritise_targets_network.html