-
Notifications
You must be signed in to change notification settings - Fork 12
Revisiting the research compendium: testing, automation, and review #5
Comments
I would be really interested in building tools to help facilitate the process of creating reproducible research compendia. Recently I adopted the approaches described in rrrpkg, and it was great! (rough example here). I managed to have a bit more time on my hands, and was really disciplined with how I built the analysis. This was really great when the input data needed to change, or I needed to update one model. Very very satisfying to just type However, recently I've been more pressed for time, and have started to do things in a way that "works for now", in an attempt to claw back some of the time that I need to get the analysis done. Then, a day, week, or a few months later, I'm suffering at my own hand because now I need to untangle the reproducibility issues that I've created. I've heard it said that one of the benefits of doing things in a reproducible way is that it slows you down, and makes you think. This is a good point, but in my experience you don't always have the time to think, when deadlines are fast approaching. Personally, my biggest problem with being reproducible is that the awesome frameworks can be fragile in the face of a scary deadline. So, I really want to work on a "pit of success" for reproducibility, so that the default option is to fall into the right thing, rather than struggle doing it. Two further thoughts:
|
One of the tensions I've found in this area is the difference between a "working" repo where one is developing ideas and doing exploratory work, and a fully formed workflow and analysis where you know what the outcomes should look like. I'd like to reduce the friction of moving from the former to the latter. |
Hi, I think having a template (folder structure, etc) to use for all your projects helps a lot to work reproducibly. You always start from it and just have to follow the design; no more extra time once you have designed everything to your liking. E.g. my template is here. See also @benmarwick research compendium here. We do all exploratory analyses as Rmarkdown documents in an Of course large outputs are always a problem (see also ropensci/rrrpkg#8). We choose not to git track them, and share them through dropbox, figshare, or similar. Hope this helps, and always interested to hear other ideas! |
@noamross I think you're right on about the tension between exploratory analysis and final report. Looking back, that is why the first paper was so much easier for me. I already had all the exploratory analysis done, and so when I changed over to the other template, I just filled in a template, shoved all the functions into an Having a template is definitely a great idea, @Pakillo, and like you say, it saves a lot of cognitive load, so you can spend more time thinking about the analysis. I think this is why the idea of using the r package workflow catches on nicely. People can rely on the workflow outlined by @hadley's devtools, and move through the steps. This is a big topic! It's kind of hard to know where to start. But one thought is that R packages are generally a growing product - many (most?) will continue iterating over what their purpose is, and will improve over time. Whereas a paper or a report has a finite ending, and the iterative process of writing, analysing, and re-writing is different to package development. I wonder if perhaps it might be useful to compare and contrast package development to analysis development? |
Great thread, something I struggle with regularly as well. My default is to stick with the R package structure for a new project, e.g. any exploration that's grown bigger than a a single self-contained .Rmd and for which I can think of a functional name for the repo. Like @njtierney says, this skeleton is quick to create with I tend to omit formal tests; I refactor code a lot early on and having to refactor the unit tests is just a pain. Maybe that's not ideal but oh well. I do tend to write at least minimal roxygen docs with an example; these provide easier-to-maintain tests and can be helpful; and mean I can leave travis-ci turned on to do at least some sanity checking without being a burden. Functions I don't want to document / test I just don't export so CHECK doesn't complain. Like @Pakillo , I do exploratory analysis in separate .Rmds (in a Caching for large data &/or long-running outputs is a special problem. I think I think both papers and packages have a finite life cycles with similar challenges. Early on it's figuring out where to draw the box -- stuff starts in one repo and then gets split out into multiple repos for different packages / papers as the project grows and becomes better defined. Knowing when to split is always hard for either research or software; I which someone would give me some rules-of-thumb. Since we don't sweat software 'releases' I agree that there's no sharp delineation point in software the way there is in publishing, but after submitting a paper there's still the iteration of peer review, and after acceptance there's still some lifetime of the repo where I'm at least continuing to re-use and maybe tweak things on that project. And I think there comes a time for both software package or paper/compendium where one transitions from active maintenance to sunset & archive, though perhaps that happens more immediately after publication for most papers/compendium than for most software packages. |
I'm thinking of of testing with a bit of a broader scope, including model diagnostics and data validation as done with assertr or validate. These tests may have boolean, text, or visual outputs, but I think its important to have a workflow that (a) separates them from the main products, and (b) ensures they are run and viewed with updates. One paradigm I was considering was saving the environments of each of the I've had trouble with remake, because of the overhead of moving from script-based organization that characterizes many projects to the functional approach. On the lifecycle issue, I think something like |
I'm following this discussion with great interest, especially the comments about testing and re/make, since I haven't found a natural place for those in my work, and I'm curious to see how others are using them. I think there's scope for some easy wins with tooling to increase the convenience using CI for research-compendia-packages. There was a nice paper on using CI for research pipelines recently: http://www.nature.com/nbt/journal/vaop/ncurrent/abs/nbt.3780.html Related to CI, I like @noamross's idea of Seems like @stephlocke's excellent new https://github.com/stephlocke/pRojects could be a good prototype for |
If y'all want to make use of pRojects I'm happy to do work to fold it into rOpenSci - I've made a lot of the Issues etc up for grabs and am keen to get other's opinions and requirements built in :) |
One idea that we might be able make progress on here is figure out what subset of package-checks from various tools (R CMD check, lintr, goodpractice, etc.) can be easily applied to non-package projects, and possibly create some lightweight wrappers, extensions, and/or docs for using them on directories at various levels of rigor (e.g., something with full-blown build system and package-style DESCRIPTION, something with standalone scripts, data, and Rmds) A possible home for this would be @stephlocke's https://github.com/lockedata/PackageReviewR |
@noamross random aside: rigger could be a fun name for this package (sounds like both rigger and rigour) |
@hadley +1, as in a former career, I actually had the title of chief rigger. ⛵️ |
It seems to me that there should be some sort of golden path to tread for reproducibility, sort of like @hadley Tostoy's (approximate) quote:
It seems that the same could mostly be said for reproducibility. There are very many ways that you can do reproducibility wrong, but my sense is that there should be a small set of ways to do it right. That said, I think talking about what went wrong in the past could still be helpful, sort of like Etsy's "Guilt-Free Post Mortems" that I have heard about on NSSD. So, do you think it might be useful to collect anti-patterns to reproducibility? I, ahem, may have a few horror stories to share. We could also, of course, share success stories, and things that went well. My thoughts are that this would help identify common problems, strong good patterns for reproducibility, and common anti patterns. Thoughts? |
@njtierney I hadn't heard the guilt-free post-mortems, but I definitely think the repro research autopsies would fit well with/be of interest for #64. |
There's a nice recent collection of success stories in https://www.practicereproducibleresearch.org, with a few chapters from R users (disclaimer: including me). I'm not aware of any surveys of anti-patterns, that sounds like it would be very useful, and help to give some priority to the items in various how-to lists for reproducibile research (e.g. http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003285). If we could identify the 20% of patterns or behaviors that are responsible for 80% of irreproducibility in research (if such a thing is quantifiable), and target those with some tooling to change those behaviors, there could be a big win. |
Let me try to summarize some of the stuff above as well as my own evolving thoughts on this. I realize that this project has several components, any one of which could be an unconf project on its own: Bootstrapping compendiaThe "project template" approach has been tackled repeatedly, and well, but beyond A good start might be creating a set of project templates ( Code analysis and testing
Training and review guides
|
I'm really interested in this and have started tackling the project setup and the testing / review of packages. I'd love to make these more community developed so it's not limited by time as I think the community at large can benefit. |
I really love this idea. In my work it is my mission to get people using tools to make their work more reproducible - it can be overwhelming to beginners to learn best practices and tools so having a starting point is great. I think we have to be careful to make this approachable enough so that it doesn't scare new users off (as @njtierney mentioned talking about the 'pit of success'). +1 to building on @stephlocke's pRojects package. I wonder too if there is something that can be done to help users create their own templates, perhaps built off some boilerplates? I've often heard people say that they would use ProjectTemplate etc but it's not quite the template they need. In government, we often have to do very similar projects repeatedly so custom templates would be very helpful. As an aside, another build system I've recently heard about is drake - I've never tried it but heard an interview with the author on the r-podcast. |
So I'm aiming to add a bunch of flags to the starter projects so folks can set exactly what they want in them. I'm hoping to extend the list of options to include, for instance, Makefiles, My attempts at Makefiles have been dismal failures. The package can also be wrapped so if someone want's a bespoke project function with internal standards, they can depend on pRojects, and use the createBasicProject as a starter like the Analysis and Training functions do https://github.com/lockedata/pRojects/blob/master/R/createAnalysisProject.R |
@ateucher “it can be overwhelming to beginners to learn best practices and tools so having a starting point is great” Yes, a thousand times yes-- and as someone who got overwhelmed by learning so many "best practices" in the beginning, this can lead to bad habits and/or just wasted time because the workflow you've got going satsfices. @stephlocke It's interesting that you mention Makefiles because when I tweeted a "Reproducible workflows in R" post I'd found a few weeks ago which included make-related things, one of the responses was that there's a related conceptual obstacle of some sort common to R users. |
@batpigandme interesting that post is by Will Landau, as he is the author of drake. Maybe that was the start of his inspiration for it. |
Oh, cool! I'll have to give drake a closer look. It was released pre-tweet,
but I'll have to take a closer look at drake with the concepts he mentioned
in mind.
…On Wed, May 3, 2017 at 5:34 PM, Andy Teucher ***@***.***> wrote:
@batpigandme <https://github.com/batpigandme> interesting that that tweet
links to a post by Will Landau, as he is the author of drake
<http://will-landau.com/2017/03/09/drake/>. Maybe that was the start of
his inspiration for it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAyw9JvyCBLeLLj2VV4izNqKyOkji4J3ks5r2PLLgaJpZM4L662K>
.
--
Mara
--------------------------------------------------------
Mara Averick | maraaverick@gmail.com
http://www.linkedin.com/in/maraaverick
|
My memory is hazy of trying to make the Makefile work, but I had a shell script that worked and I was trying to convert over with no luck whatsoever. And this was my trivial case! |
A possible Makefile idiom might be this example of a set of Rmd notebook files from Lincoln Mullen: https://github.com/lmullen/rmd-notebook/blob/master/Makefile Another possible Makefile idiom would be a set of scripts that should be run in-order. If the scripts have numbered filenames ( As for testing, I think I would separate an analysis-repo testing package from a package reviewing package, though the package reviewing task is something I'm interested in, too! |
ha, that's yet another topic in which I could greatly use the wisdom of @jennybc. My students start from such different backgrounds that my grading tries to reflect the amount of effort &/or learning much more than what is objectively accomplished... |
One simple thing would be to add some metadata to DESCRIPTION that identifies this as a compendium (not a package), and then travis could either:
|
Also see usethis, where I've been pulling out all the |
I'm more of a "sensible defaults with config" person, but I really like the metadata in DESCRIPTION convention. e.g., I also just started wrapping @jennybc's |
@hadley brilliant. I love the idea of just leveraging DESCRIPTION metadata & Yay! My students can now face the 😂 and 😭 and 🔥 of travis builds on their very own homework assignments. |
I think the place to start would be to try and use the existing type field. If that doesn't break
Or maybe
Figuring out how to cleanly parameterise travis builds in this way is useful enough that we should do it independently of the other compendium issues. We just need some simple convention + default that make this easily extensible. Maybe we could have the value of the field be the name of the package, and then travis just installs that package then calls |
Not only is If you use |
oh right, using a custom Of course a utility that generated such a template |
I did some work on this type of generation on the weekend (got a post scheduled on it) but this custom travis file plus shell scripts generates each Rmd in a specific dir Dynamic file gen like generating DESCRIPTION and .travis.yml is the next thing on the pRojects todo for us to get to grips with so that we can start producing files that contain content based on the users input. Have the use* in a separate package will help as we make extensive use of these in pRojects (Thanks for the kind words about pRojects @cboettig btw - very much appreciated!) |
One problem with using @cboettig I think such a capability should be baked into travis. Auto-building an |
No it doesn't, you should be able to use the default |
Hi, For the record, here are other repos/templates for projects structured as R packages still not mentioned (I think): |
I have summarised my take aways from this discussion into a research compendia proposal (google doc). Comments welcome! |
Some observations on directory naming practices of research compendia spotted in the wild: It's a very small sample, but it seems that Naming the main compendium directory |
Is there something more general than analysis but more specific than scripts? Should it be a verb or a noun? (I think a noun because all the other directories are nouns). Should it be singular or plural? (This is harder because they're mostly singular apart from OTOH |
|
Thanks for the "in the wild" summary @benmarwick! "Wild" very definitely describes https://github.com/USEPA/LakeTrophicModelling/ and that ended up being a bit of a mess by the end. Wish I could say the decision to have a subfolder in vignettes was a conscious one, but it wasn't. Since that time I have used a separate |
Maybe stating the obvious, but while this sample is great it's worth noting they aren't very independent. E.g. I think Megan's original layout was more representative of what I see people doing before we all, um, piled in duffymeg/BroodParasiteDescription#1 Okay, so I'm all for establishing convention over configuration, but I'm not actually clear on why we need to specify a choice here. I see that using the existing |
One significant issue that isn't addressed in Hadley's excellent doc summary is publishing / sharing of output. I think this is one area that could benefit hugely from both more normative conventions and additional tooling. Personally, I like to see the Even so, this approach has problems or at least open questions on how to do it. The default of dumping output (Aside to the RStudio team: it would also be easier to make Contrast this situation to the case in R packages where we now have |
@cboettig This, to me, gets back to the tension between "working" and "final" compendia. I like the solution of A bigger challenge in input/output is (I think getting GitHub render to .Rmd files was a mistake, myself.) |
Just wanted to second the issue on data output. The Google doc comments reflect a lot of variation in how we view derived data:
Closing off my earlier comment about publishing/discovering final results, I agree with the general proposal that |
I'm a little late to the party on this one, but I wanted to sketch out the approach I took in easyMake in case it's helpful for the "working" and "final" compendia tension. What easyMake does is reads the source files in an R project for input (like I think this is a pretty promising approach to resolving the "working" and "final" tension that @noamross mentioned because so long as you break your analysis into scripts you should be able to generate a working Makefile from those scripts. This helps new users get started with Makefiles and also is a good way to take a look at the whole project and see how your workflow could be improved. I'm not sure if easyMake is an optimal implementation of this approach but the idea of automatically detecting dependencies based on the IO functions might be worth incorporating into the research compendia packages. |
I've fleshed out some notes on what a reactive build system my look like for R: https://docs.google.com/document/d/1avYAqjTS7zSZn7JAAOZhFPkhkPvYwaPVrSpo31Cu0Yc/edit#. This started out like "make for R", but has ended up fairly far away, drawing just as much inspiration from shiny. Your comments are greatly appreciated! |
Testing package development happening here: https://github.com/ropenscilabs/checkers |
Inspired by the discussion here, I recently worked with @danki, @MartinHinz and others at @ISAAKiel to make a start on an rrtools package for bootstrapping a research compedium: https://github.com/benmarwick/rrtools We carefully reviewed the literature on best practices and tried to boil them down to a novice-friendly workflow. It's an opinionated approach, for sure, but it also gives options at key decision points that tries to capture the diversity we see in the discussion above and elsewhere. No doubt we've missed some variants, but we're happy to take suggestions to make it more broadly useful! |
Blog post about this project: https://ropensci.org/blog/2017/06/20/checkers/ |
In the 2015 unconf, one output was a document of best practices for research compendia, a self-contained repository for a research analysis. Many of the ideas in this, and similar work, derive from best practices from R packages. In the past few years, there have been advances and wider adoption of a number of R package development practices, notably in package testing, automation of testing/checking/building, and best practices for code review. R-based research compendia have not coalesced around a similar set of practices yet. I would aim to build tools that would help address this, with these questions.
R CMD check
, that could be widely adopted?(I have thoughts on most of these that I'll add below or in a linked document for these in a bit)
Possible outputs include
The text was updated successfully, but these errors were encountered: