thierrygosselin / radiator

RADseq Data Exploration, Manipulation and Visualization using R
https://thierrygosselin.github.io/radiator/
GNU General Public License v3.0
58 stars 23 forks source link

genomic_converter function error Column 'POP_ID' doesn't exist #154

Closed kharrisson closed 1 year ago

kharrisson commented 2 years ago

Hi Thierry

I have used your radiator package in the past with no issues but I recently reinstalled R and reinstalled the package and am now having some issues with the genomic_converter function. When I try to convert a standard genind object to hierfstat format using the following I am getting the following errors.

genomic_converter(gi, output="hierfstat")

Error: Can't subset columns that don't exist.
x Column `POP_ID` doesn't exist.

rlang::last_error()
<error/vctrs_error_subscript_oob>
Can't subset columns that don't exist.
x Column `POP_ID` doesn't exist.
Backtrace:
  1. radiator::genomic_converter(gi, output = "hierfstat")
  2. radiator::write_hierfstat(data = input, filename = filename)
  6. dplyr:::select.data.frame(...)
  7. tidyselect::eval_select(expr(c(...)), .data)
  8. tidyselect:::eval_select_impl(...)
 16. tidyselect:::vars_select_eval(...)
 17. tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 18. tidyselect:::eval_c(expr, data_mask, context_mask)
 19. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 20. tidyselect:::walk_data_tree(new, data_mask, context_mask)
 21. tidyselect:::as_indices_sel_impl(...)
 22. tidyselect:::as_indices_impl(x, vars, strict = strict)
 23. tidyselect:::chr_as_locations(x, vars)
 24. vctrs::vec_as_location(x, n = length(vars), names = vars)
 26. vctrs:::stop_subscript_oob(...)
 27. vctrs:::stop_subscript(...)

rlang::last_trace()
<error/vctrs_error_subscript_oob>
Can't subset columns that don't exist.
x Column `POP_ID` doesn't exist.
Backtrace:
     █
  1. ├─radiator::genomic_converter(gi, output = "hierfstat")
  2. │ └─radiator::write_hierfstat(data = input, filename = filename)
  3. │   ├─`%>%`(...)
  4. │   ├─dplyr::select(.data = data, POP_ID, INDIVIDUALS, MARKERS, GT)
  5. │   └─dplyr:::select.data.frame(...)
  6. │     └─tidyselect::eval_select(expr(c(...)), .data)
  7. │       └─tidyselect:::eval_select_impl(...)
  8. │         ├─tidyselect:::with_subscript_errors(...)
  9. │         │ ├─base::tryCatch(...)
 10. │         │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
 11. │         │ │   └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 12. │         │ │     └─base:::doTryCatch(return(expr), name, parentenv, handler)
 13. │         │ └─tidyselect:::instrument_base_errors(expr)
 14. │         │   └─base::withCallingHandlers(...)
 15. │         └─tidyselect:::vars_select_eval(...)
 16. │           └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 17. │             └─tidyselect:::eval_c(expr, data_mask, context_mask)
 18. │               └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 19. │                 └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
 20. │                   └─tidyselect:::as_indices_sel_impl(...)
 21. │                     └─tidyselect:::as_indices_impl(x, vars, strict = strict)
 22. │                       └─tidyselect:::chr_as_locations(x, vars)
 23. │                         └─vctrs::vec_as_location(x, n = length(vars), names = vars)
 24. │                           └─(function () ...
 25. │                             └─vctrs:::stop_subscript_oob(...)
 26. │                               └─vctrs:::stop_subscript(...)
 27. └─dplyr::arrange(., MARKERS, POP_ID, INDIVIDUALS)

I was able to get the function working by copying the genomic_converter function and manually adding a POP_ID column here

  if ("hierfstat" %in% output) {
    if (verbose) 
      message("Generating hierfstat file")
    input$POP_ID <- input$STRATA
    res$hierfstat <- radiator::write_hierfstat(data = input, 
                                               filename = filename)
  }

Session info:

> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.1.1 (2021-08-10)
 os       macOS Big Sur 10.16         
 system   x86_64, darwin17.0          
 ui       RStudio                     
 language (EN)                        
 collate  en_AU.UTF-8                 
 ctype    en_AU.UTF-8                 
 tz       Australia/Melbourne         
 date     2022-03-11                  

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────
 package      * version   date       lib source                                    
 ade4         * 1.7-18    2021-09-16 [1] CRAN (R 4.1.0)                            
 adegenet     * 2.1.4     2021-07-17 [1] CRAN (R 4.1.0)                            
 ape            5.5       2021-04-25 [1] CRAN (R 4.1.0)                            
 bit            4.0.4     2020-08-04 [1] CRAN (R 4.1.0)                            
 bit64          4.0.5     2020-08-30 [1] CRAN (R 4.1.0)                            
 boot           1.3-28    2021-05-03 [1] CRAN (R 4.1.1)                            
 cachem         1.0.6     2021-08-19 [1] CRAN (R 4.1.0)                            
 calibrate      1.7.7     2020-06-19 [1] CRAN (R 4.1.0)                            
 callr          3.7.0     2021-04-20 [1] CRAN (R 4.1.0)                            
 carrier        0.1.0     2018-10-16 [1] CRAN (R 4.1.0)                            
 class          7.3-19    2021-05-03 [1] CRAN (R 4.1.1)                            
 classInt       0.4-3     2020-04-07 [1] CRAN (R 4.1.0)                            
 cli            3.0.1     2021-07-17 [1] CRAN (R 4.1.0)                            
 cluster        2.1.2     2021-04-17 [1] CRAN (R 4.1.1)                            
 coda           0.19-4    2020-09-30 [1] CRAN (R 4.1.0)                            
 codetools      0.2-18    2020-11-04 [1] CRAN (R 4.1.1)                            
 colorspace     2.0-2     2021-06-24 [1] CRAN (R 4.1.0)                            
 combinat       0.0-8     2012-10-29 [1] CRAN (R 4.1.0)                            
 crayon         1.4.1     2021-02-08 [1] CRAN (R 4.1.0)                            
 curl           4.3.2     2021-06-23 [1] CRAN (R 4.1.0)                            
 dartR        * 1.9.9.1   2022-02-06 [1] Github (green-striped-gecko/dartR@1e532cd)
 data.table     1.14.2    2021-09-27 [1] CRAN (R 4.1.0)                            
 DBI            1.1.1     2021-01-15 [1] CRAN (R 4.1.0)                            
 deldir         0.2-10    2021-02-16 [1] CRAN (R 4.1.0)                            
 DEoptimR       1.0-9     2021-05-24 [1] CRAN (R 4.1.0)                            
 desc           1.4.0     2021-09-28 [1] CRAN (R 4.1.0)                            
 devtools     * 2.4.2     2021-06-07 [1] CRAN (R 4.1.0)                            
 digest         0.6.28    2021-09-23 [1] CRAN (R 4.1.0)                            
 dismo          1.3-3     2020-11-17 [1] CRAN (R 4.1.0)                            
 doParallel     1.0.16    2020-10-16 [1] CRAN (R 4.1.0)                            
 dplyr        * 1.0.7     2021-06-18 [1] CRAN (R 4.1.0)                            
 e1071          1.7-9     2021-09-16 [1] CRAN (R 4.1.0)                            
 ellipsis       0.3.2     2021-04-29 [1] CRAN (R 4.1.0)                            
 expm           0.999-6   2021-01-13 [1] CRAN (R 4.1.0)                            
 fansi          0.5.0     2021-05-25 [1] CRAN (R 4.1.0)                            
 fastmap        1.1.0     2021-01-25 [1] CRAN (R 4.1.0)                            
 foreach        1.5.1     2020-10-15 [1] CRAN (R 4.1.0)                            
 fs             1.5.0     2020-07-31 [1] CRAN (R 4.1.0)                            
 fst            0.9.8     2022-02-08 [1] CRAN (R 4.1.2)                            
 fstcore      * 0.9.8     2022-02-04 [1] CRAN (R 4.1.2)                            
 gap            1.2.3-1   2021-04-21 [1] CRAN (R 4.1.0)                            
 gdata          2.18.0    2017-06-06 [1] CRAN (R 4.1.0)                            
 gdistance      1.3-6     2020-06-29 [1] CRAN (R 4.1.0)                            
 gdsfmt         1.28.1    2021-09-16 [1] Bioconductor                              
 generics       0.1.0     2020-10-31 [1] CRAN (R 4.1.0)                            
 genetics       1.3.8.1.3 2021-03-01 [1] CRAN (R 4.1.0)                            
 GGally         2.1.2     2021-06-21 [1] CRAN (R 4.1.0)                            
 ggplot2      * 3.3.5     2021-06-25 [1] CRAN (R 4.1.0)                            
 glue           1.4.2     2020-08-27 [1] CRAN (R 4.1.0)                            
 gmodels        2.18.1    2018-06-25 [1] CRAN (R 4.1.0)                            
 gridExtra      2.3       2017-09-09 [1] CRAN (R 4.1.0)                            
 gtable         0.3.0     2019-03-25 [1] CRAN (R 4.1.0)                            
 gtools         3.9.2     2021-06-06 [1] CRAN (R 4.1.0)                            
 hierfstat      0.5-7     2020-07-20 [1] CRAN (R 4.1.0)                            
 hms            1.1.1     2021-09-26 [1] CRAN (R 4.1.0)                            
 htmltools      0.5.2     2021-08-25 [1] CRAN (R 4.1.0)                            
 httpuv         1.6.3     2021-09-09 [1] CRAN (R 4.1.0)                            
 igraph         1.2.6     2020-10-06 [1] CRAN (R 4.1.0)                            
 iterators      1.0.13    2020-10-15 [1] CRAN (R 4.1.0)                            
 KernSmooth     2.23-20   2021-05-03 [1] CRAN (R 4.1.1)                            
 knitr          1.36      2021-09-29 [1] CRAN (R 4.1.0)                            
 later          1.3.0     2021-08-18 [1] CRAN (R 4.1.0)                            
 lattice        0.20-44   2021-05-02 [1] CRAN (R 4.1.1)                            
 LearnBayes     2.15.1    2018-03-18 [1] CRAN (R 4.1.0)                            
 lifecycle      1.0.1     2021-09-24 [1] CRAN (R 4.1.0)                            
 magrittr       2.0.1     2020-11-17 [1] CRAN (R 4.1.0)                            
 MASS           7.3-54    2021-05-03 [1] CRAN (R 4.1.1)                            
 Matrix         1.3-4     2021-06-01 [1] CRAN (R 4.1.1)                            
 memoise        2.0.0     2021-01-26 [1] CRAN (R 4.1.0)                            
 mgcv           1.8-36    2021-06-01 [1] CRAN (R 4.1.1)                            
 mime           0.12      2021-09-28 [1] CRAN (R 4.1.0)                            
 mmod           1.3.3     2017-04-06 [1] CRAN (R 4.1.0)                            
 munsell        0.5.0     2018-06-12 [1] CRAN (R 4.1.0)                            
 mvtnorm        1.1-2     2021-06-07 [1] CRAN (R 4.1.0)                            
 nlme           3.1-152   2021-02-04 [1] CRAN (R 4.1.1)                            
 pegas          1.0-1     2021-05-17 [1] CRAN (R 4.1.0)                            
 permute        0.9-5     2019-03-12 [1] CRAN (R 4.1.0)                            
 pillar         1.6.3     2021-09-26 [1] CRAN (R 4.1.0)                            
 pkgbuild       1.2.0     2020-12-15 [1] CRAN (R 4.1.0)                            
 pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.1.0)                            
 pkgload        1.2.2     2021-09-11 [1] CRAN (R 4.1.0)                            
 plyr         * 1.8.6     2020-03-03 [1] CRAN (R 4.1.0)                            
 png            0.1-7     2013-12-03 [1] CRAN (R 4.1.0)                            
 PopGenReport   3.0.4     2019-02-04 [1] CRAN (R 4.1.0)                            
 prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.1.0)                            
 processx       3.5.2     2021-04-30 [1] CRAN (R 4.1.0)                            
 promises       1.2.0.1   2021-02-11 [1] CRAN (R 4.1.0)                            
 proxy          0.4-26    2021-06-07 [1] CRAN (R 4.1.0)                            
 ps             1.6.0     2021-02-28 [1] CRAN (R 4.1.0)                            
 purrr          0.3.4     2020-04-17 [1] CRAN (R 4.1.0)                            
 R.methodsS3    1.8.1     2020-08-26 [1] CRAN (R 4.1.0)                            
 R.oo           1.24.0    2020-08-26 [1] CRAN (R 4.1.0)                            
 R.utils        2.11.0    2021-09-26 [1] CRAN (R 4.1.0)                            
 R6             2.5.1     2021-08-19 [1] CRAN (R 4.1.0)                            
 radiator     * 1.2.2     2022-03-11 [1] Github (thierrygosselin/radiator@6efdf14) 
 raster         3.4-13    2021-06-18 [1] CRAN (R 4.1.0)                            
 RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 4.1.0)                            
 Rcpp           1.0.7     2021-07-07 [1] CRAN (R 4.1.0)                            
 readr          2.1.2     2022-01-30 [1] CRAN (R 4.1.2)                            
 remotes        2.4.1     2021-09-29 [1] CRAN (R 4.1.0)                            
 reshape        0.8.8     2018-10-23 [1] CRAN (R 4.1.0)                            
 reshape2       1.4.4     2020-04-09 [1] CRAN (R 4.1.0)                            
 rgdal          1.5-27    2021-09-16 [1] CRAN (R 4.1.0)                            
 RgoogleMaps    1.4.5.3   2020-02-12 [1] CRAN (R 4.1.0)                            
 rlang          0.4.11    2021-04-30 [1] CRAN (R 4.1.0)                            
 robustbase     0.93-9    2021-09-27 [1] CRAN (R 4.1.0)                            
 rprojroot      2.0.2     2020-11-15 [1] CRAN (R 4.1.0)                            
 rstudioapi     0.13      2020-11-12 [1] CRAN (R 4.1.0)                            
 s2             1.0.7     2021-09-28 [1] CRAN (R 4.1.0)                            
 scales         1.1.1     2020-05-11 [1] CRAN (R 4.1.0)                            
 seqinr         4.2-8     2021-06-09 [1] CRAN (R 4.1.0)                            
 sessioninfo    1.1.1     2018-11-05 [1] CRAN (R 4.1.0)                            
 sf             1.0-2     2021-07-26 [1] CRAN (R 4.1.0)                            
 shiny          1.7.1     2021-10-02 [1] CRAN (R 4.1.0)                            
 SNPRelate      1.26.0    2021-05-19 [1] Bioconductor                              
 sp             1.4-5     2021-01-10 [1] CRAN (R 4.1.0)                            
 spData         0.3.10    2021-06-18 [1] CRAN (R 4.1.0)                            
 spdep          1.1-11    2021-09-07 [1] CRAN (R 4.1.0)                            
 StAMPP         1.6.3     2021-08-08 [1] CRAN (R 4.1.0)                            
 stringi        1.7.4     2021-08-25 [1] CRAN (R 4.1.0)                            
 stringr      * 1.4.0     2019-02-10 [1] CRAN (R 4.1.0)                            
 testthat       3.1.0     2021-10-04 [1] CRAN (R 4.1.0)                            
 tibble         3.1.5     2021-09-30 [1] CRAN (R 4.1.0)                            
 tidyr          1.1.4     2021-09-27 [1] CRAN (R 4.1.0)                            
 tidyselect     1.1.1     2021-04-30 [1] CRAN (R 4.1.0)                            
 tzdb           0.2.0     2021-10-27 [1] CRAN (R 4.1.0)                            
 units          0.7-2     2021-06-08 [1] CRAN (R 4.1.0)                            
 usethis      * 2.0.1     2021-02-10 [1] CRAN (R 4.1.0)                            
 utf8           1.2.2     2021-07-24 [1] CRAN (R 4.1.0)                            
 vctrs          0.3.8     2021-04-29 [1] CRAN (R 4.1.0)                            
 vegan          2.5-7     2020-11-28 [1] CRAN (R 4.1.0)                            
 vroom          1.5.7     2021-11-30 [1] CRAN (R 4.1.0)                            
 withr          2.4.2     2021-04-18 [1] CRAN (R 4.1.0)                            
 wk             0.5.0     2021-07-13 [1] CRAN (R 4.1.0)                            
 xfun           0.26      2021-09-14 [1] CRAN (R 4.1.0)                            
 xtable         1.8-4     2019-04-21 [1] CRAN (R 4.1.0)                            
 yaml           2.2.1     2020-02-01 [1] CRAN (R 4.1.0)                            

[1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
thierrygosselin commented 2 years ago

Thanks I'll have a look today

thierrygosselin commented 1 year ago

no need to do that, the new version should work. Re-open the issue following guidelines if you're still experiencing problems with radiator

thanks