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", "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
)
output of prioritise_targets.
Columns within top_targets
to include as vertices/nodes within the network.
Variable to group nodes by.
Function to aggregate edge values with when there are multiple edges between a given pair of nodes.
Column to color nodes by.
Variable to color edges by.
Variable to scale edges by.
Node opacity.
Edge opacity.
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
: 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.
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 of the heatmap body.
Height of the heatmap body.
: 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;'.
Preferred palettes to use for each column.
: 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.
Print messages.
Print the plot after it's been generated.
Path to save interactive plot to as a self-contained HTML file.
Prune redundant ancestral terms if any of their descendants are present. Passes to prune_ancestors.
A named list containing the visNetwork plot and the the graph used to make the plot.
top_targets <- MSTExplorer::example_targets$top_targets[1:10]
top_targets[,estimate:=fold_change]
#> hpo_id gene_symbol CellType disease_id annotLevel p
#> <char> <char> <char> <char> <num> <num>
#> 1: HP:0001695 ACTN2 Cardiomyocytes OMIM:612158 1 0
#> 2: HP:0011675 ACTN2 Cardiomyocytes OMIM:612158 1 0
#> 3: HP:0011675 DSP Cardiomyocytes OMIM:605676 1 0
#> 4: HP:0200134 SLC25A22 Ganglion_cells OMIM:609304 1 0
#> 5: HP:0200134 SLC25A22 Ganglion_cells OMIM:609304 1 0
#> 6: HP:0011344 SLC9A6 Excitatory_neurons ORPHA:85278 1 0
#> 7: HP:0012795 ATRX Photoreceptor_cells ORPHA:847 1 0
#> 8: HP:0000648 ATRX Photoreceptor_cells ORPHA:847 1 0
#> 9: HP:0002376 SLC9A6 Limbic_system_neurons ORPHA:85278 1 0
#> 10: HP:0002376 SLC9A6 Inhibitory_neurons ORPHA:85278 1 0
#> fold_change sd_from_mean hpo_name q
#> <num> <num> <char> <num>
#> 1: 3.896919 13.716418 Cardiac arrest 0
#> 2: 2.915053 16.392754 Arrhythmia 0
#> 3: 2.915053 16.392754 Arrhythmia 0
#> 4: 2.311365 8.950861 Epileptic encephalopathy 0
#> 5: 2.311365 8.950861 Epileptic encephalopathy 0
#> 6: 2.099415 8.921895 Severe global developmental delay 0
#> 7: 1.994699 8.523000 Abnormality of the optic disc 0
#> 8: 1.953977 7.293145 Optic atrophy 0
#> 9: 1.707192 8.243906 Developmental regression 0
#> 10: 1.640133 6.537439 Developmental regression 0
#> hpo_id.disease_id intersection_size union_size symptom.pval
#> <char> <int> <int> <num>
#> 1: HP:0001695.OMIM:612158 1 6515 0.1092974
#> 2: HP:0011675.OMIM:612158 1 6515 0.1092974
#> 3: HP:0011675.OMIM:605676 1 6515 0.1092974
#> 4: HP:0200134.OMIM:609304 1 7158 0.1200846
#> 5: HP:0200134.OMIM:609304 1 7158 0.1200846
#> 6: HP:0011344.ORPHA:85278 1 7389 0.1239599
#> 7: HP:0012795.ORPHA:847 1 6647 0.1115119
#> 8: HP:0000648.ORPHA:847 1 6647 0.1115119
#> 9: HP:0002376.ORPHA:85278 1 8379 0.1405684
#> 10: HP:0002376.ORPHA:85278 1 7883 0.1322473
#> symptom.odds_ratio symptom.jaccard symptom.qval
#> <num> <num> <num>
#> 1: Inf 0.0001534919 1
#> 2: Inf 0.0001534919 1
#> 3: Inf 0.0001534919 1
#> 4: Inf 0.0001397038 1
#> 5: Inf 0.0001397038 1
#> 6: Inf 0.0001353363 1
#> 7: Inf 0.0001504438 1
#> 8: Inf 0.0001504438 1
#> 9: Inf 0.0001193460 1
#> 10: Inf 0.0001268553 1
#> definition
#> <char>
#> 1: "An abrupt loss of heart function." []
#> 2: "Any cardiac rhythm other than the normal sinus rhythm. Such a rhythm may be either of sinus or ectopic origin and either regular or irregular. An arrhythmia may be due to a disturbance in impulse formation or conduction or both." [HPO_CONTRIBUTOR:DDD_dbrown, PMID:19063792]
#> 3: "Any cardiac rhythm other than the normal sinus rhythm. Such a rhythm may be either of sinus or ectopic origin and either regular or irregular. An arrhythmia may be due to a disturbance in impulse formation or conduction or both." [HPO_CONTRIBUTOR:DDD_dbrown, PMID:19063792]
#> 4: "A condition in which epileptiform abnormalities are believed to contribute to the progressive disturbance in cerebral function. Epileptic encephalaopathy is characterized by (1) electrographic EEG paroxysmal activity that is often aggressive, (2) seizures that are usually multiform and intractable, (3) cognitive, behavioral and neurological deficits that may be relentless, and (4) sometimes early death." [PMID:21590624, PMID:23213494]
#> 5: "A condition in which epileptiform abnormalities are believed to contribute to the progressive disturbance in cerebral function. Epileptic encephalaopathy is characterized by (1) electrographic EEG paroxysmal activity that is often aggressive, (2) seizures that are usually multiform and intractable, (3) cognitive, behavioral and neurological deficits that may be relentless, and (4) sometimes early death." [PMID:21590624, PMID:23213494]
#> 6: "A severe delay in the achievement of motor or mental milestones in the domains of development of a child." [https://orcid.org/0000-0002-6410-0882]
#> 7: "A morphological abnormality of the optic disc, i.e., of the portion of the optic nerve clinically visible on fundoscopic examination." [https://orcid.org/0000-0002-0736-9199]
#> 8: "Atrophy of the optic nerve. Optic atrophy results from the death of the retinal ganglion cell axons that comprise the optic nerve and manifesting as a pale optic nerve on fundoscopy." [https://orcid.org/0000-0002-0736-9199]
#> 9: "Loss of developmental skills, as manifested by loss of developmental milestones." [https://orcid.org/0000-0002-6410-0882]
#> 10: "Loss of developmental skills, as manifested by loss of developmental milestones." [https://orcid.org/0000-0002-6410-0882]
#> disease_name
#> <char>
#> 1: cardiomyopathy, dilated, 1aa, with or without left ventricular noncompaction
#> 2: cardiomyopathy, dilated, 1aa, with or without left ventricular noncompaction
#> 3: cardiomyopathy, dilated, with woolly hair and keratoderma
#> 4: developmental and epileptic encephalopathy 3
#> 5: developmental and epileptic encephalopathy 3
#> 6: christianson syndrome
#> 7: alpha-thalassemia-x-linked intellectual disability syndrome
#> 8: alpha-thalassemia-x-linked intellectual disability syndrome
#> 9: christianson syndrome
#> 10: christianson syndrome
#> Definitions
#> <char>
#> 1: <NA>
#> 2: <NA>
#> 3: <NA>
#> 4: <NA>
#> 5: <NA>
#> 6: a rare developmental defect during embryogenesis characterized by intellectual deficit, ataxia, postnatal microcephaly, and hyperkinesis.
#> 7: a rare x-linked syndromic intellectual disability characterized by profound developmental delay, facial dysmorphism, genital abnormalities and alpha thalassemia.
#> 8: a rare x-linked syndromic intellectual disability characterized by profound developmental delay, facial dysmorphism, genital abnormalities and alpha thalassemia.
#> 9: a rare developmental defect during embryogenesis characterized by intellectual deficit, ataxia, postnatal microcephaly, and hyperkinesis.
#> 10: a rare developmental defect during embryogenesis characterized by intellectual deficit, ataxia, postnatal microcephaly, and hyperkinesis.
#> Preferred.Label
#> <char>
#> 1: CARDIOMYOPATHY, DILATED, 1AA, WITH OR WITHOUT LEFT VENTRICULAR NONCOMPACTION
#> 2: CARDIOMYOPATHY, DILATED, 1AA, WITH OR WITHOUT LEFT VENTRICULAR NONCOMPACTION
#> 3: CARDIOMYOPATHY, DILATED, WITH WOOLLY HAIR AND KERATODERMA
#> 4: DEVELOPMENTAL AND EPILEPTIC ENCEPHALOPATHY 3
#> 5: DEVELOPMENTAL AND EPILEPTIC ENCEPHALOPATHY 3
#> 6: Christianson syndrome
#> 7: Alpha-thalassemia-X-linked intellectual disability syndrome
#> 8: Alpha-thalassemia-X-linked intellectual disability syndrome
#> 9: Christianson syndrome
#> 10: Christianson syndrome
#> MONDO_ID MONDO_name MONDO_definition AgeOfDeath AgeOfDeath_names
#> <char> <char> <char> <list> <list>
#> 1: MONDO:00128083 <NA> <NA> Death in....
#> 2: MONDO:00128083 <NA> <NA> Death in....
#> 3: MONDO:00115814 <NA> <NA> Death in....
#> 4: MONDO:00122452 <NA> <NA> Death in....
#> 5: MONDO:00122452 <NA> <NA> Death in....
#> 6: MONDO:00102786 <NA> <NA> Death in....
#> 7: MONDO:00105197 <NA> <NA> Death in....
#> 8: MONDO:00105197 <NA> <NA> Death in....
#> 9: MONDO:00102786 <NA> <NA> Death in....
#> 10: MONDO:00102786 <NA> <NA> Death in....
#> AgeOfDeath_counts AgeOfDeath_score_mean AgeOfDeath_score_min
#> <list> <num> <num>
#> 1: 1 5.0 5
#> 2: 1 5.0 5
#> 3: 1, 1, 1 6.0 5
#> 4: 1 5.0 5
#> 5: 1 5.0 5
#> 6: 1, 1 6.5 6
#> 7: 1 3.0 3
#> 8: 1 3.0 3
#> 9: 1, 1 6.5 6
#> 10: 1, 1 6.5 6
#> AgeOfDeath_score_max AgeOfDeath_top AgeOfDeath_earliest
#> <num> <char> <char>
#> 1: 5 Death in adolescence Death in adolescence
#> 2: 5 Death in adolescence Death in adolescence
#> 3: 7 Death in adolescence Death in adolescence
#> 4: 5 Death in adolescence Death in adolescence
#> 5: 5 Death in adolescence Death in adolescence
#> 6: 7 Death in adulthood Death in early adulthood
#> 7: 3 Death in infancy Death in infancy
#> 8: 3 Death in infancy Death in infancy
#> 9: 7 Death in adulthood Death in early adulthood
#> 10: 7 Death in adulthood Death in early adulthood
#> AgeOfDeath_latest ancestor ancestor_name
#> <char> <char> <char>
#> 1: Death in adolescence HP:0001626 Abnormality of the cardiovascular system
#> 2: Death in adolescence HP:0001626 Abnormality of the cardiovascular system
#> 3: Death in middle age HP:0001626 Abnormality of the cardiovascular system
#> 4: Death in adolescence HP:0000707 Abnormality of the nervous system
#> 5: Death in adolescence HP:0000707 Abnormality of the nervous system
#> 6: Death in middle age HP:0000707 Abnormality of the nervous system
#> 7: Death in infancy HP:0000478 Abnormality of the eye
#> 8: Death in infancy HP:0000478 Abnormality of the eye
#> 9: Death in middle age HP:0000707 Abnormality of the nervous system
#> 10: Death in middle age HP:0000707 Abnormality of the nervous system
#> ontLvl onset onset_names onset_counts onset_score_mean onset_score_min
#> <num> <char> <char> <char> <num> <num>
#> 1: 1 <NA> <NA> <NA> NA NA
#> 2: 5 <NA> <NA> <NA> NA NA
#> 3: 5 <NA> <NA> <NA> NA NA
#> 4: 0 <NA> <NA> <NA> NA NA
#> 5: 0 <NA> <NA> <NA> NA NA
#> 6: 0 <NA> <NA> <NA> NA NA
#> 7: 3 <NA> <NA> <NA> NA NA
#> 8: 1 <NA> <NA> <NA> NA NA
#> 9: 1 <NA> <NA> <NA> NA NA
#> 10: 1 <NA> <NA> <NA> NA NA
#> onset_score_max onset_top onset_earliest onset_latest
#> <num> <char> <char> <char>
#> 1: NA <NA> <NA> <NA>
#> 2: NA <NA> <NA> <NA>
#> 3: NA <NA> <NA> <NA>
#> 4: NA <NA> <NA> <NA>
#> 5: NA <NA> <NA> <NA>
#> 6: NA <NA> <NA> <NA>
#> 7: NA <NA> <NA> <NA>
#> 8: NA <NA> <NA> <NA>
#> 9: NA <NA> <NA> <NA>
#> 10: NA <NA> <NA> <NA>
#> disease_characteristic tier tier_auto tier_merge modifier_name
#> <char> <int> <int> <int> <char>
#> 1: <NA> NA 1 1 <NA>
#> 2: <NA> NA 1 1 <NA>
#> 3: <NA> NA 1 1 <NA>
#> 4: Shortened life span: infancy 1 1 1 <NA>
#> 5: Shortened life span: infancy 1 1 1 <NA>
#> 6: Intellectual disability 1 NA 1 <NA>
#> 7: <NA> NA 1 1 <NA>
#> 8: Sensory impairment: vision 3 1 1 <NA>
#> 9: Intellectual disability 1 NA 1 <NA>
#> 10: Intellectual disability 1 NA 1 <NA>
#> Severity_score n_diseases pheno_freq_name pheno_freq_min
#> <num> <int> <char> <num>
#> 1: NA 116 Occasional (29-5%) 5
#> 2: NA 455 <NA> NA
#> 3: NA 455 <NA> NA
#> 4: NA 122 ratio 100
#> 5: NA 122 ratio 100
#> 6: NA 232 Very frequent (99-80%) 80
#> 7: NA 602 <NA> NA
#> 8: NA 599 Occasional (29-5%) 5
#> 9: NA 340 Very frequent (99-80%) 80
#> 10: NA 340 Very frequent (99-80%) 80
#> pheno_freq_max pheno_freq_mean seqnames start end width strand
#> <num> <num> <fctr> <int> <int> <int> <fctr>
#> 1: 29 17.0 1 236849754 236927931 78178 +
#> 2: NA NA 1 236849754 236927931 78178 +
#> 3: NA NA 6 7541808 7586950 45143 +
#> 4: 100 100.0 11 790475 798316 7842 -
#> 5: 100 100.0 11 790475 798316 7842 -
#> 6: 99 89.5 X 135067598 135129423 61826 +
#> 7: NA NA X 76760356 77041702 281347 -
#> 8: 29 17.0 X 76760356 77041702 281347 -
#> 9: 99 89.5 X 135067598 135129423 61826 +
#> 10: 99 89.5 X 135067598 135129423 61826 +
#> gene_id gene_name gene_biotype seq_coord_system entrezid
#> <char> <char> <char> <char> <list>
#> 1: ENSG00000077522 ACTN2 protein_coding chromosome 88
#> 2: ENSG00000077522 ACTN2 protein_coding chromosome 88
#> 3: ENSG00000096696 DSP protein_coding chromosome 1832
#> 4: ENSG00000177542 SLC25A22 protein_coding chromosome 79751
#> 5: ENSG00000177542 SLC25A22 protein_coding chromosome 79751
#> 6: ENSG00000198689 SLC9A6 protein_coding chromosome 10479
#> 7: ENSG00000085224 ATRX protein_coding chromosome 546
#> 8: ENSG00000085224 ATRX protein_coding chromosome 546
#> 9: ENSG00000198689 SLC9A6 protein_coding chromosome 10479
#> 10: ENSG00000198689 SLC9A6 protein_coding chromosome 10479
#> evidence_score_min evidence_score_max evidence_score_mean specificity
#> <num> <num> <num> <num>
#> 1: 4 4 4 0.18883881
#> 2: 4 4 4 0.18883881
#> 3: 5 5 5 0.02763754
#> 4: 5 5 5 0.01810314
#> 5: 5 5 5 0.01810314
#> 6: 3 3 3 0.02234209
#> 7: 3 3 3 0.02155020
#> 8: 3 3 3 0.02155020
#> 9: 3 3 3 0.03745019
#> 10: 3 3 3 0.02911226
#> specificity_quantile mean_exp mean_exp_quantile gene_freq
#> <num> <num> <num> <char>
#> 1: 40 0.7154 40 HP:0040283
#> 2: 40 0.7154 40 <NA>
#> 3: 35 0.1928 35 <NA>
#> 4: 30 0.0080 30 HP:0040281
#> 5: 30 0.0080 30 4/4
#> 6: 33 0.0454 33 HP:0040281
#> 7: 32 0.3288 32 <NA>
#> 8: 32 0.3288 32 HP:0040283
#> 9: 36 0.1838 36 HP:0040281
#> 10: 34 0.0786 34 HP:0040281
#> gene_freq_name gene_freq_min gene_freq_max gene_freq_mean estimate
#> <char> <num> <num> <num> <num>
#> 1: Occasional (29-5%) 5 29 17.0 3.896919
#> 2: <NA> NA NA NaN 2.915053
#> 3: <NA> NA NA NaN 2.915053
#> 4: Very frequent (99-80%) 80 99 89.5 2.311365
#> 5: 4/4 1 1 1.0 2.311365
#> 6: Very frequent (99-80%) 80 99 89.5 2.099415
#> 7: <NA> NA NA NaN 1.994699
#> 8: Occasional (29-5%) 5 29 17.0 1.953977
#> 9: Very frequent (99-80%) 80 99 89.5 1.707192
#> 10: Very frequent (99-80%) 80 99 89.5 1.640133
top_targets <- map_celltype(top_targets)
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
vn <- prioritise_targets_network(top_targets = top_targets)
#> Adding logFC column.
#> Cell type columns already present. Skipping mapping.
#> Creating network.
#> Making hoverboxes from: 'node', 'node_type', 'q', 'CellType', 'ancestor_name', 'disease_id', 'ontLvl', 'definition', 'hpo_name', 'hpo_id', 'disease_name', 'shape', 'name'
#> Adding hoverboxes to data.table.
#> Creating visNetwork plot.
#> 'title' column already exists. Skipping hoverbox creation.
#> Using palette: kovesi.linear_bmy_10_95_c78
#> Warning: Can't find 'name' in node data.frame
#> Saving plot --> /tmp/RtmpMmVOaL/file2ffc3a339e13_prioritise_targets_network.html