R/ontology_plot.R
ontology_plot.RdThis subsets the results, using other functions from this script,
by cell type,
q value, and fold change. It then plots a graph/ network of
the phenotypes and
colors the nodes by their fold change or q value
(see the color_var param).
ontology_plot(
cell_type,
results = load_example_results(),
color_var = c("fold_change", "q", "p"),
q_threshold = 5e-04,
fold_threshold = 1,
hpo = HPOExplorer::get_hpo(),
phenotype_to_genes = HPOExplorer::load_phenotype_to_genes(),
palette = "Spectral",
shape = "rect",
verbose = TRUE,
...
)The cell type of interest to be plotted.
Can be a single string (e.g. "Astrocytes") or a character vector
of multiple cell types (e..g. c("Astrocytes","Microglia")).
Set to NULL if you wish to include all cell-types that are available
(after q_threshold and fold_threshold filtering).
If >1 cell-type remains, results will be aggregated automatically
such that there is only 1 node per phenotype.
The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results.
Name of the variable (column) in results
that should be used to color the graph nodes.
The q value threshold to subset the results by.
The minimum fold change in specific expression
to subset the results by.
Human Phenotype Ontology object, loaded from ontologyIndex.
Output of load_phenotype_to_genes mapping phenotypes to gene annotations.
The colours or colour function that values will be mapped to
Character vector of shape names for nodes (or function to set them). Defaults to "circle".
Print messages.
Arguments passed on to ontologyPlot::onto_plot
ontologyontology_index object
term_setsList of character vectors of ontological term IDs
frequenciesNumeric vector of term frequencies named by term IDs
termsCharacter vector of ontological terms
edge_attributesList of properties to set for arrows (note, these properties will be used for all arrow).
fillcolorCharacter vector of colours to fill nodes corresponding to terms with. Alternatively a function to set the colours of the nodes in the graph based on term_sets.
labelCharacter vector of labels (or function to set them).
colorCharacter vector of colours for borders of nodes representing terms (or function to set them).
widthNumeric vector of widths for nodes (of function to set them).
fontsizeNumeric vector of font sizes for the text to be placed in the nodes (or function to set them).
styleDisplay style for nodes, defaults to "filled".
fixedsizeCharacter indicating whether nodes should be fixed size, "true", or adjusted to fit around the contained text, "false".
A ontologyPlot plot of the network of phenotypes in a subset of RD EWCE results.
Developer notes: The ontologyPlot package did not have prebuilt options to create the heatmap, so the colours are assigned manually to each phenotype in this function. There must be a more efficient way to do this.
results = load_example_results()[seq(100000)]
plt <- ontology_plot(cell_type="ENS_glia", results=results)
#> Generating ontology plot.
#> Subsetting results by q_threshold and fold_change.
#> Subsetting results by cell_type
#> 2,618 associations remain after filtering.
#> ℹ All local files already up-to-date!