plot_ontology_levels: Plot ontology levels

View source: R/plot_ontology_levels.R

plot_ontology_levelsR Documentation

Plot ontology levels

Description

Generate plots comparing the ontology level of each HPO phenotype and several other metrics.

Usage

plot_ontology_levels(
  results = load_example_results(),
  p2g = HPOExplorer::load_phenotype_to_genes(),
  ctd_list = load_example_ctd(file = paste0("ctd_", unique(results$ctd), ".rds"),
    multi_dataset = TRUE),
  x_vars = c("genes", "cell types", "estimate", "mean_specificity"),
  log_vars = x_vars %in% c("estimate", "statistic", "F", "ges", "effect"),
  sig_vars = x_vars %in% c("estimate", "statistic", "F", "ges", "effect", "cell types",
    "mean_specificity"),
  group_vars = c("hpo_id", "ontLvl", "ctd"),
  q_threshold = 0.05,
  min_value = NULL,
  label.x.npc = 0.05,
  label.y.npc = 0.5,
  n.breaks = 4,
  notch = FALSE,
  nrow = 2,
  add_arrow = TRUE,
  show_plot = TRUE,
  save_path = NULL,
  height = 7,
  width = length(x_vars) * 5.75,
  smooth.line.args = list(method = "loess", se = FALSE),
  return_data = TRUE
)

Arguments

results

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

p2g

Phenotype to gene data.

ctd_list

A named list of CellTypeDataset objects each created with generate_celltype_data.

x_vars

Variables to plot on the x-axis of each subplot.

log_vars

Logical vector indicating which variables to log-transform.

sig_vars

Logical vector indicating which variables to only plot for significant results.

group_vars

Compute the mean value for each x_vars grouped by the group_vars. This can be less accurate for some metrics but helps to drastically reduce computational load.

q_threshold

The q value threshold to subset the results by.

min_value

Minimum value for the specificity metric.

label.x.npc, label.y.npc

can be numeric or character vector of the same length as the number of groups and/or panels. If too short they will be recycled.

  • If numeric, value should be between 0 and 1. Coordinates to be used for positioning the label, expressed in "normalized parent coordinates".

  • If character, allowed values include: i) one of c('right', 'left', 'center', 'centre', 'middle') for x-axis; ii) and one of c( 'bottom', 'top', 'center', 'centre', 'middle') for y-axis.

If too short they will be recycled.

n.breaks

Passed to scale_fill_viridis_c.

notch

If FALSE (default) make a standard box plot. If TRUE, make a notched box plot. Notches are used to compare groups; if the notches of two boxes do not overlap, this suggests that the medians are significantly different.

nrow

Number of facet rows for the plot.

add_arrow

Add arrows indicating whether phenotypes are more broader or more specific across ontology levels.

show_plot

Print the plot to the console.

save_path

Save the plot to a file. Set to NULL to not save the plot.

height

Height of the saved plot.

width

Width of the saved plot.

smooth.line.args

A list of additional aesthetic arguments to be passed to geom_smooth geom used to display the regression line.

return_data

Return the full long data used in the plots.

Value

A named list containing the data and the plot.

Examples

out <- plot_ontology_levels()

neurogenomics/MultiEWCE documentation built on Sept. 28, 2024, 2:27 a.m.