---
title: "Install"
format: html
editor: visual
minimal: true
date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`'
vignette: >
  %\VignetteIndexEntry{Install}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
---

For manual installation, an [R](https://www.r-project.org/) version \>= 4.4.0 is
required.

[Notes]{.underline}: only a development version of `metabonaut` is available as
of now but a stable version will come soon. Therefore, if you are having
difficulty to run some part of the code we strongly recommend to use the Docker
image, as it will have all the package necessary to run all the analysis
presented in these workflows.

# Running workflows locally

To install on your computer all the packages necessary for the workflows run the
code as follow:

```{r eval=FALSE}
install.packages("BiocManager")
BiocManager::install('RforMassSpectrometry/MsIO', ask = FALSE, 
                     dependencies = TRUE)

BiocManager::install("RforMassSpectrometry/metabonaut",
                     dependencies = TRUE, ask = FALSE, update = TRUE)
```

If you get some error message when downloading form GitHub it might be due to
an expired token. Remove them using this code below and try to install again: 

```{r eval=FALSE}
#See if any token is there:
gitcreds::gitcreds_get()

# Delete them:
gitcreds::gitcreds_delete()
```


# Docker image

The vignettes files along with an R runtime environment including all required
packages and the RStudio (Posit) editor are all bundled in a *docker* container.

After installation, this docker container can be run on the computer and the
code and examples from the vignettes can be evaluated within this environment
(without the need to install any additional packages or files).

-   If you don't already have, install [docker](https://www.docker.com/). Find
    installation information [here](https://docs.docker.com/desktop/).
-   Get the [docker
    image](https://hub.docker.com/r/rformassspectrometry/metabonaut) of this
    tutorial e.g. from the command line with:

```         
    docker pull rformassspectrometry/metabonaut:latest
```

-   Start the docker container, either through the Docker Desktop, or on the
    command line with

```         
docker run -e PASSWORD=bioc -p 8787:8787 rformassspectrometry/metabonaut:latest
```

-   Enter [`http://localhost:8787`](http://localhost:8787) in a web browser and
    log in with username `rstudio` and password `bioc`.
-   In the RStudio server version: open any of the Quarto files in the
    *vignettes* folder and evaluate the R code blocks in that document.
