bd2kccd / r-causal

R Wrapper for Tetrad Library
35 stars 19 forks source link

Problem setting up r-causal #73

Open cabal-cmu opened 7 years ago

cabal-cmu commented 7 years ago

@chirayukong

Hi, this problem came from Peter Spirtes, through the Helpdesk:

I tried to follow the instructions for using r-causal but I could not get it to work.

install.packages("stringr") install.packages("rJava”) library(devtools) install_github("bd2kccd/r-causal") Downloading GitHub repo bd2kccd/r-causal@master from URL https://api.github.com/repos/bd2kccd/r-causal/zipball/master Installing rcausal '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD \ INSTALL \ '/private/var/folders/ph/2js0sw_j4sd01tbfb72gm5hw0000gp/T/RtmpZOcbT1/devtools1e22f624572/bd2kccd-r-causal-7c5be55' \ --library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library' --install-tests

In addition, when I tried to add the libraries “rJava” using the library command, it said it couldn’t find it.

cabal-cmu commented 7 years ago

@chirayukong

This message also came as part of the problem:

JavaVM: requested Java version ((null)) not available. Using Java at "" instead. JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib JavaVM FATAL: Failed to load the jvm library. Error : .onLoad failed in loadNamespace() for 'rcausal', details: call: .jinit() error: JNI_GetCreatedJavaVMs returned -1

kingfish777 commented 7 years ago

Install Oracle version of the jdk. The latest version 8/1.8 subversion whatever should do it.


From: cabal-cmu notifications@github.com Sent: Friday, November 17, 2017 12:37 PM To: bd2kccd/r-causal Cc: Subscribed Subject: Re: [bd2kccd/r-causal] Problem setting up r-causal (#73)

@chirayukonghttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_chirayukong&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=H9o0Suxigv8Vn_pXI0-Qsm-gTxX5zYRCHMIXSPtKJSs&s=BWwsIQls02pfV8C0y9epxizgX92Pcui4mltWIH3AxF0&e=

This message also came as part of the problem:

JavaVM: requested Java version ((null)) not available. Using Java at "" instead. JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib JavaVM FATAL: Failed to load the jvm library. Error : .onLoad failed in loadNamespace() for 'rcausal', details: call: .jinit() error: JNI_GetCreatedJavaVMs returned -1

- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bd2kccd_r-2Dcausal_issues_73-23issuecomment-2D345326788&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=H9o0Suxigv8Vn_pXI0-Qsm-gTxX5zYRCHMIXSPtKJSs&s=u06LyjWOTLC8YcDtBweKEOLlFQPsJvXrJ3evbm1hbNI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ACh2SDSKATvAM4Bn2X6KrDsPG-5FZ6GSj4ks5s3dJhgaJpZM4QiZ0j&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=H9o0Suxigv8Vn_pXI0-Qsm-gTxX5zYRCHMIXSPtKJSs&s=qz3sqBO0g7capuZW-FFHr3RBhoT3Zm3whB0AYOqQpIw&e=.

cabal-cmu commented 7 years ago

@chirayukong

Update: I install the Java for OS X 2014-001 , which seemed to solve the problem of the rJava installation. I repeat all the installation process with shows no errors. I try the example for fgs continuous but get the next error:

library(rcausal) data("charity") fgs <- fgs(df = charity, penaltydiscount = 2, maxDegree = -1,
faithfulnessAssumed = TRUE, numOfThreads = 2, verbose = TRUE) Error: could not find function "fgs"

kingfish777 commented 7 years ago

The causal alg formerly known as “fgs” is now “fges”

From: cabal-cmu notifications@github.com Reply-To: bd2kccd/r-causal reply@reply.github.com Date: Friday, November 17, 2017 at 13:07 To: bd2kccd/r-causal r-causal@noreply.github.com Cc: Scott Malec Scott.Malec@uth.tmc.edu, Comment comment@noreply.github.com Subject: Re: [bd2kccd/r-causal] Problem setting up r-causal (#73)

@chirayukonghttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_chirayukong&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=ZsSMEEd0PZpcdCUockQVrUJs5pGKpxyVrp3IFmw59Og&s=SNqAdk_jOQlTnmvlFmN0nF-Jwvsr8eakiEnwYxnPWB8&e=

Update: I install the Java for OS X 2014-001 , which seemed to solve the problem of the rJava installation. I repeat all the installation process with shows no errors. I try the example for fgs continuous but get the next error:

library(rcausal) data("charity") fgs <- fgs(df = charity, penaltydiscount = 2, maxDegree = -1, faithfulnessAssumed = TRUE, numOfThreads = 2, verbose = TRUE) Error: could not find function "fgs"

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bd2kccd_r-2Dcausal_issues_73-23issuecomment-2D345336409&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=ZsSMEEd0PZpcdCUockQVrUJs5pGKpxyVrp3IFmw59Og&s=UKgA0NA3JM9JOWFtBrQz8eXzDVjEhKFlFSSmc9o09-4&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ACh2SBP1ZFa243qLZ9x4E3xt82Hqu4hIks5s3dmGgaJpZM4QiZ0j&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=ZsSMEEd0PZpcdCUockQVrUJs5pGKpxyVrp3IFmw59Og&s=y3OznwBJdJIl3bZBgTiwbFNBwLeFPFd3x8NXXNEf5sc&e=.

ccd-helpdesk commented 7 years ago

@kingfish777

Thanks. I made the adjustments, and go this error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) : java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

kingfish777 commented 7 years ago

Ah, that one. Do a javac –version and java –version and tell me what it says. That means that rJava doesn’t like that particular version of Oracle java.

On my MBP, I have

javac -version javac 1.8.0_121 and r-causal seems to run fine. So, go and install that version of the Oracle jdk and once installed re-run sudo R CMD javareconf (and remove and then re-install rJava from Bioconductor).

From: CCD-helpdesk notifications@github.com Reply-To: bd2kccd/r-causal reply@reply.github.com Date: Friday, November 17, 2017 at 14:26 To: bd2kccd/r-causal r-causal@noreply.github.com Cc: Scott Malec Scott.Malec@uth.tmc.edu, Mention mention@noreply.github.com Subject: Re: [bd2kccd/r-causal] Problem setting up r-causal (#73)

@kingfish777https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_kingfish777&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=IUinmz-GGKVuiwSG-Jzacd6IyqSVtSdkKctxrddGuKc&s=_2TxidDBqpCTzDirCDGx3MDmEK9kk1xFLM4zImxDrbo&e=

Thanks. I made the adjustments, and go this error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) : java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bd2kccd_r-2Dcausal_issues_73-23issuecomment-2D345356605&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=IUinmz-GGKVuiwSG-Jzacd6IyqSVtSdkKctxrddGuKc&s=mExR8G-SuLCRxowRL3M1FjImxQsg5rLMAUKuQiIqoAs&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ACh2SHq2oT7b4EitHdgfz4jgqaZZmdt-5Fks5s3evogaJpZM4QiZ0j&d=DwMFaQ&c=6vgNTiRn9_pqCD9hKx9JgXN1VapJQ8JVoF8oWH1AgfQ&r=cJocORfYogykfmw40_PYbTR-_FlW5GZ15C5SG7IuxyE&m=IUinmz-GGKVuiwSG-Jzacd6IyqSVtSdkKctxrddGuKc&s=d4M7sozgsK7tVYuN8hzsAIwmyMKDHwB247uQp21RPxk&e=.

ccd-helpdesk commented 7 years ago

@kingfish777 javac 1.8.0_111

java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

kingfish777 commented 7 years ago
  1. Upgrade to Oracle jdk 1.8.0_121
  2. source("http://www.bioconductor.org/biocLite.R")
  3. R > biocLite("rJava", type = "source") #this will force recompile locally
  4. sudo R CMD javareconf
  5. Run your script and report back
ccd-helpdesk commented 7 years ago

@kingfish777

I followed the instruction, but using Oracle jdk 9.0.1. The most recent available in the website (couldn't find older versions)

I am using the website example, changing fgs, for ages


library(rcausal) data("charity") #Load the charity dataset

Compute FGES search

fges <- fges(df = charity, penaltydiscount = 2, maxDegree = -1,
faithfulnessAssumed = TRUE, verbose = TRUE)


And got the next error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) : java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

ccd-helpdesk commented 7 years ago

Could it be something about the new dataloaders ?

kingfish777 commented 7 years ago

Have you restarted your R session? Also, try a reboot and go through same process. Another thing that sometimes works is to remove rJava and rcausal and perform a fresh reinstall. If you recall a few years ago, there was a way to purge these from all of one's libraries in one line. I believe the instructions were in the instructions for Mac users, if you look back on archive.org.

ccd-helpdesk commented 7 years ago

So, I restarted the R version and that did not help.

There is no archived versions for the website, so I couldn't recover the instructions.

How should I purge rJava and rcausal ?

thanks

kingfish777 commented 7 years ago

To remove/purge:

detach("package:rcausal", unload=TRUE)
detach("package:rJava", unload=TRUE)
remove.packages(c("rcausal", "rJava"))

But fiRst, anotheR diRty tRick: https://stackoverflow.com/questions/6979917/how-to-unload-a-package-without-restarting-r

put this into a file, say charityFges.R:

library(RBGL) 
library(rJava) # loading these seems to help in order for one's set-up to "click", I've found
library(rcausal)
data("charity")
fgs <- fges(df = charity, penaltydiscount = 2, maxDegree = -1, faithfulnessAssumed = TRUE, numOfThreads = 2, verbose = TRUE)
print(fgs)

Next, do this on the command line: sudo Rscript charityFges.R

kingfish777 commented 7 years ago

There are rJava tips and tricks at the bottom: https://github.com/bd2kccd/r-causal

ccd-helpdesk commented 7 years ago

Thanks. I will try all these and write back when I make it work. Need to leave this for a moment.

Thanks again for the help.

kingfish777 commented 7 years ago

rcausal.tar.gz I have attached my local rcausal. To install, you can

R
install.packages("rcausal.tar.gz")
ccd-helpdesk commented 7 years ago

Thanks. Because I keep getting the same error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) : java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

Do you know what is this error about ?

On Fri, Nov 17, 2017 at 4:21 PM, Kingfish Threesevens < notifications@github.com> wrote:

rcausal.tar.gz https://github.com/bd2kccd/r-causal/files/1483880/rcausal.tar.gz I have attached my local rcausal. To install, you can

R install.packages("rcausal.tar.gz")

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bd2kccd/r-causal/issues/73#issuecomment-345368423, or mute the thread https://github.com/notifications/unsubscribe-auth/AXWXj5GDkKVD14bow3XJmoSZhwoTTgehks5s3fi_gaJpZM4QiZ0j .

kingfish777 commented 7 years ago

Ah, yes, I think that it may have something to do with the version of Java that was used to compile the version of tetrad-lib that is included in r-causal and some conflict with the version of java that is present in the rJava config (from R CMD javareconf). That is what comes up when I jog my memory about it. I was able to fix it once locally with that problem by dropping in a compatible version of tetrad-lib into a local r-causal installation.