Resolving GNU MP not found on CentOS 7

If you are installing package like BiocManager::install(“scDblFinder”)

BiocManager::install("scDblFinder")

You may encounters error like

configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org

The fix is obvious as seen on error message. If you are using CentOS 7, you can easily fix it via Yum

% yum install gmp-devel

Compiling R-4.1.0 with GNU

The R Project for Statistical Computing

Prerequisites

gnu-6.5
m4-1.4.18
gmp-6.1.0
mpfr-3.1.4
mpc-1.0.3
isl-0.18
gsl-2.1

Compiling PCRE is important or you will face an error like

configure: error: PCRE2 library and headers are required, or use --with-pcre1 and PCRE >= 8.32 with UTF-8 support

After you have compile PCRE, you can proceed with the compilation of R-4.1.0

% ./configure --prefix=/usr/local/R-4.1.0 --with-pcre1=/usr/local/pcre-8.42 --with-blas --with-lapack --enable-R-shlib

If there are no issues….

R is now configured for x86_64-pc-linux-gnu

  Source directory:            .
  Installation directory:      /usr/local/R-4.1.0

  C compiler:                  gcc  -g -O2
  Fortran fixed-form compiler: gfortran  -g -O2

  Default C++ compiler:        g++ -std=gnu++14  -g -O2
  C++11 compiler:              g++ -std=gnu++11  -g -O2
  C++14 compiler:              g++ -std=gnu++14  -g -O2
  C++17 compiler:
  C++20 compiler:
  Fortran free-form compiler:  gfortran  -g -O2
  Obj-C compiler:              gcc -g -O2 -fobjc-exceptions

  Interfaces supported:        X11
  External libraries:          pcre1, readline, BLAS(generic), LAPACK(generic), curl
  Additional capabilities:     PNG, JPEG, NLS, ICU
  Options enabled:             shared R library, R profiling

  Capabilities skipped:        TIFF, cairo
  Options not enabled:         shared BLAS, memory profiling

  Recommended packages:        yes

Make and Make Install the Files

% make -j 8
.....
gcc -I"/home/user1/Downloads/R-4.1.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c anova.c -o anova.o
gcc -I"/home/user1/Downloads/R-4.1.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c anovapred.c -o anovapred.o
gcc -I"/home/user1/Downloads/R-4.1.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c branch.c -o branch.o
gcc -I"/home/user1/Downloads/R-4.1.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c bsplit.c -o bsplit.o
gcc -I"/home/user1/Downloads/R-4.1.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c choose_surg.c -o choose_surg.o
g
.....
% make install

References:

  1. Compiling R by Toby Dylan

Configuring External libraries for R-Studio for CentOS 7

RStudio can be configured by adding entries to 2 configuration files. It may not exist by default and you may need to create

/etc/rstudio/rserver.conf
/etc/rstudio/rsession.conf

If you need to add additional libraries to the default LD_LIBRARY_PATH for R sessions. You have to add the parameters to the /etc/rstudio/rserver.conf

Step 1: Enter External Libraries settings
For example, you may want to add GCC-6.5 libraries

# Server Configuration File
rsession-ld-library-path=/usr/local/gcc-6.5.0/lib64:/usr/local/gcc-6.5.0/lib

Step 2a: Stop the R Server Services

# /usr/sbin/rstudio-server stop

Step 2b: Verify the Installation

# rstudio-server verify-installation

Step 2c: Start the R Server Services

# /usr/sbin/rstudio-server start
# /usr/sbin/rstudio-server status

(Make sure there is no error)

References:

  1. RStudio Server: Configuring the Server

 

Installing DiffBind for R-3.6.2

To Install DiffBind, you can follow the instruction found at DiffBind

First thing first, you would need to install BiocManager and then install DiffBand

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("DiffBind")

At the end, you should get

To view Documentation,

browseVignettes("DiffBind")

 

Installing the Seurat Package on R-3.6.2

Step 1: Compiling R on CentOS 7

a. Download R Package from https://cran.r-project.org/

b. Untar and Compile the R-Package

$ tar -zxvf R-3.6.2.tar.gz
$ cd R-3.6.2
$ ./configure --prefix=/home/myuser/R-3.6.2
$ make
$ make install

Step 2: Compile multtest package
Seurat is dependent on mulltest. But if you try installing muttest using R, you will have this error.

$ cd /home/myuser/R-3.6.2
$ ./R
install.packages("multtest")
Warning message:
package ‘multtest’ is not available (for R version 3.6.2)

To solve the issue, you have to install BiocManager first and use BiocManager to install mulltest

install.packages("BiocManager")
BiocManager::install("multtest")

Step 3: Finally, you can install Seurat

install.packages("Seurat")

References:

    1. Resampling-based multiple hypothesis testing

 

Installing rgdal_1.4-8.tar.gz with R-3.6.0 on CentOS 7

I tried installing rgdal_1.4.8.tar.gz with R-3.6.0  and there were a number of issues. Even though I have followed and installed according to “Compile gdal-2.4.3 on CentOS 7” I have the follow error.

Issue 1: Error: Proj.h not found in standard or given locations

.....
.....
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking GDAL version <= 2.5.0... yes
checking gdal: linking with --libs only... yes
checking GDAL: gdal-config data directory readable... yes
checking GDAL: /usr/local/gdal-2.4.3/share/gdal/pcs.csv readable... yes
checking proj_api.h presence and usability... no
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgdal’
.....

Apparently R is not able to find inside pkconfig for proj.pc file. To resolve it, do the following to your ~.bashrc environment.

export PKG_CONFIG_PATH=/usr/local/proj-5.2.0/lib/pkgconfig

You can verify by using the command

# pkg-config proj --libs
-L/usr/local/proj-5.2.0/lib -lproj

You can get more information via the thread proj_api.h not found in standard or given locations #1092

Issue 2: Proj_LIB Path Issues

.....
checking proj_api.h presence and usability... yes
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
checking PROJ.4: epsg found and readable... no
Error: proj/epsg not found
Either install missing proj support files, for example
the proj-nad and proj-epsg RPMs on systems using RPMs,
or if installed but not autodetected, set PROJ_LIB to the
correct path, and if need be use the --with-proj-share=
configure argument.
ERROR: configuration failed for package ‘rgdal’
.....

To resolve the PROJ_LIB Issue

export PROJ_LIB=/usr/local/proj-5.2.0/share/proj

You can more information from https://github.com/r-spatial/lwgeom/issues/28

Finally, you should be able to compile rgdal_1.4-8.tar.gz with R-3.6.0

# R CMD INSTALL rgdal_1.4-8.tar.gz
.....
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgdal)
.....

Final Step: Testing and Verification

Load both gdal and proj libaries. Make sure you have compile gdal and proj libraries using the tutorial Compile gdal-2.4.3 on CentOS 7

$ module load proj/5.2.0
$ module load R/3.6.0
$ module load gdal/2.4.3
$ R
library(rgdal)
Loading required package: sp
rgdal: version: 1.4-8, (SVN revision 845)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 2.4.3, released 2019/10/28
Path to GDAL shared files: /usr/local/gdal-2.4.3/share/gdal
GDAL binary built with GEOS: FALSE
Loaded PROJ.4 runtime: Rel. 5.2.0, September 15th, 2018, [PJ_VERSION: 520]
Path to PROJ.4 shared files: /usr/local/proj-5.2.0/share/proj
Linking to sp version: 1.3-2

 

Compiling R-3.4.2 on CentOS 6 with GNU

If you are compiling CentOS 6, you will notice that the R source will not compile without a updated version of zlib, pcre, bzip2. libcurl. There is a very good site on how to compile R on Red Hat Linux

Step 1: Compile R-3.4.2

Download R-3.4.2 from The R Project for Statistical Computing

$ tar -zxvf R-3.4.2.tar.gz
$ ./configure --prefix=/usr/local/RH6_apps/R-3.4.2

During configuring…. error surfaced.

checking for zlib.h... yes
checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required

Step 2: Compile zlib 1.2.11

a. In your .bashrc

export CFLAGS="-I/usr/local/zlib-1.2.11/include"
export LDFLAGS="-L/usr/local/zlib-1.2.11/lib"

b. Compile zlib-1.2.11

$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11
$ cd zlib-1.2.11
$ configure --prefix=/usr/local/zlib-1.2.11

Step 3: Compile bzip2
a. Download the bzip2

$ wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
$ tar xzvf bzip2-1.0.6.tar.gz
$ cd bzip2-1.0.6

b. Compile bzip2

$ make -f Makefile-libbz2_so
$ make clean
$ make -n install PREFIX=/usr/local/R-3.4.2
$ make install PREFIX=/usr/local/R-3.4.2

Step 4: Compile liblzma or xz

$ wget http://tukaani.org/xz/xz-5.2.3.tar.gz --no-check-certificate
$ tar xzvf xz-5.2.3.tar.gz
$ cd xz-5.2.3
$ ./configure --prefix=/usr/local/xz-5.2.3
$ make -j8
$ make install

Step 5: Compile pcre-8.40

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
$ tar xzvf pcre-8.40.tar.gz
$ ./configure --prefix=/usr/local/pcre-8.40
$ make -j 8
$ make install

Step 6: Compile libcurl-7.47.1

$ wget  https://curl.haxx.se/download/curl-7.47.1.tar.gz --no-check-certificate
$ tar xzvf curl-7.47.1.tar.gz
$ cd curl-7.47.1
$ ./configure --prefix=/usr/local/curl-7.47.1
$ make -j 8
$ make install

Step 7: Update CFLAGS and LDFLAGS

export CFLAGS="-I/usr/local/zlib-1.2.11/include -I/usr/local/bzip2-1.0.6/include -I/usr/local/xz-5.2.3/include -I/usr/local/pcre-8.40/include -I/usr/local/curl-7.47.1/include/curl"
export LDFLAGS="-L/usr/local/zlib-1.2.11/lib -L/usr/local/bzip2-1.0.6/lib -L/usr/local/xz-5.2.3/lib -L/usr/local/pcre-8.40/lib -L/usr/local/curl-7.47.1/lib"

Step 8: Compile R-3.4.2

$ ./configure --enable-utf8 --prefix=/usr/local/R-3.4.2
$ make -j 8
$ make install

References:

  1. Building R-devel on RedHat Linux 6

Compiling R-3.0.2 on CentOS 5

Do note that R-3.0.2 requires a higher version of gfortran 4.4.4 and above. To help ensure that the gfortran44 is installed, do check that the gnu44 are installed. For more information how to install, see Installing GNU 4.4 of C, C++ and gfortran for CentOS 5

Compiling R-3.0.2

# tar -zxvf 3.0.2.tar.gz 
# ./configure --prefix=/usr/local/R-3.0.2/ CC=gcc44 CXX=g++44 F77=gfortran44 FC=gfortran44
# make
# make install