R/check_phe_table.R

Defines functions check_phe_table

Documented in check_phe_table

#' Check if a phenotype table is valid.
#'
#' Check if a phenotype table is valid.
#' Will \link{stop} if not
#' @inheritParams default_params_doc
#' @return Nothing. Will \link{stop} if the \code{phe_table} is invalid
#' @seealso use \link{check_phe_table_ok_for_qt} to check if the `phe_table`
#' is valid for a quantitative trait analysis.
#' @examples
#' check_phe_table(get_test_phe_table())
#' @author Richèl J.C. Bilderbeek
#' @export
check_phe_table <- function(phe_table) {
  testthat::expect_true(tibble::is_tibble(phe_table))
  if (ncol(phe_table) < 3) {
    stop("Need at least 3 column in a phenotype (.phe) table")
  }
  # PLINK names, from
  # https://www.cog-genomics.org/plink/1.9/input#pheno
  testthat::expect_equal("FID", names(phe_table)[1])
  testthat::expect_equal("IID", names(phe_table)[2])
}
richelbilderbeek/plinkr documentation built on March 25, 2024, 3:18 p.m.