The intention of this package is to provide tools to assist in converting between Rmarkdown and LaTeX documents, specifically in the case where one is writing a workflow to be submitted to F1000Research, while hopefully also hosting a runable example on Bioconductor. Reaching these two endpoints while maintaining a single working document can be challenging. Submission to the journal requires a LaTeX file, which is best achieved by writing an Rnw workflow based on Sweave or knitr, while producing the html based versions hosted by Bioconductor is most easily achieved from an Rmarkdown document. Tools such as pandoc will allow conversion between many formats, but there is still a high degree of manual intervention required when aiming to meet the specific formatting requirements of a journal publication.
The current functionality assumes you have developed, or a planning to develop, a workflow in Rmarkdown, and aims to make the creation of a LaTeX document suitable for submission to F1000Research as straightforward as possible.
Before we can begin, you need to load the library.
library(BiocWorkflowTools)
This package comes with an example Rmd file based upon the LaTeX article template supplied by F1000Research. This defines the document structure for an F1000Research software article, and gives examples of how you can incorporate tables, figures and evaluated code in your Rmarkdown document. These examples have all been tested to ensure they can be converted to LaTeX using this package. If you are just starting out developing your workflow, this template is a good place to start.
The code below finds where the template has been installed on your system, and prints its location, so you can look at it and make a copy to begin creating your own workflow.
example_Rmd <- system.file('examples/f1000_software_example.Rmd', package = "BiocWorkflowTools")
example_Rmd
## [1] "/tmp/Rtmp0ZESPX/Rinst2b807f1f3ac0/BiocWorkflowTools/examples/f1000_software_example.Rmd"
Once you have written your Rmarkdown document, you want to convert it to LaTeX for submission to the journal.
The function markdownToLatex()
takes an Rmd file as input. In the example below we use the example Rmd distributed with the package. This will create a LaTeX file with appropriate formatting options defined in its header, which will produce a PDF document that meets the requirements of an F1000Research article when the LaTeX is compiled.
The output
argument to markdownToLatex()
specifies the directory you would like the output written to. In the code below the first two lines generate a temporary location we will use in this example. For your own workflow you will likely want to specify a location directly. If you do not provide an option here, the default is to use the same directory the Rmd file is located in.
You can optionally choose to create a zip file archive of the output folder using the argument compress
. Doing so can make uploading the project for journal submission easier as you only have to select a single file.
tmp_dir <- file.path(tempdir(), 'F1000_example')
dir.create(tmp_dir)
markdownToLatex(input = example_Rmd, output = tmp_dir, compress = TRUE)
Finally, we provide the function uploadToOverleaf()
to upload the project directly to Overleaf (http://www.overleaf.com), the LaTeX authoring system F1000Research use for their submission process. This step is entirely optional, and the output created by the previous steps can be uploaded manually.
zip_file <- paste0(tmp_dir, '.zip')
uploadToOverleaf(files = zip_file, openInBrowser = TRUE)
sessionInfo()
## R version 3.3.1 (2016-06-21)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.1 LTS
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] BiocWorkflowTools_1.0.0 BiocStyle_2.2.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.7 digest_0.6.10 assertthat_0.1 R6_2.2.0
## [5] formatR_1.4 magrittr_1.5 evaluate_0.10 httr_1.2.1
## [9] stringi_1.1.2 rmarkdown_1.1 tools_3.3.1 stringr_1.1.0
## [13] yaml_2.1.13 htmltools_0.3.5 knitr_1.14 tibble_1.2