-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check on batch normalisation assumptions.
- Loading branch information
1 parent
6057bff
commit 111dfd7
Showing
4 changed files
with
75 additions
and
19 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
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
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
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 |
---|---|---|
@@ -1,16 +1,42 @@ | ||
# Continuous outcomes | ||
# Avoid warnings due to non-standard evaluation in data.table. | ||
outcome <- outcome_time <- NULL | ||
|
||
# Generate data. | ||
data <- familiar:::test_create_synthetic_series_data( | ||
outcome_type = "survival", | ||
n_batch = 3L, | ||
n_samples = 50L, | ||
n_series = 1L, | ||
n_rep = 1L | ||
) | ||
|
||
# Test results | ||
.check_batch_normalisation_assumptions( | ||
data = data, | ||
normalisation_method = "combat" | ||
) | ||
for (outcome_type in c("continuous", "binomial", "multinomial", "survival")) { | ||
# Generate data. | ||
data <- familiar:::test_create_good_data(outcome_type = outcome_type) | ||
data@data[, "batch_id" := "A"] | ||
data_b <- familiar:::test_create_good_data(outcome_type = outcome_type) | ||
data_b@data[, "batch_id" := "B"] | ||
data_c <- familiar:::test_create_good_data(outcome_type = outcome_type) | ||
data_c@data[, "batch_id" := "C"] | ||
data@data <- rbind(data@data, data_b@data, data_c@data) | ||
|
||
# Introduce data with offset. | ||
data_offset <- data | ||
data_offset@data <- data.table::copy(data_offset@data) | ||
if (outcome_type == "continuous") { | ||
data_offset@data[batch_id == "A", "outcome" := outcome + 50.0] | ||
|
||
} else if (outcome_type %in% c("binomial", "multinomial")) { | ||
data_offset@data[batch_id == "A", "outcome" := "red"] | ||
|
||
} else if (outcome_type == "survival") { | ||
data_offset@data[batch_id == "A", "outcome_time" := outcome_time + 1000.0] | ||
} | ||
|
||
# Test results | ||
testthat::expect_no_condition( | ||
familiar:::.check_batch_normalisation_assumptions( | ||
data = data, | ||
normalisation_method = "combat" | ||
) | ||
) | ||
|
||
testthat::expect_warning( | ||
familiar:::.check_batch_normalisation_assumptions( | ||
data = data_offset, | ||
normalisation_method = "combat" | ||
), | ||
class = "familiar_batch_outcome_difference" | ||
) | ||
} |