Skip to content

Commit

Permalink
#7 end of day
Browse files Browse the repository at this point in the history
  • Loading branch information
pgstevenson committed Apr 17, 2019
1 parent 0bf1e19 commit 2b201fc
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 116 deletions.
236 changes: 120 additions & 116 deletions vignettes/07_reproducable_research.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "A Biostatistician's Introduction to Reproducible Research and Reporting"
title: "Introduction to Reproducible Research and Reporting"
author: "Paul Stevenson"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
Expand All @@ -18,6 +18,9 @@ vignette: >

```{r init, include = FALSE, echo = FALSE}
library(biometrics)
library(knitr)
source("assets/R/hooks.R")
```

Expand All @@ -32,19 +35,19 @@ library(biometrics)

<div class = "col2 small">

- Convention for how you organise your research artefacts into directories
- A standard and easily recognisable way for organising a reproducible research project
- Simplifies file management and streamlines analytical workflows
- Ideal for projects that result in the publication of a paper
- Easier to communicate your work with other researchers (and your future self)
- "Project as a Package"
- R and beyond
- Convention for how you organise your research artefacts into directories
- A standard and easily recognisable way for organising a reproducible research project
- Simplifies file management and streamlines analytical workflows
- Ideal for projects that result in the publication of a paper
- Easier to communicate your work with other researchers (and your future self)
- "Project as a Package"
- R and beyond

</div>

&nbsp;

<div class = "small">[https://github.com/ropensci/rrrpkg](https://github.com/ropensci/rrrpkg)</div>
<div class = "small"><https://github.com/ropensci/rrrpkg></div>

## Definition

Expand All @@ -55,118 +58,119 @@ library(biometrics)

<div class = "col2 small">

>- Convention for how you organise your research artefacts into directories
>- A standard and easily recognisable way for organising a reproducible research project
>- Simplifies file management and streamlines analytical workflows
>- Ideal for projects that result in the publication of a paper
>- Easier to communicate your work with other researchers (and your future self)
>- "Project as a Package"
>- R and beyond
>- Convention for how you organise your research artefacts into directories
>- A standard and easily recognisable way for organising a reproducible research project
>- Simplifies file management and streamlines analytical workflows
>- Ideal for projects that result in the publication of a paper
>- Easier to communicate your work with other researchers (and your future self)
>- "Project as a Package"
>- R and beyond
</div>

&nbsp;

<div class = "small">[https://github.com/ropensci/rrrpkg](https://github.com/ropensci/rrrpkg)</div>
<div class = "small"><https://github.com/ropensci/rrrpkg></div>

## Example Project Directory | *The Container*

```{r, echo = F, out.extra = "class='centre'", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "Slide1.JPG"))
```{r, echo = F, out.extra = "figure", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "07_Slide1.JPG"))
```

# Example Template Project

## Project meta data

>- README.md
>- a synopsis of the project
>- very useful for your future self and colleges/collaborators
>- NEWS.md
>- Communicate change to the project files/data
>- DESCRIPTION (R specific - Python requirements.txt)
>- LICENSE
>- .gitIgnore (Will talk about Git later)
>- README.md
>- a synopsis of the project
>- very useful for your future self and colleges/collaborators
>- NEWS.md
>- Communicate change to the project files/data
>- DESCRIPTION (R specific - Python requirements.txt)
>- LICENSE
>- .gitIgnore (Will talk about Git later)
# Project Administration

## Project Administration

```{r, echo = F, out.extra = "class='centre'", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "Slide2.JPG"))
```{r, echo = F, out.extra = "figure", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "07_Slide2.JPG"))
```

## admin \*

- Project meta data
- Legal documents (e.g. contracts)
- Communications
- Ethics documentation
- Indirect resources (e.g. papers)
- Project management resources
- etc.
- Project meta data
- Legal documents (e.g. contracts)
- Communications
- Ethics documentation
- Indirect resources (e.g. papers)
- Project management resources
- etc.

\* I Would consider adding directories/files marked with an asterisk to .gitIgnore
\* Consider adding directories/files marked with an asterisk to .gitIgnore

## archive \*

- Old code that might be redundant, but is precious
- Helps to keep project folders tidy
- Old code that might be redundant, but is precious
- Helps to keep project folders tidy

# Data Directories

## Data Directories

```{r, echo = F, out.extra = "class='centre'", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "Slide3.JPG"))
```{r, echo = F, out.extra = "figure", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "07_Slide3.JPG"))
```

## data-raw \*

- a "read-only" directory to store raw data (e.g. Excel, STATA, SAS, .csv)
- recommend changing the file to read only in operating system
- The heart of reproducible research, all actions are traceable from raw data to report
- A "read-only" directory to store raw data (e.g. Excel, STATA, SAS, .csv)
- Recommend changing the file to read only in operating system
- The heart of reproducible research, all actions are traceable from raw data to report

## data \*

- Data is converted from the raw format in to the software's preferred structure (e.g. .RData, .rds)
- Minimal operations are performed on data
- correcting variable names
- data cleaning
- data harmonisation/standardisation/coding
- table joining/splitting
- Data is converted from the raw format in to the software's preferred structure (e.g. .RData, .rds)
- Minimal operations are performed on data
- correcting variable names
- data cleaning
- data harmonisation/standardisation/coding
- table joining/splitting

## cache \*

>- Store manipulated data here for statistical analysis
>- Store manipulated data here for statistical analysis
# Script/Algorithm Directories

## Script/Algorithm Directories

```{r, echo = F, out.extra = "class='centre'", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "Slide4.JPG"))
```{r, echo = F, out.extra = "figure", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "07_Slide4.JPG"))
```

## ProjectTemplate Package

>- Automates data initiation
>- Loads library
>- Runs munge scripts
>- Loads data
```{r eval = F}
library('ProjectTemplate')
load.project()
```

>- <http://projecttemplate.net/getting_started.html>
>- Automates data initiation
>- Loads library
>- Runs munge scripts
>- Loads data
<code>
library('ProjectTemplate')<br />
load.project()
</code>
>- <http://projecttemplate.net/getting_started.html>
## munge

Expand All @@ -176,50 +180,50 @@ load.project()
<footer class="blockquote-footer">www.dictionary.com</footer>
</blockquote>

- A ProjectTemplate directory
- Order numerically in the order the scripts should be run:
- 01-munge.R
- 02-Lexis.R
- A ProjectTemplate directory
- Order numerically in the order the scripts should be run:
- 01-munge.R
- 02-Lexis.R

## R | (src, py, cpp, or whatever)

- <code>00-cleaner.R</code> - read in raw data and save in <em>data</em>
- <code>01-main.R</code> - main script file
- <code>99-helper.R</code> - custom functions to be read in at start of script
- <code>data.R</code> - How you can create a data dictionary in R!
- <code>00-cleaner.R</code> - read in raw data and save in <em>data</em>
- <code>01-main.R</code> - main script file
- <code>99-helper.R</code> - custom functions to be read in at start of script
- <code>data.R</code> - How you can create a data dictionary in R!

## Other Directories

- config
- ProjectTemplate configuration files, e.g.:
- Auto-munge
- Auto-load packages
- Auto-import cache/data
- inst
- Auto generated files used by some package-related functions
- Vignettes
- config
- ProjectTemplate configuration files, e.g.:
- Auto-munge
- Auto-load packages
- Auto-import cache/data
- inst
- Auto generated files used by some package-related functions
- Vignettes

## Other Possibilities
## More Directory Ideas

<div class = "col2">

- shiny
- docker
- logs
- diagnostics
- man/doc
- graphs
- tests
- reports/vignettes
- shiny
- docker
- logs
- diagnostics
- man/doc
- graphs
- tests
- reports/vignettes

</div>

# Reporting | Biometrics R Markdown Templates

## Reporting

```{r, echo = F, out.extra = "class='centre'", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "Slide5.JPG"))
```{r, echo = F, out.extra = "figure", out.width = "50%"}
knitr::include_graphics(file.path("assets", "images", "07_Slide5.JPG"))
```

Expand All @@ -237,8 +241,8 @@ knitr::include_graphics(file.path("assets", "images", "Slide5.JPG"))
<footer class="blockquote-footer"><https://rmarkdown.rstudio.com/></footer>
</blockquote>

```{r, echo = F, out.extra = "class='centre'", out.width = "15%"}
knitr::include_graphics(file.path("assets", "images", "rmarkdown.png"))
```{r, echo = F, out.extra = "figure", out.width = "15%"}
knitr::include_graphics(file.path("assets", "images", "07_rmarkdown.png"))
```

Expand All @@ -253,23 +257,23 @@ Live demo
## Version Control

<div class = "col2"><p>
```{r, echo = F, out.extra = "class='centre'", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "github_logo.png"))
```{r, echo = F, out.extra = "figure", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "07_github_logo.png"))
```

```{r, echo = F, out.extra = "class='centre'", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "gitlab.png"))
```{r, echo = F, out.extra = "figure", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "07_gitlab.png"))
```

```{r, echo = F, out.extra = "class='centre'", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "logos__Bitbucket.png"))
```{r, echo = F, out.extra = "figure", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "07_logos__Bitbucket.png"))
```

```{r, echo = F, out.extra = "class='centre'", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "cran.png"))
```{r, echo = F, out.extra = "figure", out.width = "75%"}
knitr::include_graphics(file.path("assets", "images", "07_cran.png"))
```

Expand All @@ -279,21 +283,21 @@ knitr::include_graphics(file.path("assets", "images", "cran.png"))

## Coding Tips

- Be consistent:
- Values:
- "day1" vs "day_1" vs "Day 1"
- "5th May 1970" vs "01-05-1970" vs "05/01/1970" vs <mark>1970/05/01</mark>
- Variables:
- <code>FirstName</code> vs <mark><code>first_name</code></mark>
- <code>sex</code> vs <mark><code>female</code></mark>
- Use variable names that a human can understand
- Document/comment your code!
- Be consistent:
- Values:
- "day1" vs "day_1" vs "Day 1"
- "5th May 1970" vs "01-05-1970" vs "05/01/1970" vs <mark>1970/05/01</mark>
- Variables:
- <code>FirstName</code> vs <mark><code>first_name</code></mark>
- <code>sex</code> vs <mark><code>female</code></mark>
- Use variable names that a human can understand
- Document/comment your code!

## Useful Tools/Packages

>- R Studio IDE
>- Tidyverse - data wrangling and visualisation
>- repmis: Miscellaneous Tools for Reproducible Research
>- captioner: Store figure and table captions and print them later
>- devtools
>- Telethon Kids Biometrics package <https://github.com/TelethonKids/biometrics>
>- R Studio IDE
>- Tidyverse - data wrangling and visualisation
>- repmis: Miscellaneous Tools for Reproducible Research
>- captioner: Store figure and table captions and print them later
>- devtools
>- Telethon Kids Biometrics package <https://github.com/TelethonKids/biometrics>
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 2b201fc

Please sign in to comment.