Plot bar plot of enriched phenotypes per cell type per HPO branch.
plot_bar_dendro_facets(
results = load_example_results(),
results_full = NULL,
hpo = HPOExplorer::get_hpo(),
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
)
The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results
A full set of results (not just those selected for
plotting in results
) to be used as a background during proportional
enrichment testing.
Human Phenotype Ontology object, loaded from get_ontology.
A named list of HPO branches each matched with CL cell type branches that correspond to on-target cell types across the two ontologies.
Only HPO terms that have these ancestors will be kept.
A named list of HPO branches and matched CL ids.
Whether to plot the target branch ancestors
(TRUE
) or simply its descendants (FALSE
).
Name of the cell type column in the results
.
Only keep phenotypes at certain absolute ontology levels to keep. See add_ont_lvl for details.
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.
Colour map generated by map_colors to use for colouring the faceted bars (i.e. number of significant associations within a given HPO branch).
A vector of colors to use for colouring the x-axis text (i.e. cell types).
Preferred palettes to use for each column.
the default position of legends ("none", "left", "right", "bottom", "top", "inside")
Variable to fill by.
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")
.
Should scales be fixed ("fixed"
, the default),
free ("free"
), or free in one dimension ("free_x"
,
"free_y"
)?
The q value threshold to subset the results
by.
HPO ontology to display the final plot as.
A column to use when displaying the number of unique phenotypes within each facet.
Suffix for facets_n
text annotation.
Add vertical lines at specific x-axis intercepts (i.e. cell types).
Number of facet columns.
Columns to use for faceting.
y-axis label.
Normalise the bar heights from 0-1 within a given variable (e.g. "ancestor_name").
Whether to use the full set of results as a background for proportional enrichment testing.
Save the plot to a file.
Set to NULL
to not save the plot.
Width of the saved plot.
Height of the saved plot.
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)
#> Force new. Removing existing ancestor columns.
#> Warning: Tried to assign NULL to column 'ancestor', but this column does not exist to remove
#> Warning: Tried to assign NULL to column 'ancestor_name', but this column does not exist to remove
#> Adding level-6 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 19,025 IDs.
#> 2815 ancestors found at level 6
#> Translating ontology terms to names.
#> 2,201,892 associations remain after filtering.
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)
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Force new. Removing existing ancestor columns.
#> Adding level-7 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 19,025 IDs.
#> 3143 ancestors found at level 7
#> Translating ontology terms to names.
#> 2,201,892 associations remain after filtering.
#> Adding HPO names.
#> Translating ontology terms to names.
#> Translating ontology terms to ids.
#> Keeping descendants of 1 term(s).
#> 20 terms remain after filtering.
#> 4,020 associations remain after filtering.
#> Translating ontology terms to ids.
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/cl.rds
#> Ancestor columns already present. Skipping.
#> 4,020 associations remain after filtering.
#> Cell type columns already present. Skipping mapping.
#> Running tests: across_branches_per_celltype
#> Using palette: gnuplot