---
title: "`r params$title`"
subtitle: "Study: `r params$study`\n`r params$version`"
date: "`r Sys.Date()`"
documentclass: book
output:   
  clinDataReview::gitbook_clinDataReview_report:
    logo: !expr system.file(package = "clinDataReview", "skeleton", "figures", "logoText.svg")
    logoHeight: "55px"
    split_by: 'section+number'
editor_options: 
  chunk_output_type: console
---

# Introduction

```{r options, echo = FALSE, message = FALSE, warning = FALSE}

library(knitr)
opts_chunk$set(
    echo = FALSE, 
    warning = FALSE, error = FALSE, message = FALSE, 
    results = "asis",
    cache = FALSE,
    fig.width = 8, fig.height = 7,
    fig.path = "./figures/",
    fig.align = 'center'
)

# print warnings where they occur (warn = 0 by default)
options(warn = 1)

```

```{r loadPackages}

library(clinDataReview)

```

**Current data transfer:** `r params$currentDataTransfer`  

**Previous data transfer (used for comparisons):**
`r params$previousDataTransfer`  

This report works best with **Mozilla Firefox** and **Google Chrome**. Please do
not use Internet Explorer or Edge as they do not contain all functionalities.  

Please send questions, requests, suggestions and issues about these reports to
`r toString(params$contactPerson)`.  

The table of contents in the side panel on the left and "<" and ">" buttons on
the left and right side of the main panel can be used to navigate the report. An
**empty page** (with a header) indicates that the data is split in subsections
and you should navigate further to the subsection of interest.  

For **instructions** on how to use the visualizations and tables please go to the next
section by either clicking the ">" button on the right, or by selecting
"Tutorial: Subject-level visualizations and tables" in the table of contents on the
left.  


```{r getMetadata, dateReportRun = TRUE}
# Current metadata associated with this report
metadataFile <- list.files(
    path = params$pathDataFolder, 
    pattern = "metadata.yml", 
    full.names = TRUE
)
namesInfo <- c(
    "pathSDTMs" = "Original data (SDTM) path:",
    "dateTimeSDTMcreation" = "Data creation date:"
)
if(length(metadataFile) > 0) {
  cat("The **metadata associated with this report** are:\n\n")
  getMetadata(metadataFile, namesInfo = namesInfo)
}
cat("\n\n")
```

```{r getMetadataOld, dateReportRun = FALSE, eval = (! is.null(params$pathDataFolderOld))}
# Old metadata associated with comparison data
metadataFileOldData <- list.files(
    path = params$pathDataFolderOld, 
    pattern = "metadata.yml", 
    full.names = TRUE
)
namesInfo <- c(
    "pathSDTMs" = "Original data (SDTM) path:",
    "dateTimeSDTMcreation" = "Report creation date:"
)
if(length(metadataFileOldData) > 0) {
  cat("The **metadata associated with the comparison data** are:\n\n")
  getMetadata(metadataFileOldData, namesInfo = namesInfo)
}
```


## Tutorial: Subject-level visualizations and tables {#tutorialSubjectLevel}

Subject-level analyses (e.g. spaghetti plots, shift plots, eDISH,...) are
represented with interactive visualizations and tables. Patient profiles can
be opened from the visualizations as well as the tables. More detailed instructions can
be found in the screenshots below.

### Scatter plots and spaghetti plots

In the scatter and spaghetti plots of the reports, points are selectable
and associated patient profiles (if available) are downloaded by pressing the 'P'
key on your keyboard.
![](figures/subjectPlots.png)

Records selected on the visualizations are filtered on the interactive table
available at the bottom of the visualization.

### Linked tables

Patients profiles are downloaded when clicking on the
subject identifier hyperlink in the table (if available).

![](figures/subjectTables.png)

## Tutorial: Summarized visualizations and tables

Summary data (e.g. counts per category) are displayed in interactive summary 
visualizations and tables. They follow the same
principles as highlighted in the previous section.  
Functionalities specific of these visualizations and tables are mentioned in 
the sections below.

### Summary plots {#tutorialSummaryPlots}

![](figures/treemap.png)

### Summary tables {#tutorialSummaryTables}

![](figures/summaryTables.png)
