tests/testthat/test-genRownames.R

set.seed(1)
n <- 50
a <- sample(LETTERS, n, replace = TRUE)
b <- sample(1:99, size = n, replace = TRUE)

test_that("genRowNames generates correct rownames to data frame", {
  rn <- data.frame(SlideId = a, Subarray = b) |> genRowNames()
  expect_equal(rn, paste0(a, "_", b))
})

test_that("genRowNames numbers numerically if no SlideId or Subarray", {
  expect_warning(
    df <- data.frame(Slide = a, Sub = b) |> genRowNames(),
    "No SlideId_Subarray found in ADAT. Rows numbered sequentially."
  )
  expect_equal(df, as.character(1:n))
})

Try the SomaDataIO package in your browser

Any scripts or data that you put into this service are public.

SomaDataIO documentation built on April 4, 2025, 2:14 a.m.