NBS error

400 views
Skip to first unread message

Danella Hafeman

unread,
Mar 29, 2021, 1:40:08 PM3/29/21
to brainGraph-help
Hi,

I am brand new to this package, but I have run NBS in matlab before, and I run most analyses in R now (thus trying to do this in R as well!). I am attempting to run NBS using the following code:

con.mat <- cbind(0, 0, 0, c(-2, 2))
rownames(con.mat) <- c('post > pre', 'pre > post')
res.nbs <- NBS(conn_array, covars, con.mat,
 p.init=0.001, N=100, alternative='greater', long=TRUE)

When I set the threshold to p=.001, I do not have any significant results, and the function runs without problem (this is a small sample). When I run summary (res.nbs), I get the following error:

Error in { : task 1 failed - "object 'NA' not found"

However,  when I change the p.init threshold to be less strict (i.e. p.init =.01), and run the above code, I get the following error:

Error in apply(x, 3L, qr.default, ...) : 'MARGIN' does not match dim(X)

Also, after running this code, I can no longer run other, unrelated code (e.g. lmer) without  getting the same error message. Instead, I need to restart R. And then I can run the other, unrelated code again without any problems. I have been trying to debug this, but cannot figure out where to start. Any ideas? Thanks in advance!

Best,
Danella

Chris Watson

unread,
Mar 29, 2021, 2:03:17 PM3/29/21
to brainGr...@googlegroups.com
I don't know without more details. Please share the output of `sessionInfo()`. To really debug it, I would need *all* the data to reproduce the issue. So you could send an ".rda" file w/ all the data, and a ".R" script with your code. You may do so off-list if you prefer.

I have no idea why unrelated code would no longer work, unless a function in `brainGraph` is overriding functions from another package. It appears to me that there are no conflicting function names with `'lme4` (which I assume you are using).

Chris

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/956bb47f-9898-4498-98ad-b9aab082e0e7n%40googlegroups.com.

Danella Hafeman

unread,
Mar 29, 2021, 2:09:23 PM3/29/21
to brainGraph-help
Thanks for your quick response. Here is the output from sessionInfo(). Any red flags? And yes, I am using lme4 for the lmer code. It is very strange. Please let me know what email address I should send the rda file to. Thanks!

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] stringi_1.5.3     nlme_3.1-151      NBR_0.1.3         data.table_1.14.0 permute_0.9-5     MASS_7.3-53       lattice_0.20-41   doParallel_1.0.16 iterators_1.0.12  foreach_1.5.0     abind_1.4-5       brainGraph_3.0.0 
[13] igraph_1.2.5      gimme_0.7-4       psycho_0.5.0      rio_0.5.16        corrplot_0.84     DescTools_0.99.36 readxl_1.3.1      forcats_0.5.0     stringr_1.4.0     dplyr_1.0.0       purrr_0.3.4       readr_1.3.1      
[25] tidyr_1.1.0       tibble_3.0.1      ggplot2_3.3.2     tidyverse_1.3.0   lmerTest_3.1-3    lme4_1.1-26       Matrix_1.2-18    

loaded via a namespace (and not attached):
  [1] backports_1.1.8      Hmisc_4.4-2          BDgraph_2.62         plyr_1.8.6           imputeTS_3.1         splines_4.0.3        inline_0.3.17        digest_0.6.25        htmltools_0.5.0      fansi_0.4.1         
 [11] magrittr_1.5         checkmate_2.0.0      cluster_2.1.0        openxlsx_4.1.5       modelr_0.1.8         matrixStats_0.57.0   RcppParallel_5.0.2   xts_0.12.1           prettyunits_1.1.1    forecast_8.13       
 [21] tseries_0.10-48      jpeg_0.1-8.1         colorspace_1.4-1     blob_1.2.1           rvest_0.3.5          haven_2.3.1          xfun_0.15            callr_3.4.3          crayon_1.3.4         jsonlite_1.7.0      
 [31] survival_3.2-3       zoo_1.8-8            glue_1.4.1           gtable_0.3.0         V8_3.4.0             pkgbuild_1.0.8       rstan_2.21.2         quantmod_0.4.18      scales_1.1.1         stinepack_1.4       
 [41] mvtnorm_1.1-1        DBI_1.1.0            data.tree_1.0.0      Rcpp_1.0.4.6         gridtext_0.1.3       htmlTable_2.0.0      tmvnsim_1.0-2        foreign_0.8-79       Formula_1.2-3        StanHeaders_2.21.0-7
 [51] stats4_4.0.3         htmlwidgets_1.5.1    httr_1.4.1           RColorBrewer_1.1-2   lavaan_0.6-6         ellipsis_0.3.1       loo_2.4.1            pkgconfig_2.0.3      nnet_7.3-14          dbplyr_1.4.4        
 [61] tidyselect_1.1.0     rlang_0.4.6          reshape2_1.4.4       munsell_0.5.0        cellranger_1.1.0     tools_4.0.3          cli_2.0.2            generics_0.0.2       broom_0.5.6          fdrtool_1.2.15      
 [71] processx_3.4.2       knitr_1.29           fs_1.4.1             zip_2.0.4            glasso_1.11          pbapply_1.4-2        whisker_0.4          xml2_1.3.2           compiler_4.0.3       rstudioapi_0.11     
 [81] curl_4.3             png_0.1-7            reprex_0.3.0         huge_1.3.4.1         statmod_1.4.34       pbivnorm_0.6.0       ps_1.3.3             qgraph_1.6.5         psych_1.9.12.31      nloptr_1.2.2.1      
 [91] MIIVsem_0.5.5        urca_1.3-0           vctrs_0.3.1          pillar_1.4.4         lifecycle_0.2.0      lmtest_0.9-38        corpcor_1.6.9        R6_2.4.1             latticeExtra_0.6-29  gridExtra_2.3       
[101] codetools_0.2-16     boot_1.3-25          gtools_3.8.2         assertthat_0.2.1     rjson_0.2.20         withr_2.2.0          fracdiff_1.5-1       mnormt_2.0.0         expm_0.999-4         hms_0.5.3           
[111] ggtext_0.1.0         quadprog_1.5-8       rpart_4.1-15         timeDate_3043.102    minqa_1.2.4          d3Network_0.5.2.1    TTR_0.24.2           numDeriv_2016.8-1.1  lubridate_1.7.9      base64enc_0.1-3     

Chris Watson

unread,
Mar 29, 2021, 2:12:27 PM3/29/21
to brainGr...@googlegroups.com
You have a lot of packages loaded so I would try just loading `brainGraph` and then running the code. I am not sure it will fix anything but it's worth a shot.

You can send the data/code to cgwa...@bu.edu

Chris Watson

unread,
Mar 31, 2021, 5:54:44 PM3/31/21
to brainGr...@googlegroups.com
I ran your code without error (even w/ `p.init=0.01`). However, I do see the error when running `summary`. This is due to the absence of the `atlas` element since you are using an atlas that is not part of the package.

While I am not sure why you get an error when running `NBS` itself, if you get it to run, after you can do

res.nbs$atlas <- 'schaefer_xyz'

or whatever the name of the atlas data.table is. It should be in the global environment.
Unfortunately I don't know if this will work; I see that the way I wrote the code makes it difficult to do so. You would have to then edit the `guess_atlas` function. I can try to make a bugfix update so that the line of code above is sufficient, maybe in the next week or so.

RE `NBS` throwing an error: One thing you can try is to *not* load `tidyverse`; I believe a lot of packages get loaded and don't know if there is a strange interaction when doing so.

Chris

Danella Hafeman

unread,
Apr 2, 2021, 9:22:01 AM4/2/21
to brainGraph-help
Re: tidyverse and NBS. I reran the code without loading tidyverse (only having NBS and data.table packages loaded) and I still have the same error. I think it must be something about the version of R (4.0.3) that I am running and/or my linux environment. In any case, while my ultimate goal is to break free from Matlab, I have converted the array to a .mat file and will use the Matlab NBS for the time being. I will continue to follow this thread, so if anyone figures this out, I can try again at a later date! Thanks for your help with this.

Chris Watson

unread,
Apr 2, 2021, 9:46:26 AM4/2/21
to brainGr...@googlegroups.com
After you get the "MARGIN does not match dim(X)" error, what is the output of `traceback()`? Unfortunately I can't do much unless I can reproduce it on my system (which it seems I can't) or can track down *where* the error occurs.

Chris

Reply all
Reply to author
Forward
0 new messages