---
title: '%PROJECT% - %PACKAGE%'
subtitle: '%TASK% - %SUFFIX%'
author: '%AUTHOR%'
date: '%DATE%'
license: '%COPYRIGHT%'
copyright: 
  holder: '%SPONSOR%'
  year: '%YEAR%'
format:
  docx:
    reference-doc: '%TEMPLATEFILE%'
    toc: true
    toc-title: 'Table of Contents'
    toc-depth: 2
    number-sections: false
    number-depth: 2
    shift-heading-level-by: 0
    highlight-style: github
---

```{r}
#| include: false
# ===================== HELPER CODE ==========================
if(FALSE) {
  library(D4TAlink.light)
  #library(D4TAlink)
  setTaskSponsor("%SPONSOR%")
  setTaskStructure(pathsDefault)
  try(setTaskRoot("%ROOT%"))

  # load the task
  task <- loadTask(project="%PROJECT%", package="%PACKAGE%", taskname="%TASK%")
  
  # render the task
  shell.exec(renderTaskRmd(task,suffix="%SUFFIX%"))
  
  # archive the task to the home directory
  archiveTask(task,zf<-paste0("~/",task$task,".zip"),overwrite=FALSE)
  
  # settings for new repository
  oro <- getTaskRoot() 
  setTaskRoot("/PATH/TO/NEW/REPOSITORY")
  ost <- getTaskStructure() 
  setTaskStructure(pathsDefault)

  # copy the task to a new repository
  newtask <- restoreTask(zf)
  print(list.files(getTaskPaths(newtask)$data,
                   full.names=FALSE,recursive=TRUE))
  
  #restore old settings
  setTaskRoot(oro) 
  setTaskStructure(ost)
}
# ============================================================
```

```{r loadLibraries, warning=FALSE}
#| echo: false
# Load libraries
library(D4TAlink.light)
setTaskSponsor("%SPONSOR%")
setTaskStructure(pathsDefault)
try(setTaskRoot("%ROOT%"))
```

```{r loadTask}
# Load task
task <- loadTask("%PROJECT%","%PACKAGE%","%TASK%",quiet=TRUE)
# if task does not exist on repository, create it 
if(is.null(task)) {
  task <- initTask(project="%PROJECT%",
                   package="%PACKAGE%",
                   taskname="%TASK%",
                   sponsor="%SPONSOR%",
                   author="%AUTHOR%")
}
options(warn = 2)
```

\newpage

# Scope

In this section the scope / rationale of the task should be explained.

# Input

The section list the information and data sources.

* List of patients (see email by JD dated 2022-05-01 17:12).
* List of assays (see task 20220102_loadAssays).

```{r loadInput}
#| echo: false
# Code to load input data

# ta <- loadTask(task$project,task$package,"20220102_loadAssays)
# ass <- readBinary(ta,"assays")

```

# Methods and Results

The results-section contains more details regarding the results of task X.

```{r consideredRCode}
#| echo: false
# Chunk that contains the analysis R code.
```


# Output

The section contains detailed information on output (incl. location).

* List of assays.

```{r saveOutput}
#| echo: false
# Code to save data

# saveBinary(ass,ta,"assays")

```

\newpage

# References

1. R Core Team (2022). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

\newpage

# Appendices

## Session information

```{r sessionInfo}
#| echo: false
#| output: true
# In the appendix the session information is being printed for reproducibility.

sessionInfo()

```

## List of figures

<!---BLOCK_TOC{seq_id: 'fig'}--->

## List of tables

<!---BLOCK_TOC{seq_id: 'tab'}--->

