Skip to content

Commit

Permalink
Testing the temporary unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StijnVandenbulcke committed May 7, 2024
1 parent 3590a80 commit 9e78bb4
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Suggests:
RefManageR,
sessioninfo,
rmarkdown,
testthat,
testthat (>= 3.0.0),
tidyverse,
plotly,
msdata,
Expand Down Expand Up @@ -97,3 +97,4 @@ biocViews:
Preprocessing
URL: https://github.com/statOmics/msqrob2
BugReports: https://github.com/statOmics/msqrob2/issues
Config/testthat/edition: 3
62 changes: 62 additions & 0 deletions tests/testthat/test-msqrob.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#Create Data
#One protein that can be fit and one that returns a fitError
se_assay <- matrix(c(rnorm(n = 10,
mean = rep(c(5,10),
each =5),
sd = 0.1),
rep(NA,times=10)),
nrow =2,
byrow = TRUE,
dimnames = list(c("Protein1","Protein2"), LETTERS[1:10]))
se_cd <- DataFrame(treatment = rep(c("A","B"), each= 5),
row.names = LETTERS[1:10])
se <- SummarizedExperiment(assay = se_assay,
colData = se_cd)
qf <- QFeatures(List(se1 = se), colData = se_cd)
#Testing with SummarizedExperiment class
msqrob_output_se <- msqrob(object = se,
formula = ~ treatment,
robust = FALSE,
ridge = FALSE)

msqrob_output_qf <- msqrob(object = qf,
i = "se1",
formula = ~ treatment,
robust = FALSE,
ridge = FALSE)


test_that("Testing classes of msqrob output", {
expect_s4_class(msqrob_output_se, "SummarizedExperiment")
expect_s4_class(msqrob_output_qf, "QFeatures")
expect_s4_class(msqrob_output_qf[["se1"]],"SummarizedExperiment")
})


#As the output of the SummarizedExperiment and QFeatures are made with
#The same functions i will not be testing them separately
#Todo: Testing all the functions separately

test_that("Testing msqrob models", {
Protein1 <- rowData(msqrob_output_se)$msqrobModels$Protein1
Protein2 <- rowData(msqrob_output_se)$msqrobModels$Protein2

expect_s4_class(Protein1, "StatModel")
expect_s4_class(Protein2, "StatModel")

expect_equal(Protein1@type, expected = "lm")
expect_equal(Protein2@type, expected = "fitError")
})



#Todo:
#Testing coldata
# - Missing data
# - Subsetted data
# - levels (ordering as well, important for coefficient names)
#Testing rowdata
#Testing parameters
# - correct naming (check ordering with levels of coldata!)
# - correct values
# ...
3 changes: 3 additions & 0 deletions tests/testthat/test-testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("multiplication works", {
expect_equal(2 * 2, 4)
})

0 comments on commit 9e78bb4

Please sign in to comment.