Plot a subset of the HPO as a 3D network.

network_3d(
  g,
  layout_func = igraph::layout.fruchterman.reingold,
  node_color_var = "ontLvl",
  edge_color_var = "zend",
  text_color_var = node_color_var,
  node_symbol_var = "ancestor_name",
  node_palette = pals::kovesi.cyclic_mrybm_35_75_c68_s25,
  edge_palette = pals::kovesi.cyclic_mrybm_35_75_c68_s25,
  node_opacity = 0.75,
  edge_opacity = 0.5,
  kde_palette = pals::gnuplot,
  add_kde = TRUE,
  extend_kde = 1.5,
  bg_color = kde_palette(6)[1],
  add_labels = FALSE,
  keep_grid = FALSE,
  aspectmode = "cube",
  hover_width = 80,
  label_width = 80,
  seed = 2023,
  showlegend = TRUE,
  show_plot = TRUE,
  save_path = tempfile(fileext = "network_3d.html"),
  verbose = TRUE
)

Arguments

g

igraph object generated by make_igraph_object.

layout_func

Layout function for the graph.

node_color_var

Variable in the vertex metadata to color nodes by.

edge_color_var

Variable in the edge metadata to color edges by.

text_color_var

Variable in the node metadata to color text by.

node_symbol_var

Variable in the vertex metadata to shape nodes by.

node_palette

Color palette function for the nodes/points.

edge_palette

Color palette function for the edges/lines.

node_opacity

Node opacity.

edge_opacity

Edge opacity.

kde_palette

Color palette function for the KDE plot.

add_kde

Add a kernel density estimation (KDE) plot below the 3D scatter plot (i.e. the "mountains" beneath the points).

extend_kde

Extend the area that the KDE plot covers.

bg_color

Plot background color.

add_labels

Add phenotype name labels to each point.

keep_grid

Keep all grid lines and axis labels.

aspectmode

The proportions of the 3D plot. See the plotly documentation site for details.

hover_width

Maximum width of the hover text.

label_width

Maximum width of the label text.

seed

Random seed to enable reproducibility.

showlegend

Show node fill legend.

show_plot

Print the plot after it's been generated.

save_path

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

verbose

Print messages.

Value

A 3D interactive plotly object.

Examples

phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#>  All local files already up-to-date!
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2023-10-09
#> Extracting data for 23 descendents.
#> Computing gene counts.
#> Getting absolute ontology level for 23 HPO IDs.
#> Computing ontology level / gene count ratio.
#> Adding term definitions.
#>  All local files already up-to-date!
#> Adding level-3 ancestor to each HPO ID.
#>  All local files already up-to-date!
g <- make_igraph_object(phenos = phenos)
#> Making phenotype network object.
#> Creating adjacency matrix for 23 term(s).
#>  All local files already up-to-date!
#> Creating ggnetwork object.
#> Adding new_column='hpo_name'
#> Adding new_column='hpo_id'
#> Adding new_column='ontLvl'
#> Adding new_column='ontLvl_geneCount_ratio'
#> Adding new_column='definition'
#> Adding new_column='ancestor'
#> Adding new_column='ancestor_name'
#> Adding n_edges per node.
#> Creating igraph object.
plt <- network_3d(g=g, show_plot=FALSE)
#> Converting igraph to plotly data.
#> Warning: 'surface' objects don't have these attributes: 'marker'
#> Valid attributes include:
#> '_deprecated', 'autocolorscale', 'cauto', 'cmax', 'cmid', 'cmin', 'coloraxis', 'colorbar', 'colorscale', 'connectgaps', 'contours', 'customdata', 'customdatasrc', 'hidesurface', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'lighting', 'lightposition', 'meta', 'metasrc', 'name', 'opacity', 'opacityscale', 'reversescale', 'scene', 'showlegend', 'showscale', 'stream', 'surfacecolor', 'surfacecolorsrc', 'text', 'textsrc', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
#> Saving interactive plot --> /tmp/Rtmp7LnXkl/file680367f6bea4network_3d.html
#> Warning: 'surface' objects don't have these attributes: 'marker'
#> Valid attributes include:
#> '_deprecated', 'autocolorscale', 'cauto', 'cmax', 'cmid', 'cmin', 'coloraxis', 'colorbar', 'colorscale', 'connectgaps', 'contours', 'customdata', 'customdatasrc', 'hidesurface', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'lighting', 'lightposition', 'meta', 'metasrc', 'name', 'opacity', 'opacityscale', 'reversescale', 'scene', 'showlegend', 'showscale', 'stream', 'surfacecolor', 'surfacecolorsrc', 'text', 'textsrc', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'