SORTEE / peer-code-review

https://sortee.github.io/peer-code-review/
4 stars 4 forks source link

[CodeReviewRequest] #6

Open AlysY opened 2 years ago

AlysY commented 2 years ago

Author: AlysY Repo: https://github.com/menzies-hotspots/AMR-HOTspots Aim: I have 2 main queries. How could I set up the structure of having multiple scripts to be clearer to other people? I haven't collaborated on scripts before so improving the readibility and logic is important to me. Secondly, if anyone has experience with shiny then how I could simplify the code, for example using modules? File Info: This repo creates a shiny app here https://anti-microbe-res.shinyapps.io/hotspots/ displaying information regarding antimicrobial resistance in Australia. The shiny code and app are in the app.R file. This file sources 5 other files: 1_functions.R , 2_load_data.R , 3_edit_this.R , 4_aesthetics.R , and 5_shiny_code.R . I usually lump all my code into one file, so this is my first time trying to split it logically.

egouldo commented 2 years ago

Hey @AlysY, I'll speak to your first query, and leave the shiny question to shiny experts.

I would suggest trying to use the targets package to streamline your pipeline. The core idea is that you modularise your code into functions, and then call these functions within a Yaml file which runs the whole analysis pipeline. The logic can easily be communicated to others in the targets.yml file that specifies and drives the whole pipeline, and there are functions to visualise the workflow for when it starts to get complicated. Here's an example from one of my projects that I'm working on: image You can also run the whole pipeline with a single command: tar_make(). It caches the outputs from previous runs and checks to see if your scripts have changed, and therefore only executes the parts that have changed and any dependencies when you go to re-run things. If you work with a lot of big objects, then this caching functionality could be really helpful so you don't have to sit around for hours or days waiting for parts to re-run.

Here's the user manual and some documentation on getting started. It took about half a day for me to get it up and running once I figured out the basics.