plot_bar_dendro_facets: Plot bar branches

View source: R/plot_bar_dendro_facets.R

plot_bar_dendro_facetsR Documentation

Plot bar branches

Description

Plot bar plot of enriched phenotypes per cell type per HPO branch.

Usage

plot_bar_dendro_facets(
  results = load_example_results(),
  results_full = NULL,
  target_branches = get_target_branches(),
  keep_ancestors = names(target_branches),
  target_celltypes = get_target_celltypes(target_branches = target_branches),
  target_branches_keep = NULL,
  celltype_col = "cl_name",
  keep_ont_levels = NULL,
  add_test_target_celltypes = TRUE,
  color_map = NULL,
  color_vector = NULL,
  preferred_palettes = "gnuplot",
  legend.position = "none",
  fill_var = "ancestor_name",
  facets = fill_var,
  scales = "free_y",
  q_threshold = NULL,
  lvl = NULL,
  facets_n = "phenotypes_per_ancestor",
  suffix = "phenotypes",
  vlines = NULL,
  ncol = 1,
  cols = NULL,
  y_lab = "Significant phenotypes",
  normalise_by = NULL,
  background_full = TRUE,
  save_path = NULL,
  width = NULL,
  height = NULL
)

Arguments

results

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

results_full

A full set of results (not just those selected for plotting in results) to be used as a background during proportional enrichment testing.

target_branches

A named list of HPO branches each matched with CL cell type branches that correspond to on-target cell types across the two ontologies.

keep_ancestors

Only HPO terms that have these ancestors will be kept.

target_celltypes

A named list of HPO branches and matched CL ids.

target_branches_keep

Whether to plot the target branch ancestors (TRUE) or simply its descendants (FALSE).

celltype_col

Name of the cell type column in the results.

keep_ont_levels

Only keep phenotypes at certain absolute ontology levels to keep. See add_ont_lvl for details.

add_test_target_celltypes

Using the significant phenotype-cell type association results, run proportional enrichment tests to determine whether each cell type is overrepresented in a given HPO branch relative to all other HPO branches. Overrepresented cell types will be denoted by "*" above its bar.

color_map

Colour map generated by map_colors to use for colouring the faceted bars (i.e. number of significant associations within a given HPO branch).

color_vector

A vector of colors to use for colouring the x-axis text (i.e. cell types).

preferred_palettes

Preferred palettes to use for each column.

legend.position

the default position of legends ("none", "left", "right", "bottom", "top", "inside")

fill_var

Variable to fill by.

facets

A set of variables or expressions quoted by vars() and defining faceting groups on the rows or columns dimension. The variables can be named (the names are passed to labeller).

For compatibility with the classic interface, can also be a formula or character vector. Use either a one sided formula, ~a + b, or a character vector, c("a", "b").

scales

Should scales be fixed ("fixed", the default), free ("free"), or free in one dimension ("free_x", "free_y")?

q_threshold

The q value threshold to subset the results by.

lvl

HPO ontology to display the final plot as.

facets_n

A column to use when displaying the number of unique phenotypes within each facet.

suffix

Suffix for facets_n text annotation.

vlines

Add vertical lines at specific x-axis intercepts (i.e. cell types).

ncol

Number of facet columns.

cols

Columns to use for faceting.

y_lab

y-axis label.

normalise_by

Normalise the bar heights from 0-1 within a given variable (e.g. "ancestor_name").

background_full

Whether to use the full set of results as a background for proportional enrichment testing.

save_path

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

width

Width of the saved plot.

height

Height of the saved plot.

Examples

hpo <- HPOExplorer::get_hpo()
target_branches <- list("Recurrent bacterial infections"="leukocyte")
lvl <- subset(hpo@elementMetadata,name==names(target_branches)[1])$ontLvl
results <- load_example_results()
results <- HPOExplorer::add_ancestor(results,
                                     lvl = lvl,
                                     force_new = TRUE)
out <- plot_bar_dendro_facets(results=results,
                         target_branches=target_branches,
                         facets = "hpo_name",
                         legend.position="right",
                         lvl=lvl+1,
                         ncol=2,
                         vlines="hepatoblast",
                         facets_n=NULL,
                         q_threshold=0.05,
                         background_full=FALSE)

neurogenomics/MultiEWCE documentation built on April 22, 2024, 6:22 a.m.