HOW TO FIX Error in .Hub("AnnotationHub", hub, cache, proxy, localHub, ...) - r

I am using REMP package in R to find methylation in repetitive elements. I have stumbled upon the function initREMP, which is giving me the error:
remparcel <- initREMP(arrayType = "EPIC", REtype = "Alu", ncore = 1)
Start Alu annotation data initialization ... (0 sec.)
Illumina platform: EPIC
Error in .Hub("AnnotationHub", hub, cache, proxy, localHub, ...) :
Local database does not exist.
Repeat call with 'localHub=FALSE'
I installed annotationhub package from the bioconductor and tried the function again. Still the error remains.

Finally I got the answer.If you are working behind a proxy server getAnnotationHub function will not be able to make connection with the URL.Therefor we have to set the proxy using
library(AnnotationHub) setAnnotationHubOption("PROXY","https://username:password#proxy:port")
then try the
AnnotationHub( hub=getAnnotationHubOption("URL"),
cache=getAnnotationHubOption("CACHE"),
proxy=getAnnotationHubOption("PROXY"),
localHub=FALSE)

Related

Problems with connecting to local postgres database from R through RPostgreSQL

I have to following code
drv <- RPostgreSQL::PostgreSQL()
con <- DBI::dbConnect(drv, dbname = 'dbname', user = 'user',
host = 'host.name', port = 5432, password = 'password')
When I run it on server (Ubuntu server 16.04 with latest updates) running the database I get the following error:
Error in .valueClassTest(ans, "data.frame", "dbGetQuery") :
invalid value from generic function ‘dbGetQuery’, class “NULL”, expected “data.frame”
But when I run R from commandline with sudo, it works, when I run it from different my laptop connecting to the DB on the server it also works. So it shouldn't be connection problem. I am thinking about problem with access rights to some libraries/executables/configs on the system? Any help will be appreciated.
When I run the dbConnect multiple times and it ends with the error, when I run drv_info <- RPostgreSQL::dbGetInfo(drv), I still get multiple connectionIds in the drv_info:
drv_info <- RPostgreSQL::dbGetInfo(drv)
> drv_info
$drvName
[1] "PostgreSQL"
$connectionIds
$connectionIds[[1]]
<PostgreSQLConnection>
$connectionIds[[2]]
<PostgreSQLConnection>
$fetch_default_rec
[1] 500
$managerId
<PostgreSQLDriver>
$length
[1] 16
$num_con
[1] 2
$counter
[1] 2
Found a source of confusion, but not necessarily the root problem. (I was assuming RPostgres, while you are using RPostgreSQL (github mirror).)
If you check the source, you'll find that the method is calling postgresqlNewConnection, which includes a call to dbGetQuery. The problem you're seeing is that your call to dbConnect is failing (my guess is at line 100) and returns something unexpected, but postgresqlNewConnection continues.
I see three options for you:
try calling dbConnect(..., forceISOdate=FALSE) to bypass that one call to dbGetQuery (note that this doesn't fix the connection problem, but it at least will not give you the unexpected query error on connection attempt);
raise an issue for the package maintainers; or
switch to using RPostgres, still DBI-based and actively developed (it looks like RPostgreSQL has not had significant commits in the last few years, not sure if that's a sign of good code stability or development stagnation)
One lesson you may take from this is that you should check the value returned from dbConnect; if is.null(con), something is wrong. (Again, this does not solve the connection problem.)

R- mongolite on OS X Sierra- No suitable servers found

I am trying to follow the "Getting started with MongoDB in R" page to get a database up and running. I have mongoDB installed in my PATH so I am able to run mongod from the terminal and open an instance. Though when I open an instance in the background and try running the following commands in R:
library(mongolite)
m <- mongo(collection = "diamonds") #diamonds is a built in dataset
It throws an error after that last statement saying:
Error: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'localhost']
How do I enable it to find the connection I have open? Or is it something else? Thanks.
It could be that mongolite is looking in the wrong place for the local server. I solved this same problem for myself by explicitly adding the local host address in the connection call:
m <- mongo(collection = "diamonds", url = "mongodb://127.0.0.1")

RStudio : Rook does not work?

I would like to build a simple webserver using Rook, however I am having strange errors when trying it in R-Studio:
The code
library(Rook)
s <- Rhttpd$new()
s$start()
print(s)
returns the rather useless error
"Error in listenPort > 0 :
comparison (6) is possible only for atomic and list types".
When trying the same code in a simple R-Console,everything works - so I would like to understand why that happens and how I can fix it.
RStudio is Version 0.99.484 and R is R 3.2.2
I've experienced same thing.
TLDR: This pull request solves the problem: https://github.com/jeffreyhorner/Rook/pull/31
RStudio is treated in different way and Rook port is same as tools:::httpdPort value. The problem is that in current Rook master tools:::httpdPort is assigned directly. It's a function that's why we need to evaluate it first.
If you want to have it solved right now, without waiting for merge into master: install devtools and load package from my fork #github.
install.packages("devtools")
library(devtools)
install_github("filipstachura/Rook")

RStudio cannot find any package after laptop restart

My R script worked fine in RStudio (Version 0.98.1091) on Windows 7. Then I restarted my laptop, entered again in RStudio and now it provides the following error messages each time I want to execute my code:
cl <- makeCluster(mc); # build the cluster
Error: could not find function "makeCluster"
> registerDoParallel(cl)
Error: could not find function "registerDoParallel"
> fileIdndexes <- gsub("\\.[^.]*","",basename(SF))
Error in basename(SF) : object 'SF' not found
These error messages are slightly different each time I run the code. It seems that RStudio cannot find any function that is used in the code.
I restarted R Session, cleaned Workspace, restarted RStudio. Nothing helps.
It must be noticed that after many attempts to execute the code, it finally was initialized. However, after 100 iterations, it crashed with the message related to unavailability of localhost.
Add library(*the package needed/where the function is*) for each of the packages you're using.

dbConnect with R 3.0 on Ubuntu 12.04 x64 --Error in as.integer(from) : cannot coerce type 'S4' to vector of type 'integer'

Just updated to R 3.0 and updated all the packages, including DBI. To my surprise, a script that I often use stopped working.
I am unable to connect to a MySQL database using dbConnect. The code script instantly, so only a few lines will reproduce the problem
> require("RMySQL")
> m = dbDriver("MySQL")
> dbConnect(m, user = 'user', password = 'pass', dbname = 'dbname', host = 'localhost', client.flag = CLIENT_MULTI_STATEMENTS)
Error in as.integer(from) :
cannot coerce type 'S4' to vector of type 'integer'
Calls: dbConnect ... mysqlNewConnection -> isIdCurrent -> as -> asMethod
Also tried it as:
dbConnect(MySQL(), user = 'user', password = 'pass', dbname = 'dbname', host = 'localhost', client.flag = CLIENT_MULTI_STATEMENTS)
but the same problem
Also tried removing other parameters, but the same issue from the dbDriver.
What changed in the DBI package with the latest update? How can I fix this?
I noticed that the DBI package is orphaned so don't know who to ask.
I had the same issue with R 3.0.1 on ubuntu.
Installing the latest version of the RMySQL-package resolved the problem:
> install.pacakges("RMySQL")
Make sure to restart R after the installation.
I'm still digging into the issue, but I think I've identified multiple causes of this issue. At their root, they all have to do with R expecting an S4 object but getting back an integer instead. I believe these are generally a result of the connection failing to establish.
Why is it failing? One thing I've noticed is that if you fail to close to many of your connections (~16 [see the number of maximum connections specified in the driver handle call] open) DBI won't/can't open a new connection. Make sure you are calling dbDisconnect as needed. Usually, this sort of problem results in a sensible error message, however sometimes results in the above referenced error. If possible access the DB through an abstraction layer, e.g. dplyr as some will monitor the db connections and kill them if they are inactive. Whereas, AFIK if you open a connection in a function and the function breaks, you have no way to close the open connection unless you returned the driver object from your initial call to dbConnect. In this case you have no choice but to restart your instance of R (possibly resetting your machine and clearing your workspace as well).
The other issue I recently encountered is that if RMySQL masks RPostgreSQL, then RPostgreSQL will fail. The reverse does not appear to be the case, but because others have mentioned RPostgreSQL in here as showing the same error message, it seemed worthy of note.
Update
The latest version of RMySQL (0.10.1) seems to have finished off RPostgreSQL - RPostgreSQL now fails to work regardless of load order. The same people working on RMySQL appear to be working on RPostgres (https://github.com/rstats-db/RPostgres) and this conflict appears to be a non-issue if using that package instead of RPostgreSQL. Specifically, use RPostgres::Postgres() in the place of RPostgreSQL::PostgreSQL() when specifying the driver in dbConnect. Other packages, e.g. dplyr, currently assume RPostgreSQL, so this issue can still bite (but it seems a resolution is in the works (https://github.com/rstats-db/RMySQL/issues/28).

Resources