Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with annotation database connection *only* in RStudio #9219

Closed
4 tasks done
levin252 opened this issue Apr 12, 2021 · 13 comments
Closed
4 tasks done

Issue with annotation database connection *only* in RStudio #9219

levin252 opened this issue Apr 12, 2021 · 13 comments
Assignees
Labels

Comments

@levin252
Copy link

System details

RStudio Edition :  Desktop
RStudio Version :  1.4.1106
OS Version      :  Kubuntu 20.04
R Version       :  4.0.5

Steps to reproduce the problem

Open RStudio Desktop, enter 'library(org.Hs.eg.db)' or any other 'org...db' (this happens for 'org.Hs.eg.db', 'org.Mm.eg.db' and 'org.Dm.eg.db' for me). It's not an issue with R because when I run R in terminal or VSCode this issue never happens and everything works perfectly.

Describe the problem in detail

So when I try to load an 'org.' annotation library/db, it loads all required packages, but when it gets to the 'org.' package, it gives an error message. Here is example code with the error:

> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] 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] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5   
> library(org.Hs.eg.db)
Loading required package: AnnotationDbi
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport, clusterMap, parApply,
    parCapply, parLapply, parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval,
    evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order,
    paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort,
    table, tapply, union, unique, unsplit, which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: IRanges
Loading required package: S4Vectors

Attaching package: ‘S4Vectors’

The following object is masked from ‘package:base’:

    expand.grid

Error: package or namespace load failed for ‘org.Hs.eg.db’:
 .onLoad failed in loadNamespace() for 'org.Hs.eg.db', details:
  call: l$contains
  error: $ operator is invalid for atomic vectors
>

I have uninstalled RStudio and all configuration directories/files, and reinstalled, and this error persists. I have restarted my computer. It has rendered using this package while in RStudio impossible. However, everything works fine in R or another program (VSCode) running R.

Another error message that may also be related- when I load other databases (some others such as 'GO.db' still seem to work), I get a warning message:

>library(GO.db)

Warning message:
call dbDisconnect() when finished working with a connection 

I am doing a fairly complex bit of code in RMD and recently RStudio crashed while working on this. I'm not sure, but it's possible it crashed while communicating with a database and somehow that connection is persisting and can't be closed in the IDE. But I can't figure out why uninstalling RStudio and configuration (as well as restarting my computer) doesn't remove this?

Describe the behavior you expected

Upon "library(org.Hs.eg.db)" the library loads and there is no error thrown.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
@levin252 levin252 changed the title Issue with annotation database connection persisting and throws error/unusable *only* in RStudio Issue with annotation database connection *only* in RStudio Apr 13, 2021
@sigven
Copy link

sigven commented Apr 13, 2021

I experience the exact same issue (R version 4.0.5). For some reason, library(org.Hs.eg.db) works when installing and loading the package from the terminal, but not within Rstudio. Also reported by others here: https://support.bioconductor.org/p/9136239/

@evchambers
Copy link

evchambers commented Apr 13, 2021

Also just having this issue after no problems yesterday (R version 4.0.3 ). My issue is with library(org.Mm.eg.db). I have installed a few new packages so wondering if its related to some sort of conflict.

Edit - Like the OP I have also been connecting to other databases (topGO)

@jpadesousa
Copy link

Same issue here. Works when I load the package in the terminal but not in RStudio.
R version 4.0.4
RStudio version 1.2.5033

@kevinushey
Copy link
Contributor

Thanks; I've reproduced this on my Linux VM as well. I'll try to investigate today.

@kevinushey
Copy link
Contributor

Here's the associated call that is failing:

DBI::dbConnect(
  RSQLite::SQLite(),
  dbname = system.file("extdata/org.Hs.eg.sqlite", package = "org.Hs.eg.db"),
  cache_size = 64000L, 
  synchronous = "off",
  flags = RSQLite:::SQLITE_RO,
  vfs = "unix-none"
)

For whatever reason, the attempt to establish that connection succeeds in plain R but not in RStudio.

@kevinushey
Copy link
Contributor

In the interim, as a workaround, you can set:

options(connectionObserver = NULL)

I think an update to the RSQLite package might have broken compatibility with RStudio's connection observer, which is used to update the Connections pane when new connections are opened.

Browse[5]> sqlite_ListObjectTypes(con)
$table
$table$contains
[1] "data"


$view.contains
[1] "data"

@kevinushey
Copy link
Contributor

Marking as 1.4-JR as, even if there might be an issue with how RSQLite is communicating with RStudio here (via the connections observer) it absolutely should not prevent packages from loading or creating connections. (It should just imply that the Connections pane might not work as expected.)

@levin252
Copy link
Author

Great! Thank you SO MUCH- I'll try that out and let you know if it works for me as well! I was just about to mention that I did notice the connections pane would frequently be opened/populated already when I opened RStudio (and the previously mentioned "dbDisconnect" issue). It's still very strange to me that the issue still persist in RStudio somehow even after uninstalling+reinstalling and removing all configuration files (that I know of/are removed as standard uninstall).

@levin252
Copy link
Author

Sorry for the delay in response, but I can attest the code you recommended (below) worked to allow normal usage of the 'org.' packages in RStudio (for me anyway). Thank you again!

options(connectionObserver = NULL)

@kevinushey kevinushey added test and removed backlog labels Apr 21, 2021
@kevinushey
Copy link
Contributor

Will be fixed in the next daily builds. Note that verification should be done with RSQLite 2.2.6 installed.

> DBI::dbConnect(
+   RSQLite::SQLite(),
+   dbname = system.file("extdata/org.Hs.eg.sqlite", package = "org.Hs.eg.db"),
+   cache_size = 64000L, 
+   synchronous = "off",
+   flags = RSQLite:::SQLITE_RO,
+   vfs = "unix-none"
+ )
An error occurred while the 'RSQLite' package was updating the RStudio Connections pane:
Error in l$contains: $ operator is invalid for atomic vectors
If necessary, these warnings can be squelched by setting `options(rstudio.connectionObserver.errorsSuppressed = TRUE)`.
<SQLiteConnection>
  Path: /Users/kevinushey/Library/R/4.0/library/org.Hs.eg.db/extdata/org.Hs.eg.sqlite
  Extensions: TRUE

The error is still reported, but is now non-fatal and can be hidden if desired.

@kevinushey
Copy link
Contributor

Note that the issue is resolved also in RSQLite 2.2.7, so if you install the latest-available version of RSQLite the version should not occur regardless of version of RStudio.

@levin252
Copy link
Author

Note that the issue is resolved also in RSQLite 2.2.7, so if you install the latest-available version of RSQLite the version should not occur regardless of version of RStudio.

I can verify for me at least that this worked- installing RSQLite 2.2.7, restarting R, and reloading my packages resulted in my code now working with no errors.

Thank you for the info!

@ronblum
Copy link
Contributor

ronblum commented Apr 27, 2021

Verified that error is displayed but is non-fatal using RSQLite 2.2.6. Using the original example, we can confirm that the package loads:

> (.packages())
[1] "RSQLite"   "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
[8] "base" 

<SNIP>
An error occurred while the 'RSQLite' package was updating the RStudio Connections pane:
Error in NULL: $ operator is invalid for atomic vectors
If necessary, these warnings can be squelched by setting `options(rstudio.connectionObserver.errorsSuppressed = TRUE)`.

> (.packages())
 [1] "org.Hs.eg.db"  "AnnotationDbi" "IRanges"       "S4Vectors"     "Biobase"      
 [6] "BiocGenerics"  "parallel"      "stats4"        "RSQLite"       "stats"        
[11] "graphics"      "grDevices"     "utils"         "datasets"      "methods"      
[16] "base" 

With RSQLite 2.2.7, the error is no longer displayed. Similarly with the connection code.

Tested with RStudio Server 1.4.1687 on Ubuntu 20.04 via Chrome on MacOS 11.3.

@ronblum ronblum closed this as completed Apr 27, 2021
@ronblum ronblum removed the test label Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants