Title: | Visualising Sets of Ontological Terms |
---|---|
Description: | Create R plots visualising ontological terms and the relationships between them with various graphical options - Greene et al. 2017 <doi:10.1093/bioinformatics/btw763>. |
Authors: | Daniel Greene <[email protected]> |
Maintainer: | Daniel Greene <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.7 |
Built: | 2024-11-17 03:09:13 UTC |
Source: | https://github.com/cran/ontologyPlot |
Get logical matrix of term annotation for group of cases
annotation_grid( ontology, term_sets, all_terms = grid_terms(ontology, term_sets), remove_unanimous = FALSE, cluster_rows = TRUE, cluster_cols = TRUE )
annotation_grid( ontology, term_sets, all_terms = grid_terms(ontology, term_sets), remove_unanimous = FALSE, cluster_rows = TRUE, cluster_cols = TRUE )
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
all_terms |
Character vector giving terms to use in annotation. |
remove_unanimous |
Logical value determining whether to remove terms present in all |
cluster_rows |
Logical value rows determining whether to use hclust to cluster |
cluster_cols |
Logical value rows determining whether to use hclust to cluster terms (based on correlation of inclusion in |
Logical matrix.
Could be useful to modify a vector of sizes to between, say 1 and 3, before passing to 'onto_plot'.
calibrate_sizes(x, high, low)
calibrate_sizes(x, high, low)
x |
Numeric vector |
high |
Numeric value of largest size |
low |
Numeric value of smallest size |
Numeric vector
calibrate_sizes(c("HP:0000001"=10, "HP:0000006"=5), high=3, low=1)
calibrate_sizes(c("HP:0000001"=10, "HP:0000006"=5), high=3, low=1)
term_sets
Function to assign colours to terms based on frequency with which terms appear in term_sets
colour_by_frequency( ontology, terms, term_sets, colour_func = colorRampPalette(c("Yellow", "Green", "#0099FF")) )
colour_by_frequency( ontology, terms, term_sets, colour_func = colorRampPalette(c("Yellow", "Green", "#0099FF")) )
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
colour_func |
Function capable of returning a set of colours, given the number of colours it needs to return |
Character vector of colours, named by term
colour_by_term_set
, colour_by_population_frequency
Function to assign colours to terms based on population frequency of terms
colour_by_population_frequency( ontology, terms, frequencies, colour_palette = colorRampPalette(c("Yellow", "Green", "#0099FF"))(10), max_colour_freq = max(terms_freq), min_colour_freq = min(terms_freq) )
colour_by_population_frequency( ontology, terms, frequencies, colour_palette = colorRampPalette(c("Yellow", "Green", "#0099FF"))(10), max_colour_freq = max(terms_freq), min_colour_freq = min(terms_freq) )
ontology |
|
terms |
Character vector of ontological terms |
frequencies |
Numeric vector of term frequencies named by term IDs |
colour_palette |
Character vector of colours for the different information contents of the terms to be plotted, going from rare to common |
max_colour_freq |
Numeric value in [0, 1] giving the maximum frequency (to which the dullest color will be assigned) |
min_colour_freq |
Numeric value in [0, 1] giving the minimum frequency (to which the brightest color will be assigned) |
Character vector of colours, named by term
colour_by_term_set
, colour_by_frequency
Function to set colours of nodes in plot to distinguish terms belonging to different term sets
colour_by_term_set( ontology, terms, term_sets, colour_generator = rainbow, alpha = 0.5 )
colour_by_term_set( ontology, terms, term_sets, colour_generator = rainbow, alpha = 0.5 )
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
colour_generator |
Function which returns a vector of colours, e.g. |
alpha |
|
Character vector of colours, named by term.
colour_by_frequency
, colour_by_population_frequency
ontology_plot
object to dot stringontology_plot
object to dot string
dot_string(ontology_plot)
dot_string(ontology_plot)
ontology_plot |
Object of class 'ontology_plot' to export. |
String
Get an adjacency matrix for a set of ontological terms
get_adjacency_matrix(ontology, terms)
get_adjacency_matrix(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms |
A logical matrix representing the adjacency matrix of terms
based on the directed acyclic graph of ontology
. A TRUE
entry means the term correspnding to the column is a parent of the row term in ontology
.
library(ontologyIndex) data(hpo) get_adjacency_matrix(hpo, c("HP:0000118", "HP:0001873", "HP:0011877"))
library(ontologyIndex) data(hpo) get_adjacency_matrix(hpo, c("HP:0000118", "HP:0001873", "HP:0011877"))
Split up node labels across lines so they fit in nodes better
get_node_friendly_long_names(ontology, terms, official_names = FALSE)
get_node_friendly_long_names(ontology, terms, official_names = FALSE)
ontology |
|
terms |
Character vector of ontological terms |
official_names |
Logical value indicating whether to use the exact names from the ontology. Otherwise, shortened, capitalised names are used. |
Character vector.
library(ontologyIndex) data(hpo) get_node_friendly_long_names(hpo, c("HP:0001873", "HP:0011877"))
library(ontologyIndex) data(hpo) get_node_friendly_long_names(hpo, c("HP:0001873", "HP:0011877"))
ontology_plot
objectFunction to create ontology_plot
objects where all graphical parameters to be used must be specified.
get_ontology_plot( ontology, terms, edge_attributes = list(color = "#000000", lty = "solid"), ... )
get_ontology_plot( ontology, terms, edge_attributes = list(color = "#000000", lty = "solid"), ... )
ontology |
|
terms |
Character vector of ontological terms |
edge_attributes |
List of properties to set for arrows (note, these properties will be used for all arrow). |
... |
Named graphical parameters. These must either be vectors of values the same length as |
ontology_plot
object.
Get an adjacency matrix for a set of ontological terms
get_pseudo_adjacency_matrix(ontology, terms)
get_pseudo_adjacency_matrix(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms |
A logical matrix representing the adjacency matrix of terms
based on the directed acyclic graph of ontology
. A TRUE
entry means the term correspnding to the column is a parent of the row term within terms
.
library(ontologyIndex) data(hpo) get_pseudo_adjacency_matrix(hpo, c("HP:0000118", "HP:0001873", "HP:0011877"))
library(ontologyIndex) data(hpo) get_pseudo_adjacency_matrix(hpo, c("HP:0000118", "HP:0001873", "HP:0011877"))
Get human readable, shortened (where possible) ontological term names
get_shortened_names(ontology, terms)
get_shortened_names(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms |
Character vector
library(ontologyIndex) data(hpo) get_shortened_names(hpo, c("HP:0001873", "HP:0011877"))
library(ontologyIndex) data(hpo) get_shortened_names(hpo, c("HP:0001873", "HP:0011877"))
Get set of HPO terms appropriate for showing in a grid
grid_terms(ontology, term_sets)
grid_terms(ontology, term_sets)
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
Character vector of terme IDs.
term_sets
Function to get plot labels for terms based on frequency in term_sets
label_by_frequency(ontology, terms, term_sets)
label_by_frequency(ontology, terms, term_sets)
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
Character vector of labels, named by term.
term_set
Function to label nodes by term_set
label_by_term_set(ontology, terms, term_sets)
label_by_term_set(ontology, terms, term_sets)
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
Character vector of colours, named by term.
simple_labels
, label_by_frequency
, long_labels
Label includes term ID, term name, number of instances of term amongst term_sets
and percentage frequency in population.
long_labels(ontology, terms, term_sets, frequencies)
long_labels(ontology, terms, term_sets, frequencies)
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
frequencies |
Numeric vector of term frequencies named by term IDs |
Character vector of labels, named by term.
simple_labels
, label_by_frequency
, label_by_term_set
n
most prevalent terms in term_sets
Selects n
most prevalent terms in set of term sets/annotations including implicit terms. If more than one term are tied at the n
th position, all terms are included in the result.
n_most_frequent_terms( ontology, term_sets, n, terms = unique(unlist(term_sets)) )
n_most_frequent_terms( ontology, term_sets, n, terms = unique(unlist(term_sets)) )
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
n |
Integer |
terms |
Character vector of ontological terms |
Character vector of length at most n
remove_terms_with_less_than_n_occurrences
library(ontologyIndex) data(hpo) n_most_frequent_terms(hpo, c("HP:0001873"), list(term_sets=list("HP:0001873", "HP:0001902")), n=2)
library(ontologyIndex) data(hpo) n_most_frequent_terms(hpo, c("HP:0001873"), list(term_sets=list("HP:0001873", "HP:0001902")), n=2)
Get official names for terms
official_labels(ontology, terms)
official_labels(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms |
Character vector of labels, named by term.
ontology_plot
objectA convenience wrapper for the get_ontology_plot
function, enabling functions to be passed to generate graphical parameters for terms
automatically.
onto_plot( ontology, term_sets = NULL, frequencies = NULL, terms = remove_uninformative_terms(ontology, term_sets), edge_attributes = list(color = "#000000", lty = "solid"), fillcolor = "powderblue", label = simple_labels, color = "transparent", width = 0.75, fontsize = 30, style = "filled", fixedsize = "true", shape = "circle", ... )
onto_plot( ontology, term_sets = NULL, frequencies = NULL, terms = remove_uninformative_terms(ontology, term_sets), edge_attributes = list(color = "#000000", lty = "solid"), fillcolor = "powderblue", label = simple_labels, color = "transparent", width = 0.75, fontsize = 30, style = "filled", fixedsize = "true", shape = "circle", ... )
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
frequencies |
Numeric vector of term frequencies named by term IDs |
terms |
Character vector of ontological terms |
edge_attributes |
List of properties to set for arrows (note, these properties will be used for all arrow). |
fillcolor |
Character vector of colours to fill nodes corresponding to |
label |
Character vector of labels (or function to set them). |
color |
Character vector of colours for borders of nodes representing |
width |
Numeric vector of widths for nodes (of function to set them). |
fontsize |
Numeric vector of font sizes for the text to be placed in the nodes (or function to set them). |
style |
Display style for nodes, defaults to |
fixedsize |
Character indicating whether nodes should be fixed size, |
shape |
Character vector of shape names for nodes (or function to set them). Defaults to |
... |
Other node attributes for dot format. |
ontology_plot
object.
library(ontologyIndex) data(hpo) hpo_phenotypes <- c( A=c("HP:0001382","HP:0004272","HP:0007917","HP:0004912","HP:0001596"), B=c("HP:0001382","HP:0004272","HP:0002165","HP:0004800","HP:0004912"), C=c("HP:0004800","HP:0001382","HP:0004912","HP:0007917","HP:0008743"), D=c("HP:0001257","HP:0001382","HP:0007917","HP:0012623","HP:0002165"), E=c("HP:0007917","HP:0004800","HP:0004272","HP:0001596","HP:0002165") ) onto_plot( ontology=hpo, term_sets=hpo_phenotypes )
library(ontologyIndex) data(hpo) hpo_phenotypes <- c( A=c("HP:0001382","HP:0004272","HP:0007917","HP:0004912","HP:0001596"), B=c("HP:0001382","HP:0004272","HP:0002165","HP:0004800","HP:0004912"), C=c("HP:0004800","HP:0001382","HP:0004912","HP:0007917","HP:0008743"), D=c("HP:0001257","HP:0001382","HP:0007917","HP:0012623","HP:0002165"), E=c("HP:0007917","HP:0004800","HP:0004272","HP:0001596","HP:0002165") ) onto_plot( ontology=hpo, term_sets=hpo_phenotypes )
Functions for visualising sets of ontological terms using the ‘graphviz’ layout system.
Daniel Greene <[email protected]>
Maintainer: Daniel Greene <[email protected]>
Greene D, Richardson S, Turro E (2017). 'ontologyX: a suite of R packages for working with ontological data. _Bioinformatics_, 33(7), 1104–1106.
‘The Human Phenotype Ontology project: linking molecular biology and disease through phenotype data’, Nucl. Acids Res. (1 January 2014) 42 (D1): D966-D974 doi:10.1093/nar/gkt1026 Westbury, S. K. et al. (2015). Human Phenotype Ontology annotation and cluster analysis to un- ravel genetic defects in 707 cases with unexplained bleeding and platelet disorders. Genome Medicine. 7 (2015)
term_sets
given the population frequencies of the termsGet p-values for observing at least as many of each term as occur in term_sets
given the population frequencies of the terms
p_values_for_occurrence_of_term_in_group(ontology, term_sets, terms_freq)
p_values_for_occurrence_of_term_in_group(ontology, term_sets, terms_freq)
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
terms_freq |
Numeric vector of population frequencies of terms. |
Numeric vector of log p-values named by correspnding term.
Plot a logical matrix of term annotation
plot_annotation_grid(..., on_colour = "#FF0000FF", off_colour = "#FFFFBFFF")
plot_annotation_grid(..., on_colour = "#FF0000FF", off_colour = "#FFFFBFFF")
... |
Arguments to be passed to |
on_colour |
Colour to use to show presence of term. |
off_colour |
Colour to use to show absence of term. |
Plots heatmap.
ontology_plot
objectPlotting function for ontology_plot
object
## S3 method for class 'ontology_plot' plot(x, ...)
## S3 method for class 'ontology_plot' plot(x, ...)
x |
Object of class ontologicalPlot. |
... |
Other options passed to plot(). |
Nothing, side-effect: plots a graph.
ontology_plot
objectPrint function for ontology_plot
object
## S3 method for class 'ontology_plot' print(x, ...)
## S3 method for class 'ontology_plot' print(x, ...)
x |
Object of class ontologicalPlot. |
... |
Other options passed to be passed to plot(). |
Nothing. Side-effect: plots graphs.
Remove terms which just link two other terms together in a subontology
remove_links(ontology, terms, hard = FALSE)
remove_links(ontology, terms, hard = FALSE)
ontology |
|
terms |
Character vector of ontological terms |
hard |
Logical value determining whether to multiple edges to leaf terms are kept - |
Character vector.
library(ontologyIndex) data(hpo) remove_links(hpo, c("HP:0001873","HP:0001872","HP:0011873","HP:0011877"))
library(ontologyIndex) data(hpo) remove_links(hpo, c("HP:0001873","HP:0001872","HP:0011873","HP:0011877"))
Remove terms with less than certain number of occurrences
remove_terms_with_less_than_n_occurrences( ontology, term_sets, n, terms = unique(unlist(term_sets)) )
remove_terms_with_less_than_n_occurrences( ontology, term_sets, n, terms = unique(unlist(term_sets)) )
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
n |
Integer |
terms |
Character vector of ontological terms |
Character vector
library(ontologyIndex) data(hpo) remove_terms_with_less_than_n_occurrences(hpo, term_sets=list("HP:0001873", "HP:0001902"), n=2)
library(ontologyIndex) data(hpo) remove_terms_with_less_than_n_occurrences(hpo, term_sets=list("HP:0001873", "HP:0001902"), n=2)
For a set of ontological annotation sets, remove terms annotated to the same objects as all their children. Useful for selecting terms for summarising a set of annotation sets, as it can lead to a significant reduction in the number of terms.
remove_uninformative_terms(ontology, term_sets)
remove_uninformative_terms(ontology, term_sets)
ontology |
|
term_sets |
List of character vectors of ontological term IDs |
Character vector of terms
library(ontologyIndex) data(hpo) remove_uninformative_terms(hpo, list(Patient1=c("HP:0001873","HP:0000118")))
library(ontologyIndex) data(hpo) remove_uninformative_terms(hpo, list(Patient1=c("HP:0001873","HP:0000118")))
Capitalise words in character vector
simple_cap(x)
simple_cap(x)
x |
Character vector |
Character vector
simple_cap(c("a simple test", "Another-test"))
simple_cap(c("a simple test", "Another-test"))
Get simplified labels for terms
simple_labels(ontology, terms)
simple_labels(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms |
Character vector of labels, named by term.
ontology_plot
to SVG stringNote that by setting "id"
and "class"
attributes it enables nodes to be selected for manipulation using Javascript if interactivity is desired.
to_svg_string(op)
to_svg_string(op)
op |
Object of class |
Character vector of length 1 containing SVG representation of node.
term_sets
Function to get node sizes for terms based on frequency in term_sets
width_by_frequency(ontology, terms, term_sets)
width_by_frequency(ontology, terms, term_sets)
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
Character vector of sizes, named by term
term_sets
Function to get node sizes for terms based on statistical significance of seeing at least this number of each term in term_sets
width_by_significance(ontology, terms, term_sets, frequencies)
width_by_significance(ontology, terms, term_sets, frequencies)
ontology |
|
terms |
Character vector of ontological terms |
term_sets |
List of character vectors of ontological term IDs |
frequencies |
Numeric vector of term frequencies named by term IDs |
Character vector of sizes, named by term
ontology_plot
object as dot fileExport ontology_plot
object as dot file
write_dot(ontology_plot, file)
write_dot(ontology_plot, file)
ontology_plot |
Object of class 'ontology_plot' to export. |
file |
Character value of target file path. |
Nothing, side effect - writes to file.