tests/testthat/test_prepNlmeData.R

context("Test prepNlmeData")

test_data<- readRDS("norm_single_agents_test.rds")
norm_data <- normalizeData(test_data)


context("Test prepNlmeData")

test_that("prepNlmeData gives an error if setConcsForNlme has not been run first", {
  testthat::expect_error(
    prepNlmeData(norm_data, cl_id = "COSMIC_ID"),
    "No maxc or x columns in the normalized_data. Run setConcsForNlme\\(\\) before prepNlmeData"
    )
})

test_that("prepNlmeData gives an error if no cl_id is chosen", {
  norm_data <- setConcsForNlme(norm_data)
  testthat::expect_error(
    prepNlmeData(norm_data, drug_specifiers = c("DRUG_ID_lib", "maxc")),
    "choose a suitable cl_id: COSMIC_ID, MASTER_CELL_ID or CELL_ID"
    )
})

test_that("prepNlmeData gives an error if a non-column drug_specifier is chosen", {
  norm_data <- setConcsForNlme(norm_data)
  testthat::expect_error(
    prepNlmeData(norm_data,
                 cl_id = "COSMIC_ID",
                 drug_specifiers = ("drug_identifier")),
    "Your normalized data does not contain the columns specified to make the drug column."
    )
})


test_that("prepNlmeData gives a warning if setConcsForNlme has not grouped 
          concentrations and drug specifiers doesn't use maxc when there is a
          drug at two ranges (9002).", {
  norm_data <- setConcsForNlme(norm_data, group_conc_ranges = F)
  testthat::expect_warning(
    prepNlmeData(norm_data, cl_id = "COSMIC_ID", drug_specifiers = c("DRUG_ID_lib")),
    "There is more than one maximum concentration for drug "
    )
})
CancerRxGene/gdscIC50 documentation built on Oct. 6, 2022, 2:40 a.m.