-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from TESTgroup-BNL/data_split_fix
A bug fix to correctly stratify cal/val datasets based on user-selected groupings. The issue was identified by @asierrl who also illustrated a potential fix, which has been included in the bug fix along with new tests to check that samples are not duplicated between cal and val.
- Loading branch information
Showing
22 changed files
with
6,866 additions
and
132 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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,4 +1,5 @@ | ||
library(testthat) | ||
library(dplyr) | ||
library(spectratrait) | ||
|
||
test_check("spectratrait") |
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,33 @@ | ||
context("Test that the create data split function has the expected behavior") | ||
|
||
test_that("Generating a data split using the dplyr approach doesn't throw an error or generate duplicates between cal. and val. data", { | ||
plot<- rep(c("plot1", "plot2", "plot3"),each=42) | ||
season<- rep(1:6, 21) | ||
disease<- c(rep(0,84), rep(1,42)) | ||
d<- seq(1:126) | ||
df <- data.frame(plot,season,disease,d) | ||
df <- df %>% mutate(id=row_number()) | ||
|
||
split_data <- spectratrait::create_data_split(dataset=df, approach="dplyr", | ||
split_seed=7529075, prop=0.8, | ||
group_variables=c("plot", | ||
"season", | ||
"disease")) | ||
expect_false(sum(split_data$cal_data$id %in% split_data$val_data$id)>0) | ||
}) | ||
|
||
test_that("Generating a data split using the base approach doesn't throw an error or generate duplicates between cal. and val. data", { | ||
plot<- rep(c("plot1", "plot2", "plot3"),each=42) | ||
season<- rep(1:6, 21) | ||
disease<- c(rep(0,84), rep(1,42)) | ||
d<- seq(1:126) | ||
df <- data.frame(plot,season,disease,d) | ||
df <- df %>% mutate(id=row_number()) | ||
|
||
split_data <- spectratrait::create_data_split(dataset=df, approach="base", | ||
split_seed=7529075, prop=0.8, | ||
group_variables=c("plot", | ||
"season", | ||
"disease")) | ||
expect_false(sum(split_data$cal_data$id %in% split_data$val_data$id)>0) | ||
}) |
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
Oops, something went wrong.