This 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,
  ...
)

Arguments

cell_type

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.

results

The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results.

color_var

Name of the variable (column) in results that should be used to color the graph nodes.

q_threshold

The q value threshold to subset the results by.

fold_threshold

The minimum fold change in specific expression to subset the results by.

hpo

Human Phenotype Ontology object, loaded from ontologyIndex.

phenotype_to_genes

Output of load_phenotype_to_genes mapping phenotypes to gene annotations.

palette

The colours or colour function that values will be mapped to

shape

Character vector of shape names for nodes (or function to set them). Defaults to "circle".

verbose

Print messages.

...

Arguments passed on to ontologyPlot::onto_plot

ontology

ontology_index object

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 terms with. Alternatively a function to set the colours of the nodes in the graph based on term_sets.

label

Character vector of labels (or function to set them).

color

Character vector of colours for borders of nodes representing terms (or function to set them).

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 "filled".

fixedsize

Character indicating whether nodes should be fixed size, "true", or adjusted to fit around the contained text, "false".

Value

A ontologyPlot plot of the network of phenotypes in a subset of RD EWCE results.

Details

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.

Examples

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!