guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

metagen/tidyverse interaction #11

Closed konradjk closed 5 years ago

konradjk commented 5 years ago

Hello!

Not sure if this is the right place for this since it seems to be an interaction between metagen and a newer version of some tidyverse packages, but I've got a code snippet that runs metagen on groups of a data frame.

  enrichment_data = sum_stats %>%
    filter(cond == 'all100' &
             grepl('oe_lof_upper_quantile_', name) &
             (is.na(cor_rm0.2) | cor_rm0.2 == 0)  # Select uncorrelated variables
           ) %>%
    group_by(name) %>%
    summarize(meta_enrichment = metagen(enrichment, enrichment_SE)$TE.random,
              meta_sd = metagen(enrichment, enrichment_SE)$seTE.random)

This worked previously with dplyr 0.7.8 and tidyr 0.8.2, but some recent updates of those packages has broken this workflow (see error below). No worries from my end, as I can just fix to an older version as the project is mostly done. But thought you might want to know!

 Error in eval(mf[[match("TE", names(mf))]], data, enclos = sys.frame(sys.parent())) : 
  object 'enrichment' not found 
16.
eval(mf[[match("TE", names(mf))]], data, enclos = sys.frame(sys.parent())) 
15.
eval(mf[[match("TE", names(mf))]], data, enclos = sys.frame(sys.parent())) 
14.
metagen(enrichment, enrichment_SE) 
13.
summarise_impl(.data, dots, environment(), caller_env()) 
12.
summarise.tbl_df(.data, ...) 
11.
fun(.data, ...) 
10.
log_summarize(.data, dplyr::summarize, "summarize", ...) 
9.
summarize(., meta_enrichment = metagen(enrichment, enrichment_SE)$TE.random, 
    meta_sd = metagen(enrichment, enrichment_SE)$seTE.random) 
8.
function_list[[i]](value) 
7.
freduce(value, `_function_list`) 
6.
`_fseq`(`_lhs`) 
5.
eval(quote(`_fseq`(`_lhs`)), env, env) 
4.
eval(quote(`_fseq`(`_lhs`)), env, env) 
3.
withVisible(eval(quote(`_fseq`(`_lhs`)), env, env)) 
2.
sum_stats %>% filter(cond == "all100" & grepl("oe_lof_upper_quantile_", 
    name) & (is.na(cor_rm0.2) | cor_rm0.2 == 0)) %>% group_by(name) %>% 
    summarize(meta_enrichment = metagen(enrichment, enrichment_SE)$TE.random, 
        meta_sd = metagen(enrichment, enrichment_SE)$seTE.random) %>%  ... at fig5_disease.R#252
1.
partitioning_heritability_enrichment(T) 

Environment:

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin18.2.0 (64-bit)
Running under: macOS  10.14.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /opt/local/Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] crayon_1.3.4         tidylog_0.1.0        cowplot_0.9.4        RMySQL_0.10.17      
 [5] DBI_1.0.0            ggrepel_0.8.0        pbapply_1.4-0        rlang_0.3.4         
 [9] tidygraph_1.1.2      STRINGdb_1.22.0      meta_4.9-5           ggrastr_0.1.7       
[13] ggpubr_0.2           ggridges_0.5.1       readxl_1.3.1         corrr_0.3.2         
[17] corrplot_0.84        patchwork_0.0.1      naniar_0.4.2         plotROC_2.2.1       
[21] gghighlight_0.1.0    skimr_1.0.5          gapminder_0.3.0      trelliscopejs_0.1.18
[25] scales_1.0.0         magrittr_1.5         slackr_1.4.2         plotly_4.9.0        
[29] broom_0.5.2          forcats_0.4.0        stringr_1.4.0        dplyr_0.8.0.1       
[33] purrr_0.3.2          readr_1.3.1          tidyr_0.8.3          tibble_2.1.1        
[37] tidyverse_1.2.1      Hmisc_4.2-0          ggplot2_3.1.1        Formula_1.2-3       
[41] survival_2.44-1.1    lattice_0.20-38     

loaded via a namespace (and not attached):
 [1] colorspace_1.4-1        visdat_0.5.3            mclust_5.4.3            htmlTable_1.13.1       
 [5] base64enc_0.1-3         rstudioapi_0.10         hash_2.2.6.1            bit64_0.9-7            
 [9] lubridate_1.7.4         sqldf_0.4-11            xml2_1.2.0              splines_3.5.1          
[13] knitr_1.22              jsonlite_1.6            cluster_2.0.7-1         png_0.1-7              
[17] compiler_3.5.1          httr_1.4.0              backports_1.1.4         assertthat_0.2.1       
[21] Matrix_1.2-17           lazyeval_0.2.2          cli_1.1.0               acepack_1.4.1          
[25] htmltools_0.3.6         prettyunits_1.0.2       tools_3.5.1             igraph_1.2.4.1         
[29] gtable_0.3.0            glue_1.3.1              Rcpp_1.0.1              cellranger_1.1.0       
[33] gdata_2.18.0            nlme_3.1-137            autocogs_0.1.2          xfun_0.6               
[37] proto_1.0.0             rvest_0.3.3             gtools_3.8.1            DistributionUtils_0.6-0
[41] hms_0.4.2               parallel_3.5.1          metafor_2.0-0           RColorBrewer_1.1-2     
[45] yaml_2.2.0              memoise_1.1.0           gridExtra_2.3           rpart_4.1-13           
[49] latticeExtra_0.6-28     stringi_1.4.3           RSQLite_2.1.1           plotrix_3.7-5          
[53] checkmate_1.9.1         caTools_1.17.1.2        chron_2.3-53            pkgconfig_2.0.2        
[57] bitops_1.0-6            htmlwidgets_1.3         bit_1.1-14              tidyselect_0.2.5       
[61] plyr_1.8.4              R6_2.4.0                gplots_3.0.1.1          generics_0.0.2         
[65] gsubfn_0.7              pillar_1.3.1            haven_2.1.0             foreign_0.8-71         
[69] withr_2.1.2             RCurl_1.95-4.12         nnet_7.3-12             modelr_0.1.4           
[73] KernSmooth_2.23-15      progress_1.2.0          data.table_1.12.2       blob_1.1.1             
[77] digest_0.6.18           webshot_0.5.1           munsell_0.5.0           viridisLite_0.3.0   
guido-s commented 5 years ago

I am sorry, however, I do not see how to give any advice on this problem. All I can say is that the code in metagen() producing the error has not been changed since meta, version 3.0-0 which was published more than 5 years ago.