tests/testthat/test-confounders-lsq.R

# test confounders lsq
test_that('confounders lsq',{
  set.seed('57475')
  # DatasetExperiment
  D=iris_DatasetExperiment()
  D$sample_meta$Rnd=sample(D$sample_meta$Species,150) # random effect
  # method
  ME=confounders_clsq(factor_name='Species',confounding_factors='Rnd',threshold=0.15)
  ME=model_apply(ME,D)
  # expect all true
  expect_true(all(as.matrix(ME$significant)))

})

# confounders_lsq plots
# test confounders lsq
test_that('confounders lsq barchart',{
  set.seed('57475')
  # DatasetExperiment
  D=iris_DatasetExperiment()
  D$sample_meta$Rnd=sample(D$sample_meta$Species,150) # random effect
  # method
  ME=confounders_clsq(factor_name='Species',confounding_factors='Rnd',threshold=0.15)
  ME=model_apply(ME,D)
  # chart
  C=confounders_lsq_barchart(feature_to_plot='Petal.Length')
  gg=chart_plot(C,ME)
  # expect all true
  expect_true(is(gg,'ggplot'))

})

# test confounders lsq
test_that('confounders lsq boxplot',{
  set.seed('57475')
  # DatasetExperiment
  D=iris_DatasetExperiment()
  D$sample_meta$Rnd=sample(D$sample_meta$Species,150) # random effect
  # method
  ME=confounders_clsq(factor_name='Species',confounding_factors='Rnd',threshold=0.15)
  ME=model_apply(ME,D)
  # chart
  C=confounders_lsq_boxplot()
  gg=chart_plot(C,ME)
  # expect all true
  expect_true(is(gg,'ggplot'))

})

Try the structToolbox package in your browser

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

structToolbox documentation built on Nov. 8, 2020, 6:54 p.m.