Skip to content

Commit

Permalink
last polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinteractive committed Apr 11, 2024
1 parent b108a6b commit 0ba7e5e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 42 deletions.
44 changes: 22 additions & 22 deletions slides/01_intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ image: thumbnails/hello.jpg
::: {.column width="70%"}
- Ph.D. in Statistics from University of Zurich, Bayesian Model Selection
- Biostatistician at Roche for 5 years, Data Scientist at Google for 2 years, Statistical Software Engineer at Roche for the last 4 years
- Co-founder of [RCONIS](rconis.com)
- Co-founder of [inferential.bio](https://inferential.bio) and [RCONIS](https://rconis.com)
- Multiple R packages on CRAN and Bioconductor, co-wrote book on Likelihood and Bayesian Inference, chair of `openstatsware`
- Feel free to connect
[`r fontawesome::fa("linkedin")`](https://www.linkedin.com/in/danielsabanesbove/)
Expand All @@ -32,15 +32,15 @@ image: thumbnails/hello.jpg
## `openstatsware`

::: columns
::: {.column width="50%"}
::: {.column width="70%"}
- [openstatsware.org](https://openstatsware.org)
- Since: 19 August 2022 - almost 2 years now!
- Where: American Statistical Association (ASA) Biopharmaceutical Section (BIOP), European Federation of Statisticians in the Pharmaceutical Industry (EFSPI)
- Who: Currently more than 50 statisticians from more than 30 organizations
- What: Engineer packages and spread best practices
:::

::: {.column width="50%"}
::: {.column width="30%"}
![](https://raw.githubusercontent.com/RConsortium/asa-biop-swe-wg/main/sticker/openstatsware-hex.svg){height="300"}
:::
:::
Expand All @@ -51,17 +51,16 @@ image: thumbnails/hello.jpg
- Create your own R `r fontawesome::fa("cube")`
- Learn about & apply professional `r fontawesome::fa("cube")` development workflow
- Learn & apply fundamentals of quality control for R `r fontawesome::fa("cube")`
- Get crash-course in version control to stay organized
- Try out modern collaboration techniques on GitHub.com
- Optimize your R code for correctness and speed
- Get crash-course in version control and modern collaboration techniques on GitHub.com
- Learn how to make an R `r fontawesome::fa("cube")` available to others
- Get a starting point for sustainable Shiny app development
- Optimize your R code for correctness and speed
- Learn how to approach the design and modularity of Shiny apps and how to test them

## Program outline: Day 1

```{r}
#| echo: false
#| style: font-size:0.95em!important;
#| style: font-size:0.8em!important;
readr::read_csv("resources/program.csv", col_types = "cc") |>
dplyr::filter(day == "1") |>
dplyr::select(- day) |>
Expand All @@ -72,7 +71,7 @@ readr::read_csv("resources/program.csv", col_types = "cc") |>

```{r}
#| echo: false
#| style: font-size:0.95em!important;
#| style: font-size:0.8em!important;
readr::read_csv("resources/program.csv", col_types = "cc") |>
dplyr::filter(day == "2") |>
dplyr::select(- day) |>
Expand All @@ -94,38 +93,39 @@ readr::read_csv("resources/program.csv", col_types = "cc") |>
- Local R development environment with
- git `r fontawesome::fa("git-alt")`
- Rtools/R/Rstudio IDE `r fontawesome::fa("r-project")`
- Install additional R packages using the [installation script](slides/download/install.R)
- Curiosity `r emoji::emoji("curious")`
- Positive attitude `r emoji::emoji("smile")`

## Speed intros and what would you like to learn?

- Name?
- Organization?
- Motivation for this workshop/ what would you like to learn
- Favorite food?
- Favorite music?
- Name? `r emoji::emoji("face")`
- Organization? `r emoji::emoji("office")`
- Motivation for this workshop/ what would you like to learn `r emoji::emoji("brain")`
- Favorite food? `r emoji::emoji("food")`
- Favorite music? `r emoji::emoji("music")`

## What do we mean by GSWEP4R\*?

::: aside
\* Good Software Engineering Practice for R
:::

- Applying concept of GxP to SWE with R
- Improve **quality** of R code/packages, particularly in regulated enviroments but not limited to!
- Applying concept of "Good XYZ Practice" to SWE with R
- Improve **quality** and **longevity** of R code/packages
- Not a universal standard; we share our perspectives
- Collection of best practices
- Do not reinvent the wheel: learn from IT/open source space
- Do not reinvent the wheel: learn from the community

## Why care about GSWEP4R?

- Move to / integration of R in pharma is clear trend
- R is one of the most successfull statistical programming languages
- R is a powerful yet complex *ecosystem*
- Core component: R packages
- Mature analysts: users & contributors
- Deep understanding crucial, even to just assess quality
- Analyses increasingly require complex scripts/programs </br> $\leadsto$ line between programming and data analysis blurs
- Value: de-risking use of R and efficiency gains
- Analyses increasingly require complex scripts/programs
- The concepts are applicable to other languages, too (Python, Julia, etc.)

## Start small - from script to package

Expand Down Expand Up @@ -196,10 +196,10 @@ knitr::include_graphics("resources/pkg_graph.png")

## {background-iframe="https://pharmaverse.org/" background-interactive="true"}

## GxP + R `r fontawesome::fa("cube")` = `r fontawesome::fa("heart")`
## Pharma perspective: GxP + R `r fontawesome::fa("cube")` = `r fontawesome::fa("heart")`

- Core infrastructure packages only through industry
- Quality, burden sharing: open-source [pharmaverse](https://pharmaverse.org/) and others
- Quality, burden sharing: open-source [pharmaverse](https://pharmaverse.org/) and [openstatsware](https://openstatsware.org)
- Open methodological packages can de-risk innovative methods
- R packages make (statistical/methodological) code
- testable (with documented evidence thereof, [CFR Part 11](https://en.wikipedia.org/wiki/Title_21_CFR_Part_11))
Expand Down
1 change: 0 additions & 1 deletion slides/02_r_packages.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export(my_sum)

- [R Packages (2e)](https://r-pkgs.org/)
- [Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html)
- [Rewriting R code in C++](https://adv-r.hadley.nz/rcpp.html)
- [Super technical details about R Markdown](https://www.youtube.com/watch?v=fiy32LjgGUE)

# License Information
Expand Down
1 change: 0 additions & 1 deletion slides/05_collaboration.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "5 Version Control & Collaboration"
date: "2023-10-17"
description: "Collaboration via GitHub + practical<br/>[Photo CC0 by THIS IS ZUN on pexels.com]{.copyright}"
image: thumbnails/collaboration.jpg
---
Expand Down
10 changes: 5 additions & 5 deletions slides/06_publication.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "6 Publication"
date: "2023-10-17"
description: "Publication of R packages + practical<br/>[Photo CC0 by Andrea Piacquadio on pexels.com]{.copyright}"
image: thumbnails/publish.jpg
---
Expand All @@ -24,7 +23,7 @@ image: thumbnails/publish.jpg

```yaml
---
url: https://openpharma.github.io/mmrm
url: https://openpharma.github.io/mmrm/latest-tag

template:
bootstrap: 5
Expand Down Expand Up @@ -52,7 +51,7 @@ reference:
- component
```
## {background-iframe="https://openpharma.github.io/mmrm/main/reference/index.html" background-interactive="true"}
## {background-iframe="https://openpharma.github.io/mmrm/latest-tag/reference/index.html" background-interactive="true"}
## Publication as GitHub Page
Expand All @@ -64,7 +63,7 @@ reference:
- To get started, use `usethis::use_pkgdown_github_pages()`
- Or, manually deploy site with `pkgdown::deploy_to_branch()`

## {background-iframe="https://openpharma.github.io/mmrm/main/" background-interactive="true"}
## {background-iframe="https://openpharma.github.io/mmrm/latest-tag/" background-interactive="true"}

# Licensing, Open sourcing, Versioning

Expand Down Expand Up @@ -190,7 +189,8 @@ Example message informing about the rejection of the last
- Free `R CMD check` runs on [different operating systems](https://docs.r-hub.io/#which-platform) before submitting to CRAN
- Supported by the R consortium
- Typically used via the [website](https://builder.r-hub.io/)
- There is also an R API: `rhub::check_for_cran()` is comfortable
- There is also an R API: `rhub::check()` is comfortable
- Note: New API with R-hub v2 since a few weeks ([details](https://r-hub.github.io/rhub/articles/rhubv2.html))
:::
:::

Expand Down
11 changes: 6 additions & 5 deletions slides/07_shiny.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "7 Shiny Development"
date: "2023-10-17"
description: "Best Practices for Shiny App Development<br/>[Photo by Pixabay on pexels.com]{.copyright}"
image: thumbnails/shiny.jpg
---
Expand Down Expand Up @@ -37,6 +36,8 @@ image: thumbnails/shiny.jpg

![](resources/wireframe.png){fig-align="center"}

## Shiny specific tool: `ShinyUiEditor` {background-iframe="https://rstudio.github.io/shinyuieditor/"}

# Architecture

## Architecture: Minimize code in Shiny
Expand Down Expand Up @@ -271,7 +272,7 @@ This "stringy" reactivity graph is easier to understand and debug

# Exercise: Wireframing

- Visit https://rstudio.github.io/shinyuieditor to get an overview
- Visit [ShinyUiEditor](https://rstudio.github.io/shinyuieditor) to get an overview
- Try to build a simple app and see how the code looks like
- Do you have an idea what could be simplified with modules?

Expand Down Expand Up @@ -444,9 +445,9 @@ You'll need few extra steps:

Let's look at the following examples.

- Read and execute [`testServer.R`](slides/examples/shiny/testServer.R). Play around with setting different UI inputs and adding additional server tests.
- Read and execute [`AppDriver.R`](slides/examples/shiny/AppDriver.R). Add a small additional feature to the app and test it.
- Have a look at [`testModule.R`](slides/examples/shiny/testModule.R). What is different here? Record some additional tests and integrate them into the code.
- Read and execute [`testServer.R`](examples/shiny/testServer.R). Play around with setting different UI inputs and adding additional server tests.
- Read and execute [`AppDriver.R`](examples/shiny/AppDriver.R). Add a small additional feature to the app and test it.
- Have a look at [`testModule.R`](examples/shiny/testModule.R). What is different here? Record some additional tests and integrate them into the code.

# References

Expand Down
10 changes: 5 additions & 5 deletions slides/08_optimization.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "8 Code Optimization"
date: "2024-03-20"
description: "Best Practices for Optimizing Code<br/>[Photo by Chris Peeters on pexels.com]{.copyright}"
image: thumbnails/speed.jpg
bibliography: references.bib
Expand Down Expand Up @@ -185,6 +184,7 @@ But it is not too difficult with [`Rcpp`](https://dirk.eddelbuettel.com/code/rcp

- Starting point: `Rcpp::Rcpp.package.skeleton()`
- Use [`RcppArmadillo`](https://dirk.eddelbuettel.com/code/rcpp.armadillo.html) for linear algebra
- Hadley Wickham's chapter [Rewriting R code in C++](https://adv-r.hadley.nz/rcpp.html)

Note: Adding C++ code to your package will in many cases increase the maintenance effort significantly.

Expand All @@ -195,8 +195,8 @@ Note: Adding C++ code to your package will in many cases increase the maintenanc

# Exercise

- Read [`bootstrap.R`](slides/examples/optimization/bootstrap.R) and understand what is going on.
- Run [`profbootstrap.R`](slides/examples/optimization/profbootstrap.R) to see where most of the time is spent - where?
- Read [`bootstrap.R`](examples/optimization/bootstrap.R) and understand what is going on.
- Run [`profbootstrap.R`](examples/optimization/profbootstrap.R) to see where most of the time is spent - where?
- In a second version of the function, `impl_2`, only update vectors inside the loop and then create a `tibble` once at the end.
- In a third version `impl_3` only subset the column instead of the whole `data.frame`. How much faster does it get?
- In a fourth version `impl_4` use the [`boot`](https://cran.r-project.org/package=boot) package.
Expand All @@ -206,6 +206,6 @@ Note: Adding C++ code to your package will in many cases increase the maintenanc

- Creators (initial authors):
Lukas A. Widmer and Michael Mayer, see their course [Go fastR – how to make R code fast(er) and run it on high performance compute (HPC) clusters](https://luwidmer.github.io/fastR-website/materials.html)
- In the current version, changes were done by (later authors):
Daniel Sabanes Bove [`r fontawesome::fa("github")`](https://github.com/danielinteractive/) [`r fontawesome::fa("linkedin")`](https://www.linkedin.com/in/danielsabanesbove/),
- In the current version, changes were done by (later author):
Daniel Sabanes Bove [`r fontawesome::fa("github")`](https://github.com/danielinteractive/) [`r fontawesome::fa("linkedin")`](https://www.linkedin.com/in/danielsabanesbove/)
{{< include _license_footer.qmd >}}
7 changes: 4 additions & 3 deletions slides/09_conclusion.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "9 Conclusion"
date: "2023-10-17"
description: "Discussion of learning experience, summary of workflow, conclusion and next steps.</br>[Photo by Ann H on pexels.com]{.copyright}"
image: thumbnails/conclusion.jpg
---
Expand Down Expand Up @@ -33,9 +32,9 @@ image: thumbnails/conclusion.jpg
Idea $\rightarrow$ Design docs $\rightarrow$ Programming $\rightarrow$ Quality check $\rightarrow$ Publication
- Don't waste time on maintenance
- Be faster with release on CRAN
- Fulfill regulatory requirements
- Fulfill quality requirements of yourself and stakeholders
- Refactor your one-off scripts that you want to use in a package
- Use assertions for all arguments $\rightarrow$ Usability/UX
- Use assertions for all arguments $\rightarrow$ better user experience
- Implement common generics like `print` and `plot`

## Ensuring Quality
Expand Down Expand Up @@ -106,6 +105,8 @@ image: thumbnails/conclusion.jpg
- Later publish it open source on GitHub and submit it to CRAN
- Learn about more tips and tricks how to extend R

![Photo by Pixabay on pexels.com](resources/stairs.jpg)

# License information

- Creators (initial authors):
Expand Down
Binary file added slides/resources/stairs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ba7e5e

Please sign in to comment.