mikemc / speedyseq

Speedy versions of phyloseq functions
https://mikemc.github.io/speedyseq/
Other
45 stars 6 forks source link

Case where `merge_samples2()` fails on creating new sample data #71

Open mikemc opened 3 years ago

mikemc commented 3 years ago
grp <- ps.s %>% sample_data %>% ps_tibble %>% 
  # transmute(specimen_id:extraction_protocol:center_id) %>%
  transmute(specimen_id:extraction_protocol:center_id) %>%
  pull(1)
merge_samples2(ps.s, grp)
#> Error: Can't combine `1:1:S1` <date> and `25:1:S1` <double>.
#> Run `rlang::last_error()` to see where the error occurred.

The error is occurring in the call to merge_groups() and the error suggests it has to do with the date columns

mikemc commented 3 years ago

Here is a minimal reproducible example of the bug

group <- c(1,1,2,2,3,3)
dates <- c(NA, NA, "2020-01-01", "2020-01-01", "2020-01-02", "2020-01-03") %>%
  lubridate::as_date()
speedyseq:::merge_groups(
  dates,
  group,
  unique_or_na
)
#> Error: Can't combine `1` <date> and `3` <double>.
#> Run `rlang::last_error()` to see where the error occurred.
mikemc commented 3 years ago

Strangely, this only seems to create an error in merge_samples2() when group is a vector rather than the name of a column in the sample data