saezlab / decoupleR

R package to infer biological activities from omics data using a collection of methods.
https://saezlab.github.io/decoupleR/
GNU General Public License v3.0
183 stars 24 forks source link

Error: Column `condition` not found in `.data` #48

Closed charlotteboys closed 2 years ago

charlotteboys commented 2 years ago

This error occurs for me with run_mlm and run_ulm but it doesn't affect other functions such as run_wmean.

Minimum reproducible example:

library(decoupleR)

minimal_matrix <- data.frame("Gene" = c("gene1", "gene2"), 
                             "t" = c(3, -3)) %>% 
  tibble::column_to_rownames("Gene") %>% 
  as.matrix() 

minimal_network <- data.frame("source" = c("TF1"), 
                              "target" = c("gene1", "gene2"),
                              "mor" = c(1, -1),
                              "likelihood" = c(10, 10))

decoupleR::run_mlm(mat = minimal_matrix,
                   network = minimal_network)

rlang::last_trace() gives:

<error/rlang_error_data_pronoun_not_found>
Column `condition` not found in `.data`
Backtrace:
     █
  1. ├─decoupleR::run_mlm(mat = minimal_matrix, network = minimal_network)
  2. │ └─`%>%`(...)
  3. ├─decoupleR:::.mlm_analysis(.$mat, .$mor_mat)
  4. │ └─`%>%`(...)
  5. ├─dplyr::select(...)
  6. ├─tidyr::unnest(., .data$model)
  7. ├─dplyr::mutate(...)
  8. ├─dplyr::rowwise(., .data$condition)
  9. ├─dplyr:::rowwise.data.frame(., .data$condition)
 10. │ └─tidyselect::eval_select(expr(c(...)), data)
 11. │   └─tidyselect:::eval_select_impl(...)
 12. │     ├─tidyselect:::with_subscript_errors(...)
 13. │     │ ├─base::tryCatch(...)
 14. │     │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
 15. │     │ │   └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 16. │     │ │     └─base:::doTryCatch(return(expr), name, parentenv, handler)
 17. │     │ └─tidyselect:::instrument_base_errors(expr)
 18. │     │   └─base::withCallingHandlers(...)
 19. │     └─tidyselect:::vars_select_eval(...)
 20. │       └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 21. │         └─tidyselect:::eval_c(expr, data_mask, context_mask)
 22. │           └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 23. │             └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
 24. │               └─base::eval(expr, data_mask)
 25. │                 └─base::eval(expr, data_mask)
 26. │                   ├─condition
 27. │                   └─rlang:::`$.rlang_data_pronoun`(.data, condition)
 28. │                     └─rlang:::data_pronoun_get(x, nm)
 29. └─rlang:::abort_data_pronoun(x)

Session Info:

R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] decoupleR_2.0.0 edgeR_3.36.0    limma_3.50.0   

loaded via a namespace (and not attached):
 [1] ggrepel_0.9.1               Rcpp_1.0.8                  locfit_1.5-9.4              lattice_0.20-45            
 [5] tidyr_1.1.4                 digest_0.6.29               assertthat_0.2.1            utf8_1.2.2                 
 [9] R6_2.5.1                    ranger_0.13.1               GenomeInfoDb_1.30.0         stats4_4.1.2               
[13] evaluate_0.14               progeny_1.16.0              ggplot2_3.3.5               pillar_1.6.4               
[17] zlibbioc_1.40.0             rlang_0.4.12                rstudioapi_0.13             S4Vectors_0.32.3           
[21] rpart_4.1-15                Matrix_1.4-0                rmarkdown_2.11              stringr_1.4.0              
[25] RCurl_1.98-1.5              munsell_0.5.0               DelayedArray_0.20.0         compiler_4.1.2             
[29] xfun_0.29                   pkgconfig_2.0.3             BiocGenerics_0.40.0         speedglm_0.3-3             
[33] htmltools_0.5.2             tidyselect_1.1.1            SummarizedExperiment_1.24.0 tibble_3.1.6               
[37] gridExtra_2.3               GenomeInfoDbData_1.2.7      IRanges_2.28.0              matrixStats_0.61.0         
[41] fansi_1.0.0                 crayon_1.4.2                dplyr_1.0.7                 MASS_7.3-55                
[45] bitops_1.0-7                RobustRankAggreg_1.1        grid_4.1.2                  gtable_0.3.0               
[49] lifecycle_1.0.1             DBI_1.1.2                   magrittr_2.0.1              scales_1.1.1               
[53] stringi_1.7.6               XVector_0.34.0              ellipsis_0.3.2              generics_0.1.1             
[57] vctrs_0.3.8                 tools_4.1.2                 Biobase_2.54.0              glue_1.6.0                 
[61] purrr_0.3.4                 MatrixGenerics_1.6.0        yaml_2.2.1                  fastmap_1.1.0              
[65] colorspace_2.0-2            BiocManager_1.30.16         GenomicRanges_1.46.1        knitr_1.37 
PauBadiaM commented 2 years ago

Hi @charlotteboys, thanks for posting the error. Yes, this was a known bug in version 2.0.0 of decoupleR, by updating to the current version of decoupleR it will work fine. First run:

devtools::install_github('saezlab/decoupleR')

Then by running this:

library(decoupleR)

minimal_matrix <- data.frame("Gene" = c("gene1", "gene2", "gene3"), 
                             "t" = c(3, -3, 1)) %>% 
  tibble::column_to_rownames("Gene") %>% 
  as.matrix()

minimal_network <- data.frame("source" = c("TF1"), 
                              "target" = c("gene1", "gene2"),
                              "mor" = c(1, -1),
                              "likelihood" = c(10, 10))
decoupleR::run_ulm(mat = minimal_matrix, network = minimal_network, minsize=0)

You should get this:

# A tibble: 1 × 5
  statistic source condition score p_value
  <chr>     <chr>  <chr>     <dbl>   <dbl>
1 mlm       TF1    t          5.20   0.121

I modified the example (basically added one more gene) so that it would return a valid output. Please let me know if this solves the issue or if you run with any more problems.

charlotteboys commented 2 years ago

Thank you Pau, I forced a reinstallation devtools::install_github('saezlab/decoupleR', force = TRUE), and restarted my R session and everything is working!