{"id":47,"date":"2013-09-26T15:08:04","date_gmt":"2013-09-26T15:08:04","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/icsf\/?page_id=47"},"modified":"2025-09-04T12:39:28","modified_gmt":"2025-09-04T12:39:28","slug":"r","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/r\/","title":{"rendered":"R"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>R is a free software environment for statistical computing and graphics.<\/p>\n<h2>incline2000<\/h2>\n<p>From 1st Aug 2024, the only nodes in the iCSF are the 2TB nodes, which received an operating system upgrade. Following this upgrade, some of the older versions of R (and Rstudio) may not run.<\/p>\n<p>We strongly encourage all users to move to the newer versions of R (see below), which have been built for the new operating system on the iCSF.<\/p>\n<h3>Using R on the iCSF AND ALSO CSF3 &#8211; June 2025 Update<\/h3>\n<p>If you only use the iCSF, you can <a href=\"#versions\">skip this section<\/a>.<\/p>\n<p>New users of the iCSF and CSF3 from June 2025, who run R on both systems, can also <a href=\"#versions\">skip this section<\/a> (an extra modulefile was needed to fix a compatibility issue with iCSF and CSF3. But this is no longer an issue.)<\/p>\n<p>If you&#8217;ve previous used the iCSF AND CSF3 to run R, before the CSF3 upgrade in Feb\/May 2025, you should continue to follow the original instructions below.<\/p>\n<h3>Original Instructions<\/h3>\n<p>Prior to Feb 2025, the operating system on the iCSF nodes was newer than that on CSF3. So any packages you installed in to a &#8220;personal&#8221; library using <code>install.packages(\"<em>thing<\/em>\")<\/code>, <em>while you were logged in to the iCSF<\/em>, would very likely NOT run on CSF3, due to older system libraries on that system at the time.<\/p>\n<p>So to prevent a package installed on the iCSF from <em>polluting<\/em> your personal library on CSF3, you needed to load the following modulefile:<\/p>\n<pre># Additional modulefile for people using R on the iCSF who also use R on\r\n# CSF3. This modulefile is ONLY available on the iCSF nodes!!!\r\n# Load this AFTER loading an 'apps\/gcc\/R\/<em>x.y.x<\/em>' modulefile on the iCSF.\r\n\r\nmodule load apps\/gcc\/R\/incline2000-fix\r\n<\/pre>\n<p>This will force any subsequent package installs performed on the iCSF into a separate <code>~\/R\/el9\/<\/code> directory tree, away from the default tree <code>~\/R\/<\/code> used on the CSF3. It will prevent you breaking your CSF3 package installs.<\/p>\n<p>But it does mean that if you install a package on the iCSF, it WON&#8217;T be visible to R on the CSF3. You&#8217;ll need to login to CSF3 and install it again, for use on CSF3.<\/p>\n<p>In summary:<\/p>\n<ul>\n<li>Package installs performed on the iCSF <em>may<\/em> NOT run on CSF3<\/li>\n<li>Package installs performed on CSF3 will probably run OK on the iCSF<\/li>\n<li>The <code>apps\/gcc\/R\/incline2000-fix<\/code> modulefile will keep your iCSF package installs away from your CSF3 install area. You will still be able to see your CSF3 installs when on the iCSF (they might still work.) But you won&#8217;t see your iCSF installs when on CSF3 (they probably won&#8217;t work anyway.)<\/li>\n<\/ul>\n<p>If you need further information about R packages installs on the iCSF and CSF3, please contact <a href=\"&#109;&#x61;&#x69;l&#116;&#x6f;:&#105;&#x74;&#x73;-&#114;&#x69;-&#116;&#x65;&#x61;m&#64;&#x6d;a&#110;&#x63;&#x68;&#101;&#115;&#x74;e&#114;&#x2e;&#x61;&#99;&#x2e;&#x75;k\">&#x69;&#x74;&#x73;&#x2d;&#x72;&#x69;&#x2d;&#x74;&#x65;&#x61;&#x6d;&#x40;&#x6d;&#x61;&#x6e;&#x63;&#x68;&#x65;&#x73;&#x74;&#x65;&#x72;&#x2e;&#x61;&#x63;&#x2e;&#x75;&#x6b;<\/a>.<\/p>\n<h2 id=\"versions\">Versions available<\/h2>\n<p>Please see the <a href=\"#modules\">Setup procedure<\/a> section below for the modulefile commands that will make a particular version available to your login session.<\/p>\n<p>The following versions are installed on the iCSF:<\/p>\n<p><strong>These versions are for use on the iCSF nodes, following the operating system upgrade. You are strongly encouraged to begin using version 4.4.0 or newer.<\/strong><\/p>\n<ul>\n<li>R 4.5.1 &#8211; includes GCC 11.5.0 (system default as of Sep 2025)<\/li>\n<li>R 4.4.2 &#8211; includes GCC 14.2.0<\/li>\n<li>R 4.4.1 &#8211; including a non-optimised version to resolve issues with certain packages\/fuctionality (4.4.1-nonopt) &#8211; see below.\n<p>This release is missing <em>libRlapack.so<\/em>, so it is unable to use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Basic_Linear_Algebra_Subprograms\">Basic Linear Algebra Subprograms<\/a> (BLAS). This only applies to the optimised installation on iCSF.<\/li>\n<li>R 4.3.3 &#8211; please upgrade to using 4.4.0 or newer<\/li>\n<li>R 4.1.3 &#8211; please upgrade to using 4.4.0 or newer<\/li>\n<li>R 4.1.2 &#8211; please upgrade to using 4.4.0 or newer<\/li>\n<li>R 4.0.2 &#8211; please upgrade to using 4.4.0 or newer<\/li>\n<\/ul>\n<p><strong>Versions below here here may not run correctly on the upgraded iCSF nodes &#8211; please use a newer version (see above.) Note that the old incline256 nodes are no longer available (1st Aug 2024.)<\/strong><\/p>\n<ul>\n<li>R 4.3.2<\/li>\n<li>R 4.3.1<\/li>\n<li>R 4.1.2-gcc830 &#8211; includes BioConductor 3.13 and ukbtools 0.11.3, only on incline256 boxes<\/li>\n<li>R 4.0.2-gcc830<\/li>\n<li>R 3.6.1-gcc830 &#8211; includes BioConductor 3.9.0 &amp; <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ukbtools\/index.html\">ukbtools<\/a> 0.11.3 # only on incline256 boxes. Uses newer C++ compiler which will allow most user-packages to install correctly (those that need C++11 and C++14)<\/li>\n<li>R 3.6.1 # all incline node types but some user-packages may not install correctly (those that need C++11 and C++14)<\/li>\n<li>R 3.6.0 &#8211; includes BioConductor 3.7 &amp; <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ukbtools\/index.html\">ukbtools<\/a> 0.11.2 # only on incline256 boxes<\/li>\n<li>R 3.5.2 &#8211; includes BioConductor 3.5 &amp; <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ukbtools\/index.html\">ukbtools<\/a> 0.9.0 # only on incline256 boxes<\/li>\n<\/ul>\n<ul>\n<li>R 3.4.2 &#8211; includes BioConductor 3.5 &amp; <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ukbtools\/index.html\">ukbtools<\/a> 0.9.0<\/li>\n<li>R 3.4.1 &#8211; includes BioConductor 3.5 &amp; <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ukbtools\/index.html\">ukbtools<\/a> 0.9.0<\/li>\n<li>R 3.3.3 &#8211; includes BioConductor 3.3 (Rcmdr is not installed).<\/li>\n<li>R 3.3.0 &#8211; includes BioConductor 3.3 (Rcmdr is not installed).<\/li>\n<li>R 3.2.3 &#8211; does not include Bioconductor or Rcmdr<\/li>\n<li>R 3.2.3-ambs &#8211; as per 3.2.3 but with a number of additional packages &#8211; see updates at the bottom of this page for full details.<\/li>\n<li>R 3.2.0 &#8211; includes BioConductor 3.1 (please note Rcmdr does not work in this version)<\/li>\n<li>R 3.1.0 &#8211; includes BioConductor 2.14<\/li>\n<li>R 3.0.2<\/li>\n<li>R 2.15.3 &#8211; includes BioConductor 2.11<\/li>\n<\/ul>\n<ul>\n<li>Microsoft R Open 3.2.4 &#8211; does <strong>not<\/strong> include BioConductor. It does include MKL libraries for parallel matrix calculations<\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.bioconductor.org\/\">Bioconductor<\/a> is included in some of the central iCSF installations of R. Not all associated packages may be available, but you can install them to your own home directory using the <a href=\"#bioc\">Adding BioConductor Packages<\/a> instructions below, in conjunction with information from the bioconductor website.<\/p>\n<p>Alternatively, we may be able to add them to the central install &#8211; contact <a href=\"&#109;a&#x69;l&#x74;o&#x3a;i&#x74;s&#x2d;r&#x69;&#45;&#x74;&#101;&#x61;&#109;&#x40;&#109;&#x61;&#110;&#x63;&#104;&#x65;&#115;t&#x65;r&#x2e;a&#x63;&#46;&#x75;k\">&#x69;&#x74;&#x73;&#x2d;&#x72;&#x69;&#x2d;&#116;&#101;&#97;&#109;&#64;manc&#x68;&#x65;&#x73;&#x74;&#x65;&#x72;&#x2e;&#x61;&#99;&#46;&#117;&#107;<\/a> .<\/p>\n<h2>Restrictions on use<\/h2>\n<p>There are no restrictions on access to R as it is a free piece of software released under a GNU license. All users should familiarise themselves with the licensing information available via the <a href=\"http:\/\/www.r-project.org\/\">R website<\/a>.<\/p>\n<h2 id=\"modules\">Setup procedure<\/h2>\n<p>To access the executables please load an appropriate modulefile.<\/p>\n<p>Note, if you wish to use Rstudio, load the R modulefile first, then please see the <a href=\"\/icsf\/software\/applications\/rstudio\/\">Rstudio page<\/a> for a list of available modulefiles.<\/p>\n<pre># <strong>We recommend all users upgrade to using the latest versions of R<\/strong>\r\nmodule load apps\/gcc\/R\/4.5.1\r\n# OR\r\nmodule load apps\/gcc\/R\/4.4.2\r\n\r\n# This installation is unable to use the  Basic Linear Algebra Subprograms (BLAS) library\r\nmodule load apps\/gcc\/R\/4.4.1\r\n\r\n# <strong>If you experience crashing in 4.4.1<\/strong> (either at the command-line or in Rstudio),\r\n# please try this 'nonopt' version which has been compiled without optimization (-O0)\r\n# to resolve some crashes we've seen in various libraries and functions.\r\nmodule load apps\/gcc\/R\/4.4.1-nonopt\r\n\r\n# Please upgrade to 4.4.2 if using these versions\r\nmodule load apps\/gcc\/R\/4.3.3\r\nmodule load apps\/gcc\/R\/4.1.3\r\nmodule load apps\/gcc\/R\/4.1.2\r\nmodule load apps\/gcc\/R\/4.0.2\r\n\r\n# <strong>Additional modulefile to consider loading after loading one of the above:<\/strong>\r\n# If using CSF3 <em>as well as<\/em> iCSF, and you have problems with R libraries not running on CSF3,\r\n# this modulefile will keep your iCSF library installs away from your CSF3 library installs.\r\n# Problems can occur when the CSF tries to use R libraries that were installed on the iCSF.\r\n# (If you do use this, load it before installing any R libraries, and every time you use R.)\r\nmodule load apps\/gcc\/R\/incline2000-fix\r\n<\/pre>\n<p>The following versions were installed for the now-retired incline256 nodes. They may not run on the incline 2TB nodes (please try them.)<\/p>\n<p>If you have problems running any of the following versions, please consider using one of the above newer versions. You&#8217;ll need to reinstall any R libraries you&#8217;ve installed.<\/p>\n<pre># If these versions do not run on the upgraded iCSF nodes, we are unlikely to reinstall them.\r\n# Please move to a newer version of R (see above.) \r\nmodule load apps\/gcc\/R\/4.3.1\r\nmodule load apps\/gcc\/R\/4.1.3-gcc830 \r\nmodule load apps\/gcc\/R\/4.1.2-gcc830\r\nmodule load apps\/gcc\/R\/3.6.1-gcc830\r\nmodule load apps\/gcc\/R\/3.6.1\r\nmodule load apps\/gcc\/R\/3.6.0\r\nmodule load apps\/gcc\/R\/3.5.2\r\nmodule load apps\/gcc\/R\/3.4.2\r\nmodule load apps\/gcc\/R\/3.4.1\r\nmodule load apps\/gcc\/R\/3.3.3\r\nmodule load apps\/gcc\/R\/3.3.0\r\nmodule load apps\/gcc\/R\/3.2.3\r\nmodule load apps\/gcc\/R\/3.2.3-ambs\r\nmodule load apps\/gcc\/R\/3.2.0\r\nmodule load apps\/gcc\/R\/3.1.0         # Fixes a font problem in v3.0.2\r\nmodule load apps\/gcc\/R\/3.0.2\r\nmodule load apps\/gcc\/R\/2.15.3        # Rcmdr not available in this version\r\n<\/pre>\n<p>Microsoft R Open with MKL (this is an old version, we recommend the open source versions above.)<\/p>\n<pre>module load apps\/gcc\/MRO\/3.2.4\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>Having loaded the appropriate modulefile, simply run:<\/p>\n<pre>R\r\n\r\n# To ensure no previously save large objects are loaded, which might cause memory issues\r\n# from previous runs of R if you were processing a large dataset, use:\r\nR --no-restore-data\r\n\r\n# Or use --vanilla, which applies the following flags\r\n# --no-save, --no-restore, --no-site-file, --no-init-file and --no-environ\r\nR --vanilla\r\n<\/pre>\n<p>PLEASE NOTE: If more than one R module file is loaded it will default to the version which has been loaded most recently.<\/p>\n<p>You will now be at the R prompt.<\/p>\n<p>To exit R, type:<\/p>\n<pre>q()\r\n<\/pre>\n<p>To start the GUI, enter <code>library(Rcmdr)<\/code> at the R command line:<\/p>\n<pre>library(Rcmdr)\r\n\r\nLoading required package: tcltk\r\nLoading Tcl\/Tk interface ... done\r\n<\/pre>\n<p>If you are using Microsoft Open R then please note that you do not have exclusive access to iCSF compute nodes so it is highly recommended that you set:<\/p>\n<pre>export OMP_NUM_THREADS=4<\/pre>\n<p>to avoid the software trying to use the whole node and interfering with other people&#8217;s work.<\/p>\n<h2 id=\"addingpackages\">Adding packages<\/h2>\n<div class=\"note\">Check the section <strong><a href=\"#R_Project_Environments_renv\">R Project Environments (renv)<\/a><\/strong> below before trying to install any R packages. It will save you from lot of problems.<\/div>\n<p>Packages that provide extra functionality can be added to R by allowing R to save them in to your iCSF home directory. Packages can be downloaded automatically by R (if it can find the package associated with the library you are requesting) or you can supply a source package for R to unpack and install. The download method is preferred. Follow the instructions below:<\/p>\n<h3>Automatically Download from CRAN<\/h3>\n<p>To add packages that will be downloaded by R from the CRAN (cran.r-project.org):<\/p>\n<ol>\n<li>Check whether you have a <code>~\/.Renviron<\/code> file &#8211; it may contain some old, out-of-date proxy settings which need to be removed.\n<pre># Note: you may have old proxy settings in an ~\/.Renviron file. You'll need to remove these:\r\ncat ~\/.Renviron\r\n  #\r\n  # <strong>If you see the following, you do not need to do anything!<\/strong>\r\n  cat: .Renviron: No such file or directory\r\n\r\n  # <strong>If you see some lines containing<\/strong>\r\n  http_proxy=http:\/\/proxy.man.ac.uk:3128\r\n  https_proxy=https:\/\/proxy.man.ac.uk:3128\r\n    #\r\n    # <strong>DELETE these lines or place a # at the start of each line.<\/strong>\r\n\r\n  # <strong>If your ~\/.Renviron file contains <em>only<\/em> the above proxy lines<\/strong>\r\n  # <strong>you can delete the file<\/strong>\r\n  rm ~\/.Renviron\r\n<\/pre>\n<\/li>\n<li>Start R in the usual way (choose the version of R you require):\n<pre>module load apps\/gcc\/R\/3.2.0\r\nR\r\n<\/pre>\n<\/li>\n<li>Ask R to install the required package and answer <code>y<\/code> when asked if you wish to create a personal library:\n<pre>&gt; <strong>install.packages(\"thing\")<\/strong>\r\nWarning in install.packages(\"thing\") :\r\n'lib = \"\/opt\/gridware\/apps\/gcc\/R\/3.2.0\/lib64\/R\/library\"' is not writable\r\nWould you like to create a personal library\r\n~\/R\/x86_64-unknown-linux-gnu-library\/3.0\r\nto install packages into?  (y\/n) <strong>y<\/strong>\r\n<\/pre>\n<\/li>\n<li>Select a UK mirror when prompted.\n<ul>\n<li>Note, you may have to select a mirror name that does <strong>not<\/strong> have <code>[https]<\/code> next to it.<\/li>\n<\/ul>\n<\/li>\n<li>Then to use the package in R, load the library in R:\n<pre><strong>library(thing)<\/strong>\r\n<\/pre>\n<\/li>\n<\/ol>\n<h3>nloptr dependency<\/h3>\n<p>This problem does NOT occur in recent versions of R (e.g., 4.4.1.) If you do have a problem with R libraries not installing correctly, please read this section.<\/p>\n<p>Some packages fail to install because they depend on the <code>nloptr<\/code> R package. Trying to install that specific package often fails due to a dependency on the <code>nlopt<\/code> library, which R fails to compile. So we have provided this as a separate modulefile. For example:<\/p>\n<pre># <strong>This will fail due to a failure to compile nloptr<\/strong>\r\nmodule load apps\/gcc\/R\/4.3.1\r\nR\r\ninstall.packages(\"nloptr\")           # Other R packages that depend on this one will also fail\r\nq()\r\n\r\n# <strong>The solution is to load an extra modulefile:<\/strong>\r\nmodule load libs\/gcc\/nlopt\/2.7.1\r\nR\r\ninstall.packages(\"nloptr\")\r\n<\/pre>\n<h3>Rcpp dependency<\/h3>\n<p>This problem does NOT occur in recent versions of R (e.g., 4.4.1.) If you do have a problem with R libraries not installing correctly, please read this section.<\/p>\n<p>We&#8217;ve seen some R packages fail to install due to a failure in R to compile the <code>Rcpp<\/code> dependency.<\/p>\n<p>The solution was to do the <code>Rcpp<\/code> package first, then do the package you want to install. For example:<\/p>\n<pre># Install the lme4 packages, which requires nloptr and Rcpp:\r\nmodule load libs\/gcc\/nlopt\/2.7.1\r\nR\r\ninstall.packages(\"nloptr\")\r\ninstall.packages(\"Rcpp\")\r\ninstall.packages(\"lme4\")\r\n\r\n# Test\r\nlibrary(lme4)\r\nq()\r\n<\/pre>\n<p>In the above instructions replace the <code>module load<\/code> command with the one appropriate to the R version you wish to use.<\/p>\n<h3>Library from Source<\/h3>\n<p>If you&#8217;ve downloaded an R library source file you can add it to your local workspace using the following commands (which assume the source package is in your home directory on the iCSF):<\/p>\n<ol>\n<li>Start R with extra command-line args (choose the version of R you require):\n<pre>module load apps\/gcc\/R\/3.2.0\r\nR CMD INSTALL thing.x.y.z.tar.gz\r\n\r\n* installing to library \u2018\/mnt\/iusers01\/support\/mabcxyz1\/R\/x86_64-unknown-linux-gnu-library\/3.2\u2019\r\n* installing *source* package \u2018thing\u2019 ...\r\n** package \u2018thing\u2019 successfully unpacked and MD5 sums checked\r\n** R\r\n** data\r\n** demo\r\n** preparing package for lazy loading\r\n** help\r\n*** installing help indices\r\n** building package indices\r\n** testing if installed package can be loaded\r\n* DONE (thing)\r\n<\/pre>\n<p>Alternatively,<\/p>\n<pre>module load apps\/gcc\/R\/4.3.1\r\nR\r\npackageurl &lt;- \"https:\/\/cran.ma.imperial.ac.uk\/src\/contrib\/Archive\/nloptr\/nloptr_1.2.1.tar.gz\";  install.packages(packageurl, repos=NULL, type=\"source\");\r\ninstall.packages('lme4')\r\n<\/pre>\n<\/li>\n<li>Now run R and test that the library can be loaded:\n<pre>R\r\n&gt; library(thing)\r\n<\/pre>\n<\/li>\n<\/ol>\n<p>The compiled library files will be save in a directory named <code>R<\/code> in your home directory. <strong>It contains subdirectories for each version of R so if you want to use the library in different versions of R you will have to repeat the above commands for each version.<\/strong><\/p>\n<p><a name=\"bioc\"><\/a><\/p>\n<h3>Adding BioConductor Packages &#8211; R 3.6.0 and newer<\/h3>\n<p>Note: This is NOT the method used for <em>older<\/em> versions of R (3.5 and older). See below for that.<\/p>\n<p>The &#8216;manager&#8217; for bioconductor has changed in version 3.6.0. Details are given here on how to install BioConductor packages in R 3.6.0 (and up). Please also check the <a href=\"https:\/\/www.bioconductor.org\/install\/\">BioConductor installation instructions<\/a> at their website for up-to-date version information.<\/p>\n<pre># Load your version of R...\r\nmodule load apps\/gcc\/R\/4.4.2\r\n\r\n# Start R\r\nR\r\n\r\n# If we haven't yet installed BiocManager, install it now\r\n# Select from a UK Mirror when prompted (e.g., the UK Bristol mirror)\r\nif (!require(\"BiocManager\", quietly = TRUE))\r\n    install.packages(\"BiocManager\")\r\n\r\n# Check the BiocManager version\r\nBiocManager::version()\r\n\r\n# See what is installed (this can be a long list!)\r\nBiocManager::available()\r\n\r\n# Install everything to your home directory\r\nBiocManager::install()\r\n# OR Install a package to your home directory\r\nBiocManager::install(c(\"<em>esATAC<\/em>\"))\r\n                           #\r\n                           # Use the name of the package you want to install.\r\n                           #\r\n                           # You will be prompted to install to a local directory\r\n                           # (i.e., your <em>home<\/em> directory) as shown below.\r\n\r\n### Select from a UK Mirror when prompted (e.g., the UK Bristol mirror)\r\n\r\nBioconductor version 3.9 (BiocManager 1.30.4), R 3.6.0 (2019-04-26)\r\nInstalling package(s) 'esATAC'\r\nWarning in install.packages(pkgs = doing, lib = lib, repos = repos, ...) :\r\n  'lib = \"\/opt\/gridware2\/el7\/apps\/gcc\/R\/3.6.0\/lib64\/R\/library\"' is not writable\r\nWould you like to use a personal library instead? (yes\/No\/cancel) <strong>y<\/strong>   # <strong>Answer 'y'<\/strong>\r\nWould you like to create a personal library\r\n\u2018~\/R\/x86_64-pc-linux-gnu-library\/3.6\u2019\r\nto install packages into? (yes\/No\/cancel) <strong>y<\/strong>                           # <strong>Answer 'y'<\/strong>\r\n<\/pre>\n<p>See <a href=\"#usingbioc\">below<\/a> for how to then use (load) an installed BioConductor package.<\/p>\n<h3>Adding BioConductor Packages &#8211; R 3.5 and earlier<\/h3>\n<p>Note: This is NOT the method used for newer versions of R (3.6 and newer). See above for that.<\/p>\n<p>BioConductor packages or packages that rely on bioconductor packages can be installed in to your local R library (in your home directory) as follows (this example assumes use of R 3.2.0):<\/p>\n<ol>\n<li>Check whether you have a <code>~\/.Renviron<\/code> file &#8211; it may contain some old, out-of-date proxy settings which need to be removed.\n<pre># Note: you may have old proxy settings in an ~\/.Renviron file. You'll need to remove these:\r\ncat ~\/.Renviron\r\n  #\r\n  # <strong>If you see the following, you do not need to do anything!<\/strong>\r\n  cat: .Renviron: No such file or directory\r\n\r\n  # <strong>If you see some lines containing<\/strong>\r\n  http_proxy=http:\/\/proxy.man.ac.uk:3128\r\n  https_proxy=https:\/\/proxy.man.ac.uk:3128\r\n    #\r\n    # <strong>DELETE these lines or place a # at the start of each line.<\/strong>\r\n\r\n  # <strong>If your ~\/.Renviron file contains <em>only<\/em> the above proxy lines<\/strong>\r\n  # <strong>you can delete the file<\/strong>\r\n  rm ~\/.Renviron\r\n<\/pre>\n<\/li>\n<li>Now load a version of R that has bioconductor installed, e.g.\n<pre>module load apps\/gcc\/R\/3.2.0\r\n<\/pre>\n<\/li>\n<li>Start R in the usual way and tell it you need to use <code>BiocInstaller<\/code>\n<pre>&gt; require('BiocInstaller')\r\nLoading required package: BiocInstaller\r\nBioconductor version 3.1 (BiocInstaller 1.18.1), ?biocLite for help\r\n<\/pre>\n<\/li>\n<li>Next install the required packages\n<pre>&gt; biocLite(c(\"WGCNA\"))\r\n<\/pre>\n<p>and when it asks if you want to use a personal library answer <code>y<\/code><\/p>\n<pre>Would you like to use a personal library instead?  (y\/n) y\r\ntrying URL 'http:\/\/bioconductor.org\/packages\/3.1\/bioc\/src\/contrib\/BiocInstaller_1.18.5.tar.gz'\r\nContent type 'application\/x-gzip' length 14977 bytes (14 KB)\r\n==================================================\r\ndownloaded 14 KB\r\n\r\n* installing *source* package \u2018BiocInstaller\u2019 ...\r\n** R\r\n** inst\r\n** preparing package for lazy loading\r\n** help\r\n*** installing help indices\r\n** building package indices\r\n** testing if installed package can be loaded\r\nBioconductor version 3.1 (BiocInstaller 1.18.5), ?biocLite for help\r\nA newer version of Bioconductor is available for this version of R,\r\n  ?BiocUpgrade for help\r\n* DONE (BiocInstaller)\r\n\r\nThe downloaded source packages are in\r\n\t\u2018\/tmp\/RtmpMwCszR\/downloaded_packages\u2019\r\nBioconductor version 3.1 (BiocInstaller 1.18.5), ?biocLite for help\r\nA newer version of Bioconductor is available for this version of R,\r\n  ?BiocUpgrade for help\r\n'BiocInstaller' updated to version 1.18.5\r\nBioC_mirror: http:\/\/bioconductor.org\r\nUsing Bioconductor version 3.1 (BiocInstaller 1.18.5), R version 3.2.0.\r\nInstalling package(s) \u2018WGCNA\u2019\r\nalso installing the dependencies \u2018impute\u2019, \u2018GO.db\u2019\r\n\r\n------- SNIP ------\r\n<\/pre>\n<\/li>\n<li>It should install any dependencies that are missing. At the end it may ask if you want to update some other\/old packages &#8211; say <code>n<\/code> as most of them will be part of the central install which you do not have permission to change.\n<pre>------- SNIP ------\r\n* DONE (WGCNA)\r\n\r\nThe downloaded source packages are in\r\n\t\u2018\/tmp\/RtmpMwCszR\/downloaded_packages\u2019\r\nOld packages: 'abind', 'annotate', 'base64', 'BiocInstaller', 'BiocParallel',\r\n  'biomaRt', 'Biostrings', 'boot', 'car', 'class', 'cluster', 'codetools',\r\n  'DBI', 'digest', 'e1071', 'edgeR', 'effects', 'evaluate', 'foreach',\r\n  'foreign', 'formatR', 'futile.logger', 'GenomeInfoDb', 'GenomicAlignments',\r\n  'GenomicFeatures', 'GenomicRanges', 'ggplot2', 'gridExtra', 'gtable',\r\n  'highr', 'Hmisc', 'IRanges', 'iterators', 'KernSmooth', 'knitr', 'lambda.r',\r\n  'lattice', 'latticeExtra', 'limma', 'lme4', 'lmtest', 'MASS', 'Matrix',\r\n  'matrixStats', 'mclust', 'mgcv', 'mime', 'multcomp', 'munsell', 'mvtnorm',\r\n  'nlme', 'nnet', 'nor1mix', 'plyr', 'quantreg', 'Rcmdr', 'RcmdrMisc', 'Rcpp',\r\n  'RcppEigen', 'RCurl', 'registry', 'relimp', 'rgl', 'rJava', 'RODBC', 'rpart',\r\n  'Rsamtools', 'rtracklayer', 'ruv', 'S4Vectors', 'sandwich', 'scales', 'sem',\r\n  'snow', 'SparseM', 'spatial', 'statmod', 'stringi', 'survival', 'TH.data',\r\n  'XLConnect', 'XLConnectJars', 'XML', 'xtable', 'zoo'\r\nUpdate all\/some\/none? [a\/s\/n]: n\r\n<\/pre>\n<\/li>\n<li>Test you can load the package\n<pre>library(\"WGCNA\")\r\n<\/pre>\n<\/li>\n<\/ol>\n<p><a name=\"usingbioc\"><\/a><\/p>\n<h3>Using BioConductor Packages<\/h3>\n<p>BioConductor packages have to be loaded like any other package if you&#8217;ve previously installed them. For example, assuming you have installed a BioConductor package named <code>bioThing<\/code>, to use it in your code use:<\/p>\n<pre># Load\/use a BioConductor package named 'bioThing' previously installed\r\nlibrary(bioThing)\r\n<\/pre>\n<h3>Listing Packages<\/h3>\n<p>To list the installed packages run:<\/p>\n<pre>installed.packages();\r\n<\/pre>\n<p>To list loaded packages run:<\/p>\n<pre>(.packages())\r\n<\/pre>\n<p><a name=\"R_Project_Environments_renv\"><\/a><\/p>\n<h2>R Project Environments (<a href=\"https:\/\/rstudio.github.io\/renv\/\" target=\"_blank\" rel=\"noopener\">renv<\/a>)<\/h2>\n<p>We advice using <strong>&#8216;renv&#8217;<\/strong> to install R packages that you need. The <strong>renv<\/strong> package helps you create conflict free reproducible environments for your R projects. Using renv you can maintain separate project folder with their own set of R packages and they will not conflict with other R packages in other renv project folders or R modules. This is somewhat similar to using conda virtual environments. Benefit of using renv includes:<\/p>\n<ol>\n<li><strong>Isolation:<\/strong> Installing a new or updated package for one pipeline will not break your other projects\/piplelines, and vice versa. That\u2019s because renv gives each project its own private library. You can have separate isolated project directory for each of your work\/pipelines with its own sets of packages.<\/li>\n<li><strong>Portability:<\/strong> You can easily transport your projects from one cluster\/computer to another, even across different platforms. renv makes it easy to install the packages your project depends on in the new environment.<\/li>\n<li><strong>Reproducibility:<\/strong> renv records the exact package versions you have installed in a project. This helps in ensuring those exact versions are installed wherever you want to move your work to.<\/li>\n<\/ol>\n<p>The main steps involved are:<\/p>\n<ol>\n<li>Create a separate directory for each of your projects\/pipelines and move (cd) to that directory. If you are accessing multiple servers\/clusters from the same home directory and you are using different R modules for them, it is important that you use <code>renv<\/code> for your projects\/pipelines to avoid conflicts.<\/li>\n<li>Load appropriate R module as per your requirement. It is advisable to use the latest R module available for your system as packages of older versions are not always maintained in the CRAN repositories.<\/li>\n<li>Start R<\/li>\n<li>Install &#8216;renv&#8217; package.<\/li>\n<li>Initialize renv. This will set up a project library. Following files and folder are created in that directory at the time of initialization, which record the packages and the metadata needed to <em>reinstall<\/em> them at any point: <code>renv.lock<\/code>, .Rprofile and <code>renv<\/code>.<br \/>\nThese files and folders should not be altered. You can see them when you exit R and run the command <code><strong>ls -al<\/strong><\/code> from that directory later.<\/li>\n<li>Quit\/Exit R. This is IMPORTANT, you need to quit\/exit R after you have initialized <code>renv<\/code> for the first time after installation.<\/li>\n<li>Start R again from the same directory.<\/li>\n<li>Install any required R package(s).<\/li>\n<li>Create a snapshot of the installation.<\/li>\n<li>Create a text file and add information like the platform\/server the project was created and the R and other modules that were used, inside the project folder for your future reference.<\/li>\n<li>If needed, repeat the same steps for a different project\/pipleline requiring different sets of packages in a separate directory.<\/li>\n<li>To run a package installed within a specific project created like this please see <a href=\"#run_renv_packages\">below<\/a>:<\/li>\n<\/ol>\n<p>Here are the commands needed to perform the steps described above.<br \/>\nIn this example we will install only the <code>BiocManager<\/code> package in this renv R Project folder, but you can install as many packages you need in a project.<\/p>\n<pre># Create a new directory for our R project\r\nmkdir ~\/MyFirstRProject\r\n\r\n# Go into that directory. This will become our working renv project, once we've finished the setup\r\ncd ~\/MyFirstRProject\r\nmodule load apps\/gcc\/R\/4.4.2\r\nR\r\ninstall.packages(\"renv\")\r\n   # Select the preferred CRAN mirror from the presented list (e.g., Bristol)\r\nrenv::init()\r\n# We now quit R. We'll start it again soon!\r\nq()\r\nn\r\n\r\n# At this point we've exited R and are now back at the CSF login-node prompt.\r\nls -al\r\n\r\n# Start R again - it will now see that we're working in an renv project\r\nR\r\n\r\n# Run commands to install additional R packages if needed (here we install BioCManager)\r\ninstall.packages(\"BiocManager\")\r\nY\r\n# Save the state of our project\r\nrenv::snapshot()\r\n# To exit back to the login node prompt\r\nq()\r\nn\r\n\r\n# At this point we've exited R and are now back at the CSF login-node prompt.\r\n# We create a description of this R project, for our own future reference.\r\ngedit README.txt       # Or use an editor such as nano\r\n------------------------------------------------------------\r\n| Project Platform: iCSF                                   |\r\n| Project directory location: ~\/MyFirstRProject            |\r\n| Modules used: apps\/gcc\/R\/4.4.2                           |\r\n| Packages Installed: BiocManager                          |\r\n------------------------------------------------------------\r\n<\/pre>\n<p>That&#8217;s it, we&#8217;ve now created our first <code>renv<\/code> project in a new folder.<\/p>\n<h3 id=\"run_renv_packages\">Running a package installed in a &#8216;renv&#8217; project<\/h3>\n<p>For running \/ using the packages installed in a &#8216;renv&#8217; project folder, or to add more packages, you need to do the following:<\/p>\n<pre>cd ~\/MyFirstRProject              # Use the name of your project folder\r\nmodule load apps\/gcc\/R\/4.4.2      # Use the same version as when you created the renv project\r\n                                  # If you wrote the README.txt file (see above), try:\r\n                                  # cat README.txt to read it.\r\nR                                 # Run R\r\n<\/pre>\n<p>You can then load and run your R package or R CMD SCRIPT.<\/p>\n<h2 id=\"hints\">Hints and Tips (let us know yours)<\/h2>\n<h3>Plotting Graphs and Graphics<\/h3>\n<p>To see the available graphics file formats support, run the <code>capabilities()<\/code> function in R. Note that newer versions of R (e.g., 3.6.0-gcc830) have more graphics formats supported &#8211; we recommend you use the latest version of R available on the iCSF:<\/p>\n<pre>ssh <em>username<\/em>@incline2000.itservices.manchester.ac.uk\r\n[mabcxyz1@incline31 ~]$ module load apps\/gcc\/R\/3.6.1-gcc830\r\n[mabcxyz1@incline31 ~]$ R\r\n&gt; capabilities()\r\n       jpeg         png        tiff       tcltk         X11        aqua \r\n       TRUE        TRUE       TRUE        TRUE        TRUE       FALSE \r\n<\/pre>\n<p>The following example generates a histogram and plots it to a <code>.png<\/code> file and a <code>.jpg<\/code> file. It has been tested on the <code>incline256<\/code> nodes.<\/p>\n<pre># R script to demonstrate plotting to image files on the iCSF\r\n\r\n# Enable cairo device - <strong>MAC USER: THIS MIGHT FIX SOME FONT PROBLEMS.<\/strong>\r\noptions(bitmapType='cairo')\r\n\r\n# Initialize some data to plot\r\nx = rnorm(100)\r\n\r\n# Save a png plot\r\npng(file=\"hist.png\")\r\nhist(x)\r\nrug(x,side=1)\r\ndev.off()\r\n\r\n# How about jpg\r\njpeg(file=\"hist.jpg\")\r\nhist(x)\r\nrug(x,side=1)\r\ndev.off()\r\n\r\n# R 3.6.1 can also do tiff\r\ntiff(file=\"hist.tif\")\r\nhist(x)\r\nrug(x,side=1)\r\ndev.off()\r\n\r\n# Exit\r\nq();\r\n<\/pre>\n<p>Now to view your images while on the iCSF, use the <em>eye of gnome<\/em> (<code>eog<\/code>) image viewer:<\/p>\n<pre># List the image files created by the above example\r\nls hist.*\r\nhist.jpg  hist.png  hist.tif\r\n\r\n# Use the image viewer name 'eog' (Eye of Gnome)\r\neog hist.png\r\n<\/pre>\n<p>If you need other image file formats you can then convert your PNG file using the <code>convert<\/code> command-line tool, available on the login node or can be run in your jobscript (note that <code>convert<\/code> is a linux command-line program, not an R function):<\/p>\n<pre># Using the hist.png example file from the above R script, convert it to another format:\r\nconvert hist.png hist.tif      # R 3.6.1 can write tif files directly (see above) but older versions can't\r\n\r\n# How about a .pdf\r\nconvert hist.png hist.pdf\r\n\r\n# View the PDF file\r\nevince hist.pdf\r\n<\/pre>\n<p>Another example of plotting to file:<\/p>\n<pre>png(file = \"myplot.png\", bg = \"transparent\")\r\nplot(1:10)\r\nrect(1, 5, 3, 7, col = \"white\")\r\ndev.off()\r\n\r\n## will make myplot1.jpeg and myplot2.jpeg\r\njpeg(file = \"myplot%d.jpeg\")\r\nexample(rect)\r\ndev.off()\r\n<\/pre>\n<h3>Adobe Helvetica Font Problem<\/h3>\n<p>If you see the following error when using <code>ggplot2<\/code>,<\/p>\n<pre>Error in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) : \r\n  X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 9 could not be loaded\r\n<\/pre>\n<p>please try to use the <code>showtext<\/code> package as follows:<\/p>\n<pre>install.packages(showtext)\r\nlibrary(showtext)\r\nshowtext_auto()\r\n\r\nlibrary(ggplot2)\r\ntest_data &lt;- data.frame(x=rnorm(100),y=rnorm(100))\r\nggplot(test_data, aes(x=x, y=y)) + ggtitle(\"test plot\")\r\n<\/pre>\n<h2>Further info<\/h2>\n<p>For software documentation and FAQs please consult the <a href=\"http:\/\/www.r-project.org\/\">R Project website<\/a>.<\/p>\n<p>See also the <a href=\"http:\/\/www.bioconductor.org\/\">Bioconductor website<\/a>.<\/p>\n<h2>Updates<\/h2>\n<p>September 2025 &#8211; v4.5.1 added<br \/>\nAugust 2024 &#8211; Only the 2TB nodes remain and have been upgraded to an EL9 O\/S. R 4.4.x versions installed. Older versions may not run.<br \/>\nAugust 2017 &#8211; v3.4.1 added<br \/>\nJuly 2016 &#8211; a version of rjava has been compiled for R version 3.3.0 and has all the java environment variables automatically set. It can be accessed using:<code>module load apps\/gcc\/rjava\/0.9.8-R3.3.0<\/code>.<br \/>\n29.01.2016 &#8211; v3.2.3-ambs added including the packages: ggplot2, randomForest, dplyr, party, DataCombine, Imtest, Foreign, Hmisc, lattice, survival, Formula.<br \/>\n29.01.2016 &#8211; v3.2.3 added<br \/>\n11 May 2015 &#8211; v3.2.0 added<br \/>\n9-June-2014 &#8211; v3.1.0 added<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview R is a free software environment for statistical computing and graphics. incline2000 From 1st Aug 2024, the only nodes in the iCSF are the 2TB nodes, which received an operating system upgrade. Following this upgrade, some of the older versions of R (and Rstudio) may not run. We strongly encourage all users to move to the newer versions of R (see below), which have been built for the new operating system on the iCSF&#8230; <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/r\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":43,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-47","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":26,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/47\/revisions"}],"predecessor-version":[{"id":1523,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/47\/revisions\/1523"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/43"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/media?parent=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}