#' Create interactive network plot start to finish
#'
#' This puts all the functions together from getting the subset of results
#' to creating the final interactive plot.
#'
#' @param results The cell type-phenotype enrichment results generated by
#' \link[MSTExplorer]{gen_results}
#' and merged together with \link[MSTExplorer]{merge_results}
#' @param q_threshold The q value threshold to subset the \code{results} by.
#' @param effect_threshold The minimum fold change in specific expression
#' to subset the \code{results} by.
#' @inheritParams HPOExplorer::make_phenos_dataframe
#' @inheritParams HPOExplorer::make_network_plot
#' @inheritParams HPOExplorer::filter_descendants
#' @inheritParams HPOExplorer::make_network_object
#' @inheritParams KGExplorer::filter_dt
#' @inheritDotParams HPOExplorer::make_network_plot
#' @returns A named list of outputs,
#' including a interactive network plot of the selected subset
#' of results from RD EWCE analysis.
#'
#' @export
#' @import HPOExplorer
#' @import KGExplorer
#' @examples
#' res <- ggnetwork_plot_full(filters = list(CellType = "Microglia"))
ggnetwork_plot_full <- function(filters,
keep_descendants = NULL,
results = load_example_results(),
hpo = HPOExplorer::get_hpo(),
q_threshold = 0.0005,
effect_threshold = 1,
columns = HPOExplorer::list_columns(),
colour_var = "effect",
size_var = "ontLvl_relative",
add_ont_lvl_absolute = TRUE,
add_ont_lvl_relative = TRUE,
method = c("ggnetwork","visnetwork"),
interactive = TRUE,
verbose = TRUE,
...){
messager("ggnetwork_plot_full",v=verbose)
phenos <- subset_phenos(filters = filters,
keep_descendants = keep_descendants,
results = results,
hpo = hpo,
q_threshold = q_threshold,
effect_threshold = effect_threshold,
verbose = verbose)
phenos <- HPOExplorer::add_hpo_name(phenos = phenos,
hpo = hpo)
#### Aggregate across multiple celltypes ####
phenos <- agg_results(phenos = phenos,
count_var = "CellType",
group_var = c("hpo_name","hpo_id"),
verbose = verbose)
#### Add metadata ####
if(isTRUE(add_ont_lvl_absolute)){
phenos <- HPOExplorer::add_ont_lvl(phenos = phenos,
hpo = hpo,
absolute = TRUE)
}
if(isTRUE(add_ont_lvl_relative)){
phenos <- HPOExplorer::add_ont_lvl(phenos = phenos,
hpo = hpo,
absolute = FALSE)
}
phenos <- HPOExplorer::add_hpo_definition(phenos = phenos,
verbose = verbose)
phenos <- KGExplorer::add_hoverboxes(g = phenos,
columns = names(columns),
hoverbox_column = "hover",
as_html = interactive)
#### Fix colour var for aggregated data ####
colour_var2 <- paste0("mean_",colour_var)
if(!colour_var %in% names(phenos) &&
colour_var2 %in% names(phenos)){
colour_var <- colour_var2
}
#### Make plot ####
out <- HPOExplorer::make_network_plot(phenos = phenos,
colour_var = colour_var,
size_var = size_var,
interactive = interactive,
method = method,
...)
#### Return ####
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.