Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table skips is.data.frame check #20

Open
bonifazi opened this issue Nov 19, 2024 · 1 comment
Open

data.table skips is.data.frame check #20

bonifazi opened this issue Nov 19, 2024 · 1 comment

Comments

@bonifazi
Copy link
Owner

bonifazi commented Nov 19, 2024

Script: https://github.com/bonifazi/TuttiFrutti/blob/main/compute_LR_stats.R

if EBV partial and EBV whole are data.table the script returns:

val_results[[run]][[t]][[s]][[l]][[g]] <- compute_LR_stats(
                      EBV_partial = ebv.tmp[, c("AID", "sol_part" )],
                      EBV_whole   = ebv.tmp[, c("AID", "sol_whole")],
                      val_group = data.frame(AID = val.tmp[, "AID"]),
                      # val_subgroup = NA, 
                      # VAR_A = NA,
                      # inbreeding = inbreeding[[paste0("run", run)]], # inbreeding file (val group AID will be subsetted)
                      # plot = T,
                      bootstrap = F,
                      boot_samples = 10,
                      parallel = "multicore", 
                      ncpus = 15,
                      verbose = T)
Error in compute_LR_stats(EBV_partial = ebv.tmp[, c("AID", "sol_part")],  : 
  Not all IDs provided in 'val_groupIDs' were sub-set from the 'EBV_partial' and 'EBV_whole' data.frames. Make sure to provide in 'val_groupIDs' args only IDs that exist in data.frames 'EBV_partial' and 'EBV_whole'

Funny enough, the script gets stuck with no error message if bootstrap == T.

Two observations: 1) is.data.frame returns T on a data.table obj. this should be further improved as a check. 2) why bootstrap = F gives different error? confirm that some checks are not bypassed when bootstrap = F.

@bonifazi
Copy link
Owner Author

bonifazi commented Nov 19, 2024

This seems could work:

assert_that(identical(class(ebv.tmp)[1], "data.frame"),
            msg = "Input is not a pure data.frame (it might be a data.table or another structure).")

improve the error, return the class to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant