-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Committed tests for cosinor based analysis.
- Loading branch information
Bharath Air
committed
May 27, 2024
1 parent
0afaf8c
commit 769fb1c
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
context("compareRhythms_cosinor") | ||
|
||
load("test_data_ma.rda") | ||
|
||
test_that("cosinor analysis works for default params and independent sampling", { | ||
results <- compareRhythms(expr, exp_design, method = "cosinor") | ||
expect_s3_class(results, "data.frame") | ||
expect_named(results, | ||
c("id", "category", "rhythmic_in_CC", "rhythmic_in_KD", "diff_rhythmic")) | ||
}) | ||
|
||
test_that("cosinor analysis works for different input params", { | ||
expect_error(compareRhythms(expr, exp_design, period = 12, method = "cosinor")) | ||
expect_s3_class(compareRhythms(expr, exp_design, rhythm_fdr = 0.01, method = "cosinor"), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, compare_fdr = 0.01, method = "cosinor"), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, rhythm_fdr = 0.1, compare_fdr = 0.01, method = "cosinor"), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, amp_cutoff = 0, method = "cosinor"), "data.frame") | ||
expect_error(compareRhythms(expr, exp_design, rhythm_fdr = 0, method = "cosinor")) | ||
results <- compareRhythms(expr, exp_design, just_classify = FALSE, method = "cosinor") | ||
expect_s3_class(results, "data.frame") | ||
expect_named(results, | ||
c("id", "category", "rhythmic_in_CC", "rhythmic_in_KD", "diff_rhythmic", "CC_amp", | ||
"CC_phase", "KD_amp", "KD_phase", "adj_p_val_CC_or_KD", "adj_p_val_DR")) | ||
}) | ||
|
||
test_that("cosinor analysis runs for arrhythmic dataset", { | ||
dim_y <- dim(expr) | ||
y_null <- matrix(0, nrow = dim_y[1], ncol = dim_y[2]) | ||
colnames(y_null) <- colnames(expr) | ||
rownames(y_null) <- rownames(expr) | ||
expect_error(compareRhythms(y_null, exp_design, method = "cosinor")) | ||
}) | ||
|
||
exp_design <- dplyr::mutate(dplyr::group_by(exp_design, group, time), ID = dplyr::row_number()) | ||
exp_design$ID <- factor(exp_design$ID) | ||
|
||
test_that("longitudinal cosinor analysis works for default params and independent sampling", { | ||
results <- compareRhythms(expr, exp_design, method = "cosinor", longitudinal = TRUE) | ||
expect_s3_class(results, "data.frame") | ||
expect_named(results, | ||
c("id", "category", "rhythmic_in_CC", "rhythmic_in_KD", "diff_rhythmic")) | ||
}) | ||
|
||
test_that("cosinor analysis works for different input params", { | ||
expect_error(compareRhythms(expr, exp_design, period = 12, method = "cosinor", longitudinal = TRUE)) | ||
expect_s3_class(compareRhythms(expr, exp_design, rhythm_fdr = 0.01, method = "cosinor", longitudinal = TRUE), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, compare_fdr = 0.01, method = "cosinor", longitudinal = TRUE), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, rhythm_fdr = 0.1, compare_fdr = 0.01, method = "cosinor", longitudinal = TRUE), "data.frame") | ||
expect_s3_class(compareRhythms(expr, exp_design, amp_cutoff = 0, method = "cosinor", longitudinal = TRUE), "data.frame") | ||
expect_error(compareRhythms(expr, exp_design, rhythm_fdr = 0, method = "cosinor", longitudinal = TRUE)) | ||
results <- compareRhythms(expr, exp_design, just_classify = FALSE, method = "cosinor", longitudinal = TRUE) | ||
expect_s3_class(results, "data.frame") | ||
expect_named(results, | ||
c("id", "category", "rhythmic_in_CC", "rhythmic_in_KD", "diff_rhythmic", "CC_amp", | ||
"CC_phase", "KD_amp", "KD_phase", "adj_p_val_CC_or_KD", "adj_p_val_DR")) | ||
}) | ||
|
||
test_that("cosinor analysis runs for arrhythmic dataset", { | ||
dim_y <- dim(expr) | ||
y_null <- matrix(0, nrow = dim_y[1], ncol = dim_y[2]) | ||
colnames(y_null) <- colnames(expr) | ||
rownames(y_null) <- rownames(expr) | ||
expect_error(compareRhythms(y_null, exp_design, method = "cosinor", longitudinal = TRUE)) | ||
}) | ||
|
||
|