gilesjohnr / WES

WES: an R package providing methods for analyzing Wastewater and Environmental Sampling (WES) data.
https://www.r-wes.com
Creative Commons Attribution 4.0 International
0 stars 0 forks source link

apply_delta_delta_ct should not use dcast(fun.aggregate=identity) #1

Open tdhock opened 4 months ago

tdhock commented 4 months ago

Hi @gilesjohnr After installing data.table from github master,

data.table::update_dev_pkg()

And then running R CMD check on WES, I get the following new failure, (which is not present if you use data.table from CRAN)

* checking examples ... ERROR
Running examples in 'WES-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: apply_delta_delta_ct
> ### Title: Apply the delta delta Ct calculation to a data.frame
> ### Aliases: apply_delta_delta_ct
> 
> ### ** Examples
> 
> 
> pae <- apply_amplification_efficiency(template_WES_standard_curve)
> 
> ddct_standard <- apply_delta_delta_ct(df = template_WES_data,
+                                       target_names = c('target_1', 'target_2', 'target_3'),
+                                       reference_names = rep('target_0', 3))
Error in maybe_err(eval(fun.call)) : 
  Aggregating function(s) should take vector inputs and return a single value (length=1). However, function(s) returns length!=1. This value will have to be used to fill any missing combinations, and therefore must be length=1. Either override by setting the 'fill' argument explicitly or modify your function to handle this case appropriately.
Calls: apply_delta_delta_ct ... [.data.table -> maybe_err -> stopf -> raise_condition -> signal
Execution halted

data.table needs to ensure that updates do not break dependent packages like WES, before uploading new versions to CRAN, so can you please submit an updated version of WES to CRAN, that fixes this test failure? In particular, you need to avoid using fun.aggregate=identity in dcast https://github.com/gilesjohnr/WES/blob/f5b19ce671f804f97e4eac7415217583ee2cbf38/R/apply_delta_delta_ct.R#L81 this is documented in ?dcast:

     The aggregating function should take a vector as input and return
     a single value (or a list of length one) as output. In cases where
     ‘value.var’ is a list, the function should be able to handle a
     list input and provide a single value or list of length one as
     output.
tdhock commented 4 months ago

This is a part of https://github.com/Rdatatable/data.table/issues/6032 We plan to release this code to CRAN in Aug 2024, so please try to fix in your next CRAN submission.