From Reproducible to Reusable

NHS RPySOC 2024

Nov 22, 2024

Thoughts from HACA 2024

Illustration of a woman at a laptop giving a presentation.

  • Wow people are doing some great work
  • Inspiring to see people proudly sharing GitHub links
  • Wouldn’t it be amazing if everyone knew about and used this work

My Code Utopia

Illustration of a woman sat in a woodland.

Work on great open source code, together, publicly, across the system

Meet Nina

Profile picture of a woman (illustrated).

  • Analyst at Isle of Wight NHS Trust
  • Learnt R through the NHS-R community
  • Loves video games and her cat Dennis
  • Has been asked to model waiting times for the maternity unit

She searches the national public health code library

  • Searches for waiting list models
  • Filters for R programming
  • All RAP certified ⭐
  • Maintained by trusted organisations

Illustration of a woman using a search functionality.

The perfect repository

  • Open license
  • 100% test-coverage
  • Available on CRAN & NHS package manager
  • Diverse collaborators
  • Website with articles, examples and synthetic data

Illustration of a woman programming, she is punching the air with joy.

Adapt & contribute

  • Her team has already got a databricks pipeline for pre-processing HES data
  • Make a PR to expand the function for her model
  • Spots an edge case not covered by tests and contributes a patch
  • Learns about withr::with_seed()

Illustration of three people having a meeting with their laptops.

Learn & Share

Illustration of a woman sat writing an article.

  • Delivers a branded Quarto report with her analysis
  • Cites the package and data linkage
  • Writes a blog post about the project for NHS-R
  • Someone from another NHS Trust sees this

Doesn’t this sound lovely

Illustration of a woman holding a large heart.

We’re already part-way there

  • Growing number of RAP projects on GitHub
  • Analysts are skilling up in function writing and git
  • Teams are using repository templates
  • Useful functions being shared in boilerplate code
  • Collaborative projects in NHS R Community

Illustration of a woman next to a line graph. The graph is going up. There are five points and two of them are ticked.

From Reproducible to Reusable

Data
Same Different
Analysis Same Reproducible Replicable
Different Robust Reusable

What do other people think?

“I think the reusability point is crucial, and perhaps the most important part of RAP”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“Reproducible generally falls on the ‘covering your backside’ side of things for me”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“Maybe ‘RAP’ should really be ‘RRRAP’ (reproducible, reusable and replicable)”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“Reduce, reuse, recycle works well in this context: reduce reinventing the wheel, reuse other people’s code, recycle your code to use it again or let other’s use it”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“Reusing code is a bit of a psychological shift. When you write something yourself, you know where each step came from and how it fits into what you’re trying to do.”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“In a resource constrained world these could be in direct conflict. Do you spend the time ensuring the results are replicable, or do you sacrifice some of that by making it more reusable?”

Illustration of a woman with two chat speech bubbles.

What do other people think?

“I don’t know what code has already been developed in my team - never mind in different organisations!”

Illustration of a woman with two chat speech bubbles.

What are the challenges?

  • NHS is not one organisation
  • Nervousness developing in public
  • Thinking small
  • Discoverability
  • Upskilling in package development
  • Infrastructure
  • Resource

Illustration of a woman kicking a ball at a wall to break it.

What can we do?

Illustration of a person rearranging three profile pictures of other people.

Build modular code

  • Think big picture
  • Design smaller, more modular functions
  • Build packages
  • Write for humans

Illustration of a person putting bricks into a hole in the wall.

Shout about it

Illustration of a woman speaking at a podium.

  • Write and speak about your work
  • Don’t wait until it’s finished to share
  • Seek others who might be interested
  • Ask to see code
  • Shout loud, be curious 🎙️

Reward reusablility

  • Borrow with pride
  • Celebrate those who share
  • …and those who adapt it
  • Could we have a reusability contest?

Illustration of a two people high-fiving.

Resources

With thanks to

  • Matt Dray
  • Lizzie Ellis
  • Sam Hollings
  • Jamie Lendrum
  • Jamie Riley
  • Tim Taylor
  • Rosemary Walmsley

Illustration of six profiles of people on a website.

Share your story

Illustration of a woman surrounded by icons of social media platforms.