giovedì 23 ottobre 2008

R Upgrade on Mac Os X 10.5.5 (Leopard)

To reinstall packages from an old version of R to a new one.
In the old version type:
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")

Install the most recent version of R:
Download the most recent version of R from The Comprehensive R Archive Network (CRAN)
# To wipe the old R version
rm -rf /Library/Frameworks/R.framework /Applications/R.app
rm -rf /Library/Receipts/R-*

Build from source new R version (see this FAQ).
From inside the decompressed R-?.?.? directory type:
# See Section 2.2 of RMacOSX FAQ for the flag description
./configure --with-blas='-framework vecLib' --enable-BLAS-shlib
make
sudo make install

Install BioConductor packages using the biocLite.R installation script.
In an R command window, type the following:
source("http://bioconductor.org/biocLite.R")
chooseBioCmirror()
biocLite()

If you have other Bioconductor packages missing from the old installation:

load("installed_old.rda")
tmp <- installed.packages()
installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
missing <- setdiff(installedpkgs, installedpkgs.new)
for (i in 1:length(missing)) biocLite(missing[i])

Re-install the missing packages from CRAN:
load("installed_old.rda")
tmp <- installed.packages()
installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
missing <- setdiff(installedpkgs, installedpkgs.new)
install.packages(missing)
update.packages()

If you use some package created by Henrik Bengtsson:
source("http://www.braju.com/R/hbLite.R")
hbLite()

If you find your X11 broken after the installation procedure (it happens every time to me, at least on Leopard) install the XQuartz App from here.

Update: If you need to install a recent version of R on old hardware (Power PC G4) and OS (Mac OS X 10.4 here) this post can be useful.

18 commenti:

  1. Thanks! This is extremely helpful!

    RispondiElimina
  2. Grazie mille, with such good daily tips I'll be back here tommorrow!

    RispondiElimina
  3. Troppo gentile! The door is always open! ;-)

    RispondiElimina
  4. Thanks, very useful indeed.. I also suggest to use chooseBioCmirror() after sourcing "biocLite.R".. depending on your location and the installed packages (Hs map size is around 800Mb) the upgrade running time can be drastically reduced.

    jC

    RispondiElimina
  5. @JC Thanks for your contribution!

    RispondiElimina
  6. Hi,

    Thanks for the post. When trying to install bioconductor packages using, I get the following error:
    >source("http://bioconductor.org/biocLite.R")
    Error in file(file, "r", encoding = encoding) :
    internet routines cannot be loaded
    In addition: Warning message:
    In file(file, "r", encoding = encoding) :
    unable to load shared object '/Library/Frameworks/R.framework/Resources/modules/x86_64/internet.so':
    dlopen(/Library/Frameworks/R.framework/Resources/modules/x86_64/internet.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libR.dylib
    Referenced from: /Library/Frameworks/R.framework/Resources/modules/x86_64/internet.so
    Reason: Incompatible library version: internet.so requires version 2.13.0 or later, but libR.dylib provides version 2.12.0

    Any advice would be appreciated!

    RispondiElimina
  7. It seems (not sure) that some component of the previous version (R.2.12.0) are still in place. I suggest to wipe completely the old version (as stated at the beginning of the post) and try again to install R from scratch. Remember that this procedure works (at least for me) on Mac OS X 10.5. I can't guarantee this will work on Mac OS X 10.6 or 10.7 as well.

    RispondiElimina
  8. Thank you so much for this. So much easier than copying my entire suite of library files and moving them back into the new R directory...

    RispondiElimina
  9. I like the sarcasm. I don' like so much comments suggesting alternative strategies without indicate the context in which you can apply them.
    The procedure you suggest works almost certainly between minor revisions: e.g., upgrade from R-2.14.0 to R-2.14.1. Nevertheless try to upgrade 'your way' from let's say R-2.9.0 to R-2.14.1! I think you'll have a surprise! My post is meant to explain an upgrade workflow which works FOR ME with the particular configuration (hardware/software) described. It seems to be useful to other people too and I'm glad for that! If anybody (maybe using his real name, nobody bites on this blog ;-) ) want to post a more general, reliable and fast pipeline I'll be more than happy to update the post.

    RispondiElimina
  10. hi...Im student from Informatics engineering nice article,
    thanks for sharing :)

    RispondiElimina
  11. I'm happy it is of some use to you! :-)

    RispondiElimina
  12. Thank you, this is very helpful!

    I think though that if I go through the commands in the order that you write them, this one:

    for (i in 1:length(missing)) biocLite(missing[i])

    ... installs all the packages from biocLite. So running

    install.packages(missing)

    first might make more sense. I'm not sure, I haven't tried this.

    Anyway, updated R and all packages there -> happy. Many thanks!

    RispondiElimina
  13. Dear Marianne, I'm glad this old post it is still useful to someone! Nowadays I completely switch to Linux and I don't have access to a Mac. In any case i think the install.packages() function is redundant: you can use directly biocLite to install CRAN as well as bioconductor packages.

    RispondiElimina
  14. Paolo! It is Gareth the student of Luca. I just had to fix this and found your blog. Bioinformatics is a small world so I'm saying hello to people when I run into them on forums from now on!

    RispondiElimina
  15. Hi Gareth! Thanks for visiting my blog! I hope you find something useful for you! See you soon in person! :-)

    RispondiElimina
  16. Hi there Paolo, thanks for your useful post! I tried this in my OS X 10.7.5 Lion and it seems like it worked! Do you mind if I put your code in my own blog? (with some minor comments for my particular case).

    RispondiElimina
    Risposte
    1. Feel free to use the code on your blog: just put a link to the original post.

      Elimina