jean997 / cause

R package for CAUSE
https://jean997.github.io/cause/
52 stars 15 forks source link

DLL requires the use of native symbols #37

Closed Evaporater closed 1 year ago

Evaporater commented 1 year ago

when i run cause function, it returns following error:

Estimating CAUSE posteriors using  1957  variants.
Fitting confounder only model.
Setting ranges
Refining grid
Error in `map()`:
ℹ In index: 1.
Caused by error in `.local()`:
! DLL requires the use of native symbols

how can i fix it? thank you.

>sessioninfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 
[2] LC_CTYPE=Chinese (Simplified)_China.utf8   
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                               
[5] LC_TIME=Chinese (Simplified)_China.utf8    

time zone: Asia/Shanghai
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] cause_1.2.0.0335

loaded via a namespace (and not attached):
 [1] gtable_0.3.0       ggplot2_3.4.1      htmlwidgets_1.5.4  devtools_2.4.4    
 [5] remotes_2.4.2      processx_3.7.0     lattice_0.21-8     callr_3.7.3       
 [9] tzdb_0.3.0         vctrs_0.6.0        tools_4.3.0        ps_1.7.1          
[13] generics_0.1.3     parallel_4.3.0     tibble_3.2.1       fansi_1.0.3       
[17] pkgconfig_2.0.3    Matrix_1.5-4       SQUAREM_2021.1     RcppParallel_5.1.7
[21] lifecycle_1.0.3    truncnorm_1.0-8    compiler_4.3.0     stringr_1.5.0     
[25] munsell_0.5.0      httpuv_1.6.5       htmltools_0.5.2    usethis_2.1.6     
[29] later_1.3.0        pillar_1.9.0       crayon_1.5.1       urlchecker_1.0.1  
[33] tidyr_1.3.0        ellipsis_0.3.2     cachem_1.0.6       sessioninfo_1.2.2 
[37] mime_0.12          tidyselect_1.2.0   digest_0.6.29      stringi_1.7.6     
[41] dplyr_1.1.0        purrr_1.0.1        ashr_2.2-54        fastmap_1.1.0     
[45] grid_4.3.0         colorspace_2.0-3   cli_3.6.0          invgamma_1.1      
[49] magrittr_2.0.3     loo_2.5.1          pkgbuild_1.3.1     utf8_1.2.2        
[53] withr_2.5.0        readr_2.1.4        prettyunits_1.1.1  scales_1.2.0      
[57] promises_1.2.0.1   bit64_4.0.5        matrixStats_0.62.0 bit_4.0.4         
[61] gridExtra_2.3      hms_1.1.3          memoise_2.0.1      shiny_1.7.2       
[65] irlba_2.3.5        miniUI_0.1.1.1     profvis_0.3.7      rlang_1.1.0       
[69] Rcpp_1.0.10        mixsqp_0.3-43      xtable_1.8-4       glue_1.6.2        
[73] pkgload_1.3.0      rstudioapi_0.14    vroom_1.6.1        ieugwasr_0.1.5    
[77] R6_2.5.1           intervals_0.15.2   fs_1.5.2 
jean997 commented 1 year ago

Hi - I've never seen this issue before. Do you have a small dataset and example that reproduces the error?

Evaporater commented 1 year ago

i am sorry that i don't know how to share my data directly to you via github, so i upload it to dropbox, the url is https://www.dropbox.com/s/57nq6eodq2g024q/test.RData?dl=0 , i hope it works.

this data is generated following your tutorial on https://jean997.github.io/cause/ldl_cad.html#Step_1:_Format_Data_for_CAUSE .

you can reproduce my analysis using following code:

>load(test.RData)
>cause::cause(X=X, variants = top_vars, param_ests = params)

in my case, it returns:

Estimating CAUSE posteriors using  726  variants.
Fitting confounder only model.
Setting ranges
Refining grid
Error in `map()`:
ℹ In index: 1.
Caused by error in `.local()`:
! DLL requires the use of native symbols

further run rlang::last_trace(drop = FALSE) , it returns:

<error/purrr_error_indexed>
Error in `map()`:
ℹ In index: 1.
Caused by error in `.local()`:
! DLL requires the use of native symbols
---
Backtrace:
     ▆
  1. ├─cause::cause(X = X, variants = top_vars, param_ests = params)
  2. │ └─cause::cause_grid_adapt(...)
  3. │   └─cause:::adapt2_grid(...)
  4. │     ├─base::unique(unlist(get_neighbors(ix, res, params)))
  5. │     ├─base::unlist(get_neighbors(ix, res, params))
  6. │     └─cause:::get_neighbors(ix, res, params)
  7. │       ├─... %>% ...
  8. │       └─purrr::map(...)
  9. │         └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 10. │           ├─purrr:::with_indexed_errors(...)
 11. │           │ └─base::withCallingHandlers(...)
 12. │           ├─purrr:::call_with_cleanup(...)
 13. │           └─cause (local) .f(.x[[i]], ...)
 14. │             ├─intervals::interval_overlap(x[ix, ], x)
 15. │             └─intervals::interval_overlap(x[ix, ], x)
 16. │               └─intervals (local) .local(from, to, ...)
 17. │                 ├─intervals::which_nearest(from, to, check_valid)
 18. │                 └─intervals::which_nearest(from, to, check_valid)
 19. │                   └─intervals (local) .local(from, to, ...)
 20. ├─purrr::map(...)
 21. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 22. │   └─purrr:::vctrs_vec_compat(.x, .purrr_user_env)
 23. ├─purrr::transpose(.)
 24. └─base::.handleSimpleError(...)
 25.   └─purrr (local) h(simpleError(msg, call))
 26.     └─cli::cli_abort(...)
 27.       └─rlang::abort(...)

it seems that the problem comes from purrr package, but i don't know how to fix it... hope you can give me some tips, thank you

jean997 commented 1 year ago

I have tried to replicate your error on two different computers and three different versions of R (including 4.3.0) but failed. It always runs fine for me. The only thing I can think of is that you have

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 
[2] LC_CTYPE=Chinese (Simplified)_China.utf8   
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                               
[5] LC_TIME=Chinese (Simplified)_China.utf8    

in your session info. It is possible that this is related to the issue. I haven't been able to test this (haven't figured out how to set my locale variables to Chinese). Perhaps you could try setting yours to English and see if that solves the issue?

Evaporater commented 1 year ago

Well, I don't think it's a language problem because it works fine on my colleague's computer. I tried to reinstall the cause package but the problem still existed, so I reinstalled R and installed only the cause package and the problem was solved, so I guess I might have lost something when I upgraded R or there was a conflict between one of the previous packages and cause. Anyway, thanks for your reply!

jean997 commented 1 year ago

Ok! Glad it is solved but sorry we couldn't figure out exactly the source of the issue. If you encounter it again feel free to reopen this issue.