R/list_columns.R

Defines functions list_columns

Documented in list_columns

#' List columns
#'
#' Provide a list of columns to be used as hover metadata in an interactive
#' network plot generated by \link[HPOExplorer]{make_network_plot}.
#' @param add_gene_cols Add columns related to genes.
#' @param extra_cols Additional user-specified column names.
#' @inheritParams make_phenos_dataframe
#' @returns Named list of columns.
#'
#' @export
#' @examples
#' columns <- list_columns()
list_columns <- function(columns=NULL,
                         add_gene_cols=FALSE,
                         extra_cols=NULL){
  cols <- list(
    hover="hover",
    hpo_name="hpo_name",
    hpo_id="hpo_id",
    ontLvl="ontLvl",
    ontLvl_relative="ontLvl_relative",
    ontLvl_geneCount_ratio="ontLvl_geneCount_ratio",
    Definition="definition",
    ancestor="ancestor",
    ancestor_name="ancestor_name",
    CellType="CellType",
    p="p",
    q="q",
    fold_change="fold_change",
    #### Aggregated cols ####
    n_celltype="n_celltype",
    celltype="celltype",
    mean_p="mean_p",
    mean_q="mean_q",
    mean_fold_change="mean_fold_change",
    mean_sd_from_mean="mean_sd_from_mean")
  if(isTRUE(add_gene_cols)){
    cols[c("n_genes","genes")] <- c("n_genes","genes")
  }
  for(col in extra_cols){
    cols[col] <- col
  }
  if(!is.null(columns)){
    cols <- cols[columns]
  }
  return(cols)
}
neurogenomics/HPOExplorer documentation built on Aug. 24, 2024, 1:39 a.m.