diff --git a/.github/workflows/onlabel_Fedora_setup.yml b/.github/workflows/Fedora_setup.yml similarity index 55% rename from .github/workflows/onlabel_Fedora_setup.yml rename to .github/workflows/Fedora_setup.yml index 56047282a..1dfba6136 100644 --- a/.github/workflows/onlabel_Fedora_setup.yml +++ b/.github/workflows/Fedora_setup.yml @@ -44,13 +44,12 @@ jobs: - name: install config and build dependencies run: | - dnf -y install pkg-config - dnf -y install cmake - dnf -y install R-devtools + dnf -y install libcurl-devel # needed for pak - - name: install GSL + - name: install pak run: | - dnf -y install gsl-devel + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) + shell: Rscript {0} - name: install JAGS run: | @@ -73,38 +72,16 @@ jobs: library("rjags") shell: Rscript {0} - - name: install INLA dependencies - run: | - dnf -y install udunits2-devel - dnf -y install libcurl-devel # rCurls package (for INLA) - dnf -y install openssl-devel # s2 package - dnf -y install libjpeg-devel # jpeg package - dnf -y install proj-devel # sf package - dnf -y install geos-devel # sf package - dnf -y install gdal-devel # terra package - - - name: install INLA - run: | - install.packages("INLA", repos = c(CRAN = "https://cran.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - shell: Rscript {0} - - - name: installing dependencies from BiocManager - run: | - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager", repos=c(CRAN="https://cran.r-project.org")) - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - shell: Rscript {0} - - - name: install from CRAN - run: | - install.packages('abn', repos=c(CRAN="https://cran.r-project.org")) - library('abn') - shell: Rscript {0} + # - name: install from CRAN with pak + # run: | + # pak::pkg_install('abn', dependencies=TRUE) + # library('abn') + # shell: Rscript {0} - - name: install from GitHub + - name: pak install from GitHub run: | - devtools::install_github("furrer-lab/abn", ref="${{ env.BRANCH }}", dependencies=c("Depends", "Imports", "LinkingTo"), local=FALSE) + pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") + pak::pkg_install("furrer-lab/abn@${{ env.BRANCH }}", dependencies=TRUE) library('abn') shell: Rscript {0} @@ -118,7 +95,5 @@ jobs: - name: install from source run: | - devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never', repos=c(CRAN="https://cran.r-project.org")) - devtools::build(pkg = '.', path = '${{ env.BUILD_LOC }}/abn.tar.gz', vignettes = FALSE) - install.packages('${{ env.BUILD_LOC }}/abn.tar.gz', repos=NULL, type="source") + pak::local_install(dependencies=TRUE) shell: Rscript {0} diff --git a/.github/workflows/onlabel_Macos_setup.yml b/.github/workflows/Macos_setup.yml similarity index 60% rename from .github/workflows/onlabel_Macos_setup.yml rename to .github/workflows/Macos_setup.yml index 1b7027d9d..e8e0dd8d7 100644 --- a/.github/workflows/onlabel_Macos_setup.yml +++ b/.github/workflows/Macos_setup.yml @@ -39,11 +39,11 @@ jobs: run: | brew install jags - - name: install rjags - run: | - install.packages("rjags", type="source", repos=c(CRAN="https://cran.r-project.org")) - library("rjags") - shell: Rscript {0} + # - name: install rjags + # run: | + # install.packages("rjags", type="source", repos=c(CRAN="https://cran.r-project.org")) + # library("rjags") + # shell: Rscript {0} - name: install INLA dependencies run: | @@ -58,23 +58,21 @@ jobs: install.packages("INLA", repos = c(CRAN = "https://cran.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) shell: Rscript {0} - - name: installing dependencies from BiocManager + - name: install pak run: | - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager", repos=c(CRAN="https://cran.r-project.org")) - BiocManager::install("Rgraphviz") - BiocManager::install("graph") + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) shell: Rscript {0} - - name: install from CRAN - run: | - install.packages('abn', repos=c(CRAN="https://cran.r-project.org")) - library('abn') - shell: Rscript {0} + # - name: install from CRAN with pak + # run: | + # pak::pkg_install('abn', dependencies=TRUE) + # library('abn') + # shell: Rscript {0} - - name: install from GitHub + - name: pak install from GitHub run: | - devtools::install_github("furrer-lab/abn", ref="${{ env.BRANCH }}", dependencies=c("Depends", "Imports", "LinkingTo"), local=FALSE) + pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") + pak::pkg_install("furrer-lab/abn@${{ env.BRANCH }}", dependencies=TRUE) library('abn') shell: Rscript {0} @@ -88,7 +86,5 @@ jobs: - name: install from source run: | - devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never', repos=c(CRAN="https://cran.r-project.org")) - devtools::build(pkg = '.', path = '${{ env.BUILD_LOC }}/abn.tar.gz', vignettes = FALSE) - install.packages('${{ env.BUILD_LOC }}/abn.tar.gz', repos=NULL, type="source") + pak::local_install(dependencies=TRUE) shell: Rscript {0} diff --git a/.github/workflows/Ubuntu_setup.yml b/.github/workflows/Ubuntu_setup.yml new file mode 100644 index 000000000..08596207c --- /dev/null +++ b/.github/workflows/Ubuntu_setup.yml @@ -0,0 +1,77 @@ +# Workflow is triggered on label and check installation on various operating systems +# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning +name: Ubuntu Install + +on: + push: + branches: + - "main" + +env: + BRANCH: ${{ github.head_ref || github.ref_name }} + +permissions: + packages: read + contents: write + pull-requests: write + repository-projects: write + +jobs: + setup-and-install: + runs-on: ubuntu-latest + name: ubuntu-latest R release + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + + - name: Update and upgrade + run: | + sudo apt-get update && sudo apt-get upgrade + + - name: install R + run: | + sudo apt-get -y install r-base + + - name: fixing folder perms for local lib + run: | + sudo chown root:adm -R /usr/lib/R + sudo chmod g+w -R /usr/lib/R + sudo chown root:adm -R /usr/local/lib/R + sudo chmod g+w -R /usr/local/lib/R + + - name: install config and build dependencies + run: | + sudo apt-get -y install libcurl4-openssl-dev # needed for pak + + - name: install pak + run: | + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) + shell: Rscript {0} + + # - name: install from CRAN with pak + # run: | + # pak::pkg_install('abn', dependencies=TRUE) + # library('abn') + # shell: Rscript {0} + + - name: pak install from GitHub + run: | + pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") + pak::pkg_install("furrer-lab/abn@${{ env.BRANCH }}", dependencies=TRUE) + library('abn') + shell: Rscript {0} + + - name: fetch the repository from GitHub + uses: actions/checkout@v4 + + - name: deactivate the renv + run: | + renv::deactivate() + shell: Rscript {0} + + - name: install from source + run: | + pak::local_install(dependencies=TRUE) + shell: Rscript {0} diff --git a/.github/workflows/onlabel_Windows_setup.yml b/.github/workflows/Windows_setup.yml similarity index 65% rename from .github/workflows/onlabel_Windows_setup.yml rename to .github/workflows/Windows_setup.yml index d5ebad6c3..b3f6a30bd 100644 --- a/.github/workflows/onlabel_Windows_setup.yml +++ b/.github/workflows/Windows_setup.yml @@ -29,9 +29,9 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - name: prepare windows + - name: install pak run: | - install.packages("devtools", repos=c(CRAN="https://cran.r-project.org")) + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) shell: Rscript {0} - name: install GSL @@ -55,28 +55,16 @@ jobs: library("rjags") shell: Rscript {0} - - name: install INLA - run: | - install.packages("INLA", repos = c(CRAN = "https://cran.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - shell: Rscript {0} - - - name: installing dependencies from BiocManager - run: | - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager", repos=c(CRAN="https://cran.r-project.org")) - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - shell: Rscript {0} - - - name: install from CRAN - run: | - install.packages('abn', repos=c(CRAN="https://cran.r-project.org")) - library('abn') - shell: Rscript {0} + # - name: install from CRAN with pak + # run: | + # pak::pkg_install('abn', dependencies=TRUE) + # library('abn') + # shell: Rscript {0} - - name: install from GitHub + - name: pak install from GitHub run: | - devtools::install_github("furrer-lab/abn", ref="${{ env.BRANCH }}", dependencies=c("Depends", "Imports", "LinkingTo"), local=FALSE) + pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") + pak::pkg_install("furrer-lab/abn@${{ env.BRANCH }}", dependencies=TRUE) library('abn') shell: Rscript {0} @@ -90,7 +78,12 @@ jobs: - name: install from source run: | - devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never', repos=c(CRAN="https://cran.r-project.org")) - devtools::build(pkg = '.', path = '${{ env.BUILD_LOC }}/abn.tar.gz', vignettes = FALSE) - install.packages('${{ env.BUILD_LOC }}/abn.tar.gz', repos=NULL, type="source") + pak::local_install(dependencies=TRUE) + shell: Rscript {0} + + - name: run the tests + run: | + pak::pak('r-lib/testthat') + library("abn") + testthat::test_local(path='tests', load_package='none') shell: Rscript {0} diff --git a/.github/workflows/onlabel_Ubuntu_setup.yml b/.github/workflows/onlabel_Ubuntu_setup.yml deleted file mode 100644 index c0f3fe5bb..000000000 --- a/.github/workflows/onlabel_Ubuntu_setup.yml +++ /dev/null @@ -1,113 +0,0 @@ -# Workflow is triggered on label and check installation on various operating systems -# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning -name: Ubuntu Install - -on: - push: - branches: - - "main" - -env: - JAGS: '4.3.2' - BUILD_LOC: "./build" - BRANCH: ${{ github.head_ref || github.ref_name }} - -permissions: - packages: read - contents: write - pull-requests: write - repository-projects: write - -jobs: - setup-and-install: - runs-on: ubuntu-latest - name: ubuntu-latest R release - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - - - name: install R - run: | - sudo apt-get -y install r-base - - - name: install config and build dependencies - run: | - sudo apt-get -y install pkg-config - sudo apt-get -y install cmake - sudo apt-get -y install r-cran-devtools - - - name: fixing folder perms for local lib - run: | - sudo chown root:adm -R /usr/lib/R - sudo chmod g+w -R /usr/lib/R - sudo chown root:adm -R /usr/local/lib/R - sudo chmod g+w -R /usr/local/lib/R - - - name: update R packages - run: | - update.packages(ask = FALSE, checkBuilt = TRUE) - shell: Rscript {0} - - - name: install GSL - run: | - sudo apt-get -y install libgsl-dev - - - name: install JAGS - run: | - sudo apt-get -y install jags - - - name: install rjags - run: | - install.packages("rjags", configure.args="--enable-rpath", repos=c(CRAN="https://cran.r-project.org")) - library("rjags") - shell: Rscript {0} - - - name: install INLA dependencies - run: | - sudo apt-get install -y --no-install-recommends libudunits2-dev - sudo apt -y install libcurl4-openssl-dev # rCurl for (for INLA) - sudo apt-get -y install libssl-dev # s2 package - sudo apt-get -y install libproj-dev # sf package - sudo apt-get -y install libgeos-dev # terra package - sudo apt-get -y install libgdal-dev # terra package - - - name: install INLA - run: | - install.packages("INLA", repos = c(CRAN = "https://cran.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - shell: Rscript {0} - - - name: installing dependencies from BiocManager - run: | - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager", repos=c(CRAN="https://cran.r-project.org")) - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - shell: Rscript {0} - - - name: install from CRAN - run: | - install.packages('abn', repos=c(CRAN="https://cran.r-project.org")) - library('abn') - shell: Rscript {0} - - - name: install from GitHub - run: | - devtools::install_github("furrer-lab/abn", ref="${{ env.BRANCH }}", dependencies=c("Depends", "Imports", "LinkingTo"), local=FALSE) - library('abn') - shell: Rscript {0} - - - name: fetch the repository from GitHub - uses: actions/checkout@v4 - - - name: deactivate the renv - run: | - renv::deactivate() - shell: Rscript {0} - - - name: install from source - run: | - devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never', repos=c(CRAN="https://cran.r-project.org")) - devtools::build(pkg = '.', path = '${{ env.BUILD_LOC }}/abn.tar.gz', vignettes = FALSE) - install.packages('${{ env.BUILD_LOC }}/abn.tar.gz', repos=NULL, type="source") - shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION index 7e924332b..b7cd02393 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,8 +51,6 @@ Imports: Rgraphviz, rjags, stringi, - entropy, - moments Suggests: bookdown, boot, @@ -62,13 +60,16 @@ Suggests: gridExtra, INLA, knitr, - Matrix (>= 1.6.3), + Matrix, MatrixModels (>= 0.5.3), microbenchmark, R.rsp, RhpcBLASctl, rmarkdown, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + entropy, + moments, + R6 LinkingTo: Rcpp, RcppArmadillo @@ -77,7 +78,7 @@ VignetteBuilder: Additional_repositories: https://inla.r-inla-download.org/R/stable/ Config/testthat/edition: 3 Encoding: UTF-8 -LazyData: true +LazyData: TRUE Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 -SystemRequirements: Gnu Scientific Library version >= 1.12, jpeg, gdal, geos, proj +SystemRequirements: pkg-config, cmake, gsl, jpeg, gdal, geos, proj, udunits-2, openssl, libcurl, jags diff --git a/README.md b/README.md index 667eaae18..d526d51e6 100644 --- a/README.md +++ b/README.md @@ -18,175 +18,80 @@ It derives a directed acyclic graph (DAG) from empirical data that describes the The package provides routines for structure learning and parameter estimation of additive Bayesian network models. # Installation -[![Ubuntu Install](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Ubuntu_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Ubuntu_setup.yml) -[![Fedora Install](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Fedora_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Fedora_setup.yml) -[![MacOS Install](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Macos_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Macos_setup.yml) -[![Windows Install](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Windows_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/onlabel_Windows_setup.yml) +[![Ubuntu Install](https://github.com/furrer-lab/abn/actions/workflows/Ubuntu_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/Ubuntu_setup.yml) +[![Fedora Install](https://github.com/furrer-lab/abn/actions/workflows/Fedora_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/Fedora_setup.yml) +[![MacOS Install](https://github.com/furrer-lab/abn/actions/workflows/Macos_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/Macos_setup.yml) +[![Windows Install](https://github.com/furrer-lab/abn/actions/workflows/Windows_setup.yml/badge.svg?branch=main)](https://github.com/furrer-lab/abn/actions/workflows/Windows_setup.yml) `abn` and its installation process relies on various software that might, or might not, be present in your system. ## Prior to installing -In order for `abn` to work correctly on your system some dependencies need to be installed first. -The required steps to achieve this are specific to the operating system you are using and the following drop-down sections detail these steps for the most common ones: +In order for `abn` to work correctly on your system some dependencies need to be installed. +If you are on a Linux based system (most of) these dependencies are installed automatically for you when following the [pak](https://pak.r-lib.org/)-based installation procedure described in the [Installing from GitHub](#installing-from-github-recommended) section. +For MacOS and Windows based system some more preparatory steps are required. + +The following paragraphs provide detailed instructions for the most common operating systems on the steps that need to be carried out prior to installing `abn`.
Ubuntu -#### Prerequisites - -Most likely you have R installed already but if not run: +You presumably have R installed already, if not, open a terminal and type: ```bash apt-get install r-base ``` -To configure and build `abn` correctly we need `cmake` and `pkg-config`, as well as, the R `devtools` package: - -```bash -apt-get install pkg-config -apt-get install cmake -apt-get install r-cran-devtools -``` - -Finally, we will use `wget` to download `JAGS` later, as well as, the development headers of `curl` and `openssl`: - -```bash -apt-get install wget -apt-get install libcurl4-openssl-dev -apt-get install libssl-dev - -``` - -#### Dependencies +_**Note:** You might need to prepend `sudo ` to this command._ -- **GSL** +All you need for the installation is to have the R-package [pak](https://pak.r-lib.org/) installed. +`pak` is installed like any other R-package, however, it relies on `curl` being present on your system, so we make sure it is there: - [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. - It is required to compile `abn`'s C/C++ code. - - `GSL` is available through the Advanced Package Tool, `APT`, simply type: - ```bash - sudo apt-get install libgsl-dev + apt-get install libcurl4-openssl-dev ``` + Now, to install `pak` we start an R session and write: -- **JAGS & rjags** - - [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. - `JAGS` is required in some simulations `abn` can perform. - - `JAGS` is available through the Advanced Package Tool, `APT`, simply type: - - ```bash - sudo apt-get install jags - ``` - And to install `rjags` open an R session and type: - ```R - install.packages("rjags", configure.args="--enable-rpath", repos=c(CRAN="https://cran.r-project.org")) - library("rjags") + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) ``` -- **INLA** - - [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. - `anb` uses `INLA` to fit some models. - - `INLA` relies on various other R packages and C/C++ libraries. - It thus needs some additional installation steps: - - ```bash - apt-get install --no-install-recommends libudunits2-dev - apt-get install libjpeg-dev - apt-get install libgdal-dev - apt-get install libgeos-dev # might not be needed - apt-get install libproj-dev - ``` - - Now, to install `INLA` itself, simply start an R session and run: - - ```R - install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - ``` - - If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details. - -- **Dependencies from BiocManager** - - [Rgraphviz](https://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) and [graph](https://bioconductor.org/packages/3.19/bioc/html/graph.html) are used to produce plots of network graphs. - Both packages are hosted on [Bioconductor](https://www.bioconductor.org/) and thus need to be installed with `BiocManager`: - - The installation is straight forward on most common platforms, simply start an R session and run: - - ```R - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager") - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - ``` + With that you should be ready to [install `abn` from GitHub](#installing-from-github-recommended).
Fedora -#### Prerequisites - - You will need C/C++ and Fortran compilers and various libraries: - - ```bash - dnf install gcc - dnf install gcc-c++ - dnf install gfortran - dnf install lapack* # is needed on fedora server - dnf install blas* - dnf install atlas* - ``` - - Most likely you have R installed already but if not run: + You presumably have R installed already, if not, open a terminal and type: ```bash dnf install R ``` - - To configure and build `abn` correctly we need `cmake` and `pkg-config`, as well as, the R `devtools` package: - - ```bash - dnf install pkg-config - dnf install cmake - dnf install R-devtools - ``` - - Finally, we will use `wget` to download `JAGS` later, as well as, the development headers of `curl` and `openssl`: - + + _**Note:** You might need to prepend `sudo ` to this command._ + + For the installation you need to have the R-package [pak](https://pak.r-lib.org/) installed. + `pak` is installed like any other R-package, however, it relies on `curl` being installed on your system, so we make sure it is there: + ```bash - dnf install wget dnf install libcurl-devel - dnf install openssl-devel ``` + Now, to install `pak` we start an R session and write: -#### Dependencies - -- **GSL** + ```R + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) + ``` - [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. - It is required to compile `abn`'s C/C++ code. + There is one more thing we need to do before we can install `abn`: - `GSL` is available through Fedoras standard package manager, `DNF`, simply type: - - ```bash - sudo dnf install gsl-devel - ``` + **Install JAGS from source** -- **JAGS & rjags** - [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. `JAGS` is required in some simulations `abn` can perform. - `JAGS` must be installed from source. - Below are the steps to install `JAGS 4.3.2`. + The steps needed to install `JAGS 4.3.2` are: ```bash wget -O /tmp/jags.tar.gz https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.2.tar.gz/download @@ -198,10 +103,9 @@ apt-get install libssl-dev sudo make install ``` - > [!NOTE] - > If you are on a 64bit system (you likely are) mind the `--libdir=/usr/local/lib64` argument when launching `./configure`. - > Omitting this argument will lead to `rjags` "not seeing" `jags`. - + _**Note:**_ + _If you are on a 64bit system (you likely are) mind the `--libdir=/usr/local/lib64` argument when launching `./configure`.)_ + _Omitting this argument will lead to `rjags` "not seeing" `jags`._ On Fedora `rjags` might need some special configuration for it to link properly to the `JAGS` library. Also, it might be needed to add the path to the `JAGS` library to the linker path (see [rjags INSTALL file](https://github.com/cran/rjags/blob/master/INSTALL) for further details). @@ -213,68 +117,37 @@ apt-get install libssl-dev sudo /sbin/ldconfig ``` - **Note:** - _These commands might not be needed, you might first try to install `rjags` (see below) and only run them if you encounter a `configure: error: Runtime link error`._ - - To install `rjags` open an R session and type: + _**Note:**_ + _These commands might not be needed, you might first try to install the R-package `rjags` and only run them if you encounter a `configure: error: Runtime link error`._ + + With that you should be ready to [install `abn` from GitHub](#installing-from-github-recommended). - ```R - install.packages("rjags", configure.args="--enable-rpath", repos=c(CRAN="https://cran.r-project.org")) - ``` +
-- **INLA** +
+MacOS - [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. - `anb` uses `INLA` to fit some models. - - `INLA` relies on various other R packages and C/C++ libraries. - It thus needs some additional installation steps: - + Most likely you have R installed already but if not run: + ```bash - dnf install udunits2-devel - dnf install libjpeg-devel - dnf install gdal-devel - dnf install geos-devel - dnf install proj-devel - ``` - - Now, to install `INLA` itself, simply start an R session and run: - - ```R - install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) + brew install R ``` - - If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details. -- **Dependencies from BiocManager** + For the installation you need to have the R-package [pak](https://pak.r-lib.org/) installed. + `pak` is installed like any other R-package, we start an R session and write: - [Rgraphviz](https://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) and [graph](https://bioconductor.org/packages/3.19/bioc/html/graph.html) are used to produce plots of network graphs. - Both packages are hosted on [Bioconductor](https://www.bioconductor.org/) and thus need to be installed with `BiocManager`: - - The installation is straight forward on most common platforms, simply start an R session and run: - ```R - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager") - BiocManager::install("Rgraphviz") - BiocManager::install("graph") + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) ``` -
- -
-MacOS - -#### Prerequisites - - - The installation process on MacOS relies on [Homebrew](https://brew.sh/), head over to their site to see the installation process or simply open a terminal and run: + We will install the system dependencies with [Homebrew](https://brew.sh/). + Head over to their site to see the installation process or simply open a terminal and run: ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` - To configure and build `abn` correctly we need `cmake` and `pkg-config`: + To correctly link to installed libraries and to build them, we need `pkg-config` and `automake`: ```bash brew install pkg-config @@ -288,154 +161,133 @@ apt-get install libssl-dev brew install openssl@1.1 ``` - Most likely you have R installed already but if not run: - - ```bash - brew install R - ``` - - -#### Dependencies - -- **GSL** - - [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. - It is required to compile `abn`'s C/C++ code. - - With Homebrew you can install the `GSL` binaries directly: - - ``` - brew install gsl - ``` - -- **JAGS & rjags** - - [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. - `JAGS` is required in some simulations `abn` can perform. - - With Homebrew you can install the `JAGS` binaries directly: - - ``` - brew install jags - ``` - - And now to install `rjags`, open an R session and type: - - ```R - install.packages("rjags", type="source", repos=c(CRAN="https://cran.r-project.org")) - library("rjags") - ``` - -- **INLA** - - [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. - `anb` uses `INLA` to fit some models. - - `INLA` relies on various other R packages and C/C++ libraries. - It thus needs some additional installation steps: - - ```bash - brew install udunits - brew install gdal # installs also geos as dependency - brew install proj - ``` - - Now, to install `INLA` itself, simply start an R session and run: - - ```R - install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - ``` - - If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details. - -- **Dependencies from BiocManager** - - [Rgraphviz](https://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) and [graph](https://bioconductor.org/packages/3.19/bioc/html/graph.html) are used to produce plots of network graphs. - Both packages are hosted on [Bioconductor](https://www.bioconductor.org/) and thus need to be installed with `BiocManager`: - - The installation is straight forward on most common platforms, simply start an R session and run: - - ```R - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager") - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - ``` + #### Dependencies + + On MacOS we need to install some system dependencies separately: + + + - **GSL** + + [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. + It is required to compile `abn`'s C/C++ code. + + With Homebrew you can install the `GSL` binaries directly: + + ``` + brew install gsl + ``` + + - **JAGS & rjags** + + [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. + `JAGS` is required in some simulations `abn` can perform. + + With Homebrew you can install the `JAGS` binaries directly: + + ``` + brew install jags + ``` + + And now to install `rjags`, open an R session and type: + + ```R + install.packages("rjags", type="source", repos=c(CRAN="https://cran.r-project.org")) + library("rjags") + ``` + + - **INLA** + + [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. + `abn` uses `INLA` to fit some models. + + `INLA` relies on various other R packages and C/C++ libraries. + It thus needs some additional installation steps: + + ```bash + brew install udunits + brew install gdal # installs also geos as dependency + brew install proj + ``` + + Now, to install `INLA` itself, simply start an R session and run: + + ```R + install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) + ``` + + If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details.
Windows -#### Dependencies - -- **GSL** - - [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. - It is required to compile `abn`'s C/C++ code. - - In Windows `GSL` is available a.o. through [cygwin](https://cygwin.com/index.html), which has a straight forward installation process. - Either head over to the website, download and install the `setup-x86_64.exe` file or use PowerShell: - - ``` - Import-Module bitstransfer - New-Item -ItemType Directory -Force -Path "C:\Program Files\cygwin" - start-bitstransfer -source https://cygwin.com/setup-x86_64.exe "C:\Program Files\cygwin\setup-x86_64.exe" - Start-Process -Wait -FilePath "C:\Program Files\cygwin\setup-x86_64.exe" -ArgumentList "/S" -PassThru - ``` + For the installation you need to have the R-package [pak](https://pak.r-lib.org/) installed. + `pak` is installed like any other R-package, we start an R session and write: -- **JAGS & rjags** - - [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. - `JAGS` is required in some simulations `abn` can perform. - - - You can either head over to the [JAGS download page](https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/), download and execute the installable, or use PowerShell. - The following instructions will download and install `JAGS 4.3.1` in PowerShell: - - ``` - Import-Module bitstransfer - New-Item -ItemType Directory -Force -Path "C:\Program Files\JAGS\JAGS-4.3.1" - start-bitstransfer -source https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download "C:\Program Files\JAGS\JAGS-4.3.1\JAGS-4.3.1.exe" - Start-Process -Wait -FilePath "C:\Program Files\JAGS\JAGS-4.3.1\JAGS-4.3.1.exe" -ArgumentList "/S" -PassThru - ``` - - In order to make sure `rjags` finds `JAGS` we set the environment variable `JAGS_HOME` before installing `rjags`. - To do so, open your R session and type: - ```R - Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.1") - install.packages("rjags", repos=c(CRAN="https://cran.r-project.org")) - library("rjags") - ``` - -- **INLA** - - [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. - `anb` uses `INLA` to fit some models. - - The installation is straight forward, simply start an R session and run: - - ```R - install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) - ``` - - If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details. - -- **Dependencies from BiocManager** - - [Rgraphviz](https://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) and [graph](https://bioconductor.org/packages/3.19/bioc/html/graph.html) are used to produce plots of network graphs. - Both packages are hosted on [Bioconductor](https://www.bioconductor.org/) and thus need to be installed with `BiocManager`: - - The installation is straight forward on most common platforms, simply start an R session and run: + install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) + ``` + + + #### Dependencies + + On Windows we need to install some system dependencies separately: + + + - **GSL** + + [GSL](https://www.gnu.org/software/gsl/), the _GNU Scientific Library_, is a numerical library for C/C++. + It is required to compile `abn`'s C/C++ code. + + In Windows `GSL` is available a.o. through [cygwin](https://cygwin.com/index.html), which has a straight forward installation process. + Either head over to the website, download and install the `setup-x86_64.exe` file or use PowerShell: + + ``` + Import-Module bitstransfer + New-Item -ItemType Directory -Force -Path "C:\Program Files\cygwin" + start-bitstransfer -source https://cygwin.com/setup-x86_64.exe "C:\Program Files\cygwin\setup-x86_64.exe" + Start-Process -Wait -FilePath "C:\Program Files\cygwin\setup-x86_64.exe" -ArgumentList "/S" -PassThru + ``` + + - **JAGS & rjags** + + [JAGS](https://mcmc-jags.sourceforge.io/), _Just Another Gibbs Sampler_, is a program for analyzing Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation. [rjags](https://cran.r-project.org/web/packages/rjags/index.html) is R's interface to the `JAGS` library. + `JAGS` is required in some simulations `abn` can perform. + + + You can either head over to the [JAGS download page](https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/), download and execute the installable, or use PowerShell. + The following instructions will download and install `JAGS 4.3.1` in PowerShell: + + ``` + Import-Module bitstransfer + New-Item -ItemType Directory -Force -Path "C:\Program Files\JAGS\JAGS-4.3.1" + start-bitstransfer -source https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download "C:\Program Files\JAGS\JAGS-4.3.1\JAGS-4.3.1.exe" + Start-Process -Wait -FilePath "C:\Program Files\JAGS\JAGS-4.3.1\JAGS-4.3.1.exe" -ArgumentList "/S" -PassThru + ``` + + In order to make sure `rjags` finds `JAGS` we set the environment variable `JAGS_HOME` before installing `rjags`. + To do so, open your R session and type: + + ```R + Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.1") + install.packages("rjags", repos=c(CRAN="https://cran.r-project.org")) + library("rjags") + ``` + + - **INLA** + + [INLA](https://www.r-inla.org/) is an R package that is not hosted on CRAN and thus needs to be installed separately. + `abn` uses `INLA` to fit some models. + + The installation is straight forward, simply start an R session and run: + + ```R + install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE) + ``` + + If you run into trouble, please see also [INLA's installation instructions](https://www.r-inla.org/download-install) for further details. - ```R - if (!requireNamespace("BiocManager", quietly = TRUE)) - install.packages("BiocManager") - BiocManager::install("Rgraphviz") - BiocManager::install("graph") - ``` -
_Click on your operating system to see the specific installation instructions_ @@ -451,34 +303,37 @@ We recommend to not directly install `main`, but to a specific version. Head over to our [version list](https://github.com/furrer-lab/abn/releases) to see which one is the latest version. Here we assume the version is `3.1.1`. -We use [devtools](https://github.com/r-lib/devtools) to install from GitHub. -At this point `devtools` should already be installed in your system. -
if not, install it first. Open an R session and type: +We use [pak](https://pak.r-lib.org/) for the installation process. +If you followed the [Prior to installing](#prior-to-installing) section `pak` should already be installed. +
If not, install it first. Open an R session and type: ```R -install.packages("devtools", repos=c(CRAN="https://cran.r-project.org")) +install.packages('pak', repos=c(CRAN="https://cran.r-project.org")) ```
To install `abn` run in your R session: ```R -devtools::install_github("furrer-lab/abn", ref="3.1.1", dependencies=c("Depends", "Imports", "LinkingTo")) +pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") +pak::pkg_install("furrer-lab/abn@3.1.1", dependencies=TRUE) ``` +_**Note:** The first command can be skipped on MacOS or Windows._ ## Installing from CRAN -Note that when installing from CRAN you might not get the latest version of `abn`. -If you want the latest version follow the instructions from [Installing from GitHub](#installing-from-github-recommended). +> [!NOTE] +> When installing from CRAN you might not get the latest version of `abn`. +> If you want the latest version follow the instructions from [Installing from GitHub](#installing-from-github-recommended). In order to install the `abn` version on CRAN, open an R session and type: ```R -install.packages('abn', repos=c(CRAN="https://cran.r-project.org")) +pak::pkg_install("abn", dependencies=TRUE) ``` -`anb` has several dependencies that are not available on CRAN. -This is why the [Prior to installing](#prior-to-installing) section should be followed through before installing `abn` from CRAN. [^1] +`abn` has several dependencies that are not available on CRAN. +This is why we rely on [pak](https://pak.r-lib.org/) for the installation and the [Prior to installing](#prior-to-installing) section should be followed through before installing `abn` from CRAN. [^1] [^1]: The `abn` package includes certain features, such as multiprocessing and integration with the `INLA` package, which are limited or available only on specific CRAN flavors. While it is possible to relax the testing process by, e.g., excluding tests of these functionalities, we believe that rigorous testing is important for reliable software development, especially for a package like `abn` that includes complex functionalities. @@ -493,8 +348,6 @@ It is also possible to clone this repository and install `abn` from source. > [!NOTE] > Also in this case you need to first prepare your system by following the [Prior to installing](#prior-to-installing) section. -When installing from source - Installing from source is done with the following steps: 1. Clone the repository and go to the root directory of the repo: @@ -504,23 +357,19 @@ Installing from source is done with the following steps: cd abn ``` -2. Install the dependencies by opening an R session and typing: - - ```R - devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never', repos=c(CRAN="https://cran.r-project.org")) - ``` - -3. Build the package by opening an R session and typing: +2. Deactivate `abn`'s development environment (a [renv](https://rstudio.github.io/renv/articles/renv.html) virtual environment): ```R - devtools::build(pkg = '.', path = '.build/abn.tar.gz', vignettes = FALSE) + renv::deactivate() ``` -4. Install the package by opening an R session and typing: +3. Build and install the local content with dependencies: ```R - install.packages('.build/abn.tar.gz', repos=NULL, type="source") + pak::repo_add(INLA = "https://inla.r-inla-download.org/R/stable/") + pak::local_install(dependencies=TRUE) ``` + _**Note:** The first command can be skipped on MacOS or Windows._ # Quickstart diff --git a/src/Makevars.in b/src/Makevars.in index ea1cbb875..3ad19cb82 100755 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -9,4 +9,4 @@ GSL_LIBS = @GSL_LIBS@ PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) $(GSL_CFLAGS) -I. PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) $(GSL_CFLAGS) -PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(GSL_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) +PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(SHLIB_OPENMP_CFLAGS) $(GSL_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)