2

I would like to install Bioconductor R packages. However I get error that the variables are not found... I really have no idea how RLink so I do appreciate your assistance.

Needs["RLink`"]
InstallR[]
REvaluate["source(\"http://bioconductor.org/biocLite.R\"); biocLite(\" DESeq \")"]

enter image description here

I have already installed these packages via R on my computer. I thought it may help to install them via RLink incase Mathematica puts them somewhere special. Trying to load the packages also does not work:

enter image description here

It works in R

enter image description here

R Version in RLink is not the most up-to-date but it should not be an issue...

[![enter image description here][4]][4]
SumNeuron
  • 5,422
  • 19
  • 51
  • The standard way to install R packages is via install.packages. But installing packages in this way works via RLink only on Windows. On other platforms, you need to use the R's command line for that - then you can work with installed packages via RLink. What OS are you on? – Leonid Shifrin Oct 14 '16 at 14:34
  • @LeonidShifrin I am on a Mac. Yes, normally install packages work like that. To get the bioconductor packages, you use these commands... then Library(DESeq) https://bioconductor.org/packages/release/bioc/html/DESeq.html – SumNeuron Oct 14 '16 at 14:39
  • Then I suggest that you install this from R's command line. After that, hopefully you should be able to work with the package using RLink. Also, I suggest to use the external R distribution with RLink, since the one that comes with RLink is pretty old. The steps to set this up can be found here. – Leonid Shifrin Oct 14 '16 at 14:46
  • @LeonidShifrin see updated question – SumNeuron Oct 14 '16 at 14:49
  • Well, in this case the error seems to be on the R side, as reported by RLink. Are you sure you did successfully install the package? Again, one way to test is to type the same library(DESeq) in R console for your R distribution and see what happens. – Leonid Shifrin Oct 14 '16 at 14:54
  • One other thing to make sure is that you are using the right version of R with RLink. You may test this via REvaluate["R.Version()"], to make sure you use the one you want (rather than, for example, the default one that comes with RLink). You need to point to specific R via "RHomeLocation" option in InstallR, if you use the external R distro. – Leonid Shifrin Oct 14 '16 at 14:56
  • @LeonidShifrin so how do I do this? (sorry for being pathetically unaware of RLink) – SumNeuron Oct 14 '16 at 15:01
  • Ok, so I've done that myself, and the problem is really not on the RLink side. The same issue you get also when trying in R console. You need to execute these commands from R command line: biocLite(), and then biocLite("DESeq2"). They will update the version of DESeq2 that you installed, as well as dependencies. After that, it worked with RLink, at least to the point that relevant library gets loaded with REvaluate["library(DESeq2)"]. Here is the relevant link – Leonid Shifrin Oct 14 '16 at 19:24
  • @LeonidShifrin Sorry I am still not quite sure what you mean and I think we may have a miscommunication. Everything is already installed via R. I can already run all of Bioconductor in R, and do so regularly. The problem is trying to run R via RLink in Mathematica.. – SumNeuron Oct 15 '16 at 06:56
  • Then I really don't know. What I meant was that I installed this on my R distro (3.1.1), and then initially had the same issue you reported. Then, I followed that link I gave, ran those commands, and had no issues after that neither in R nor in Mathematica / RLink. The error message you are getting seems to indicate that the problems are on the R side. All I can suggest is to, once again, make sure that RLink runs the proper version of R. – Leonid Shifrin Oct 15 '16 at 15:39
  • @LeonidShifrin so how does one select which version of R to use in Mathematica? – SumNeuron Oct 15 '16 at 18:00
  • It is described in the link I gave in my first comment. Basically, you use options "RHomeLocation", and possibly "RVersion". You can look up the details in that link. Basically, on a fresh kernel, you execute SetEnvironment[ "DYLD_LIBRARY_PATH" -> "/Library/Frameworks/R.framework/Resources/lib"] and then InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources", "RVersion" -> 3]. The paths on your machine may differ, although I believe these are the default ones. You can test then with REvaluate["R.Version()"]. – Leonid Shifrin Oct 15 '16 at 18:29
  • @LeonidShifrin I didn't try RHomeLocation as on the documentation it is only for windows? – SumNeuron Oct 16 '16 at 11:10
  • Well, you are right. This is an oversight on my side, I should've made that more automatic. Problem is, I never had enough dedicated time to improve on RLink since it was released, and such a feature needs some time to be automated and tested properly on a variety of systems. So in practice, "RHomeLocation" works on all systems but on Linux and Mac requires a bit of extra work (on Linux one may need to install extra library, which was another obstacle to full automation) on the side of the user. Which is what the setup guide kindly written by Szabolcs, that I linked to, describes how to do. – Leonid Shifrin Oct 16 '16 at 13:17
  • @LeonidShifrin any luck for Macs? – SumNeuron Oct 16 '16 at 13:27
  • Sorry, not sure I follow the question. If you do the steps listed in that link of Szabolcs I gave, it all should work for you right away, right now. If you mean the automation of those steps, then there is some chance that I could get some time to work on automating this process on Macs soon. – Leonid Shifrin Oct 16 '16 at 13:34
  • @LeonidShifrin I was curious as to if you may have made any progress with specifying home location for R on mac. This issue is the Mac advice given by Szabolcs for v10 fails to load dynamic libraries. I am not the only one with this issue. Where would I even begin to trouble shoot this? – SumNeuron Feb 16 '17 at 23:24
  • I actually did some work on that, but unfortunately that had to be stopped / postponed for 11.2 due to conflicting things that were considered of higher priority. Hopefully, there will be no more delays with this, although 11.2 is still rather far away, admittedly. But, have you carefully read through Szabolcs's advice on his page? He has a section for modern OS X versions, here. It did work for everyone who tried it so far, as far as I am informed. – Leonid Shifrin Feb 17 '17 at 11:08
  • @LeonidShifrin yes it seems my system is missing the key file... so I guess I will have to maybe try a clean install. – SumNeuron Feb 17 '17 at 13:17
  • Which file do you mean? – Leonid Shifrin Feb 17 '17 at 14:16
  • @LeonidShifrin libjri.jnilib – SumNeuron Feb 17 '17 at 14:27
  • 1
    You may also get it from here, mac binary link at the bottom. Just download the archive, unpack and go to jri subfolder, it's there. Just keep in mind that the release version won't work with bundled R, only with external one - and in any case, only after you perform the procedure described by Szabolcs. – Leonid Shifrin Feb 17 '17 at 14:54

0 Answers0