prioritise_targets_network: Prioritise targets network

View source: R/prioritise_targets_network.R

prioritise_targets_networkR Documentation

Prioritise targets network

Description

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.

Usage

prioritise_targets_network(
  top_targets,
  vertex_vars = c("disease_name", "hpo_name", "cl_name", "gene_symbol"),
  group_var = vertex_vars[[1]],
  agg_fun = mean,
  colour_var = "node_type",
  edge_color_var = "estimate",
  edge_size_var = edge_color_var,
  node_opacity = 0.75,
  edge_opacity = 0.5,
  mediator_var = list(c(1, 2), c(2, 3), c(3, 4), c(1, 3)),
  layout = "layout_with_sugiyama",
  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 = "100vh",
  main = "Rare Disease Celltyping",
  submain = "Prioritised Targets Network",
  preferred_palettes = "kovesi.linear_bmy_10_95_c78",
  randomSeed = 2023,
  verbose = TRUE,
  show_plot = TRUE,
  save_path = tempfile(fileext = "_prioritise_targets_network.html"),
  run_prune_ancestors = FALSE
)

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.

agg_fun

Function to aggregate edge values with when there are multiple edges between a given pair of nodes.

colour_var

Column to color nodes by.

edge_color_var

Variable to color edges by.

edge_size_var

Variable to scale edges by.

node_opacity

Node opacity.

edge_opacity

Edge opacity.

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

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.

arrows

: 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

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

Width of the heatmap body.

height

Height of the heatmap body.

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

preferred_palettes

Preferred palettes to use for each column.

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.

show_plot

Print the plot after it's been generated.

save_path

Path to save interactive plot to as a self-contained HTML file.

run_prune_ancestors

Prune redundant ancestral terms if any of their descendants are present. Passes to prune_ancestors.

Value

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

Source

book.archnetworks.net

Edge bundling with ggraph

visNetwork examples

Examples

top_targets <- MSTExplorer::example_targets$top_targets[1:10]
top_targets[,estimate:=fold_change]
top_targets <- map_celltype(top_targets)
vn <- prioritise_targets_network(top_targets = top_targets)

neurogenomics/MultiEWCE documentation built on Sept. 28, 2024, 2:27 a.m.