R nfcore.utils: a R package to join Nextflow and R

Release codecov install with conda-forge

This package is aimed to anyone wanting to use R script within Nextflow. Its aim is to provide function allowing to link easily Nextflow parameters to the R logic. It also perform validity check on the variable passed to ensure proper execution.

Installation

With conda-forge

mamba create -n env_r_nfcore_utils conda-forge::r-nfcore.utils
mamba activate env_r_nfcore_utils

In R from Github

if (!require("remotes", quietly = TRUE))
    install.packages("remotes")

remotes::install_github(
  "nf-core/r-nf-core-utils",
  build_vignettes=TRUE
)

In R from CRAN (soon)

install.packages("nfcore.utils")

Usage example in a Nextflow template

Here is a simple example that show how to use the package in a Nextflow process template.

library(nfcore.utils)

################################################
## INPUTS PARSING                             ##
################################################

# First define the options list you need
opt <- list(
  output_prefix = '${prefix}',
  input_file = '${input}',
  output_folder = '${output_folder}',
  value_integer = 1234, # Can be set to a default value
  value_double = 0.1234,
  seed = NULL # Will be set at the start of the script
)

# Call main function with validation checks
opt_valid <- process_inputs(
  opt,
  args = '${args}', # Args provided as --key value, will replace default value
  keys_to_nullify = c("output_prefix"),
  expected_files = c("input_file"),
  expected_folders = c("output_folder"),
  expected_double = c("value_double"),
  expected_integer = c("value_integer"),
  required_opts = c("input_file", "output_folder")
)

################################################
## MAIN SCRIPT                                ##
################################################

# Write here your script and outputs

################################################
## VERSIONS and LOG EMISSION                  ##
################################################

process_end(
  packages = list( # Write additionaly used packages
    "r-stats" = "stats" # conda package name = r package name
  ),
  task_name = '"${task.process}":',
  versions_path = "versions.yml",
  log_path = "R_sessionInfo.log"
)

Documentation, News and Citation

To view documentation start R and enter:

library(nfcore.utils)
help(package="nfcore.utils")

# Or to view the vignettes
browseVignettes("nfcore.utils")

# Or to see the news
utils::news(package="nfcore.utils")

# Or to cite nfcore.utils
citation("nfcore.utils")

Credits

R nf-core/utils was written by the nf-core community, with major contributions from Louis Le Nézet, XXXX.

Additional contributors were XXXXX.

Contributions and Support

If you would like to contribute to this package, please see the contributing guidelines.

For further information or help, don’t hesitate to get in touch on the Slack #r-nf-core-utils channel (you can join with this invite).

Citations

If you use R nf-core/utils for your analysis, please cite it using the nf-core publication as follows:

The nf-core framework for community-curated bioinformatics pipelines.

Philip Ewels, Alexander Peltzer, Sven Fillinger, Harshil Patel, Johannes Alneberg, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso & Sven Nahnsen.

Nat Biotechnol. 2020 Feb 13. doi: 10.1038/s41587-020-0439-x.

The citation entry can be found in the CITATIONS file.