R/fct_dropdown_config.R

Defines functions filter_dropdown_options project_dropdown_options

#' dropdown_config
#' @description Function to return options for dropdowns
#' @return A named list with entries corresponding to module and inputId
#' @noRd
project_dropdown_options <- function() {
  all_dropdown_fields <-
    c(
      "ExperimentId",
      "AnalysisType",
      "ExpName",
      "ExpDescription",
      "NumberOfSamples",
      "CompanyOrg",
      "Organism",
      "Platform",
      "ContactEmail",
      "ContactName",
      "DateOfAnalysis",
      "Analyst"
    )

  default_dropdown_fields <- c(
    "ExperimentId",
    "AnalysisType",
    "Organism",
    "Platform",
    "DateOfAnalysis",
    "Analyst"
  )

  additional_dropdown_fields <-
    setdiff(all_dropdown_fields, default_dropdown_fields)

  list(
    AllDropdownFields = all_dropdown_fields,
    DefaultDropdownFields = default_dropdown_fields,
    AdditionalDropdownFields = additional_dropdown_fields
  )
}

filter_dropdown_options <- function(target_table) {
  non_numeric_index <- sapply(target_table, \(x) class(x) %in% c("character", "factor"))
  non_numeric_table <- target_table[, non_numeric_index]
  meta_columns <-
    c(
      "ExperimentId",
      "AnalysisType",
      "FlankSize",
      "SampleName",
      "TargetId",
      "MutationType",
      "Group",
      "TimePoint",
      "Disease",
      "GdnaId"
    )

  list(
    ColsToHideOptions = setNames(seq_along(names(target_table)), names(target_table)),
    ColsToHideSelected = setNames(seq_along(names(target_table)), names(target_table)),
    ColsForGroup = setNames(seq_along(names(target_table)), names(target_table))[meta_columns] %>% purrr::discard(is.na)
  )
}
teofiln/gene.editing.dash documentation built on Feb. 21, 2022, 12:59 a.m.