reproducible$research$ - Texas A&M...
Transcript of reproducible$research$ - Texas A&M...
![Page 1: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/1.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
reproducible research A. Michelle Lawing
Ecosystem Science and Management Texas A&M University
College Sta,on, TX 77843 [email protected]
![Page 2: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/2.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Announcements
• May 5th is redefined day (go to your Friday classes), so no presenta,ons
• Final Project (2 op,ons) – 10% of final grade – Turn in a video of your final project (around three minutes, these will be posted on my webpage)
(e.g., h[p://www.kindealabs.com/) – Turn in a manuscript for cri,cal review and feedback.
![Page 3: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/3.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Schedule for today
• My presenta,on – on reproducible research
• Presenta,on on end to end reproducibility • Demonstra,on on end to end reproducibility
• ?BREAK • ?Tutorial on end to end reproducibility
![Page 4: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/4.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
reproducible research
![Page 5: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/5.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Cornerstones of the scien,fic method
• Reproducibility Does not make the science right or wrong
• Rigor To evaluate reproducibility
• Transparency To evaluate reproducibility
• Independent verifica,on Allows science to move forward
![Page 6: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/6.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Geeng help
• Post online ques,ons
• Email code to another R user
• Need to be able to get reproducible errors
• This allows someone else to copy and paste your code without changing anything
![Page 7: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/7.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Four items for Code Share
• R environment
• Required packages
• Data
• Code
![Page 8: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/8.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
R environment
• sessionInfo() #summarizes your R environment
• makes it easy to detect out of date packages
• usually I make a folder for each “project” and open the R script from within that folder – automa,cally takes me to the correct environment
![Page 9: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/9.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Packages
• Should be loaded at the top of the script
• Easy to see which ones are needed
• I usually include and comment out the install.packages() command to make it easy for installing packages.
![Page 10: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/10.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Data
• You can use r code to recreate data to output
• dput() outputs an ASCII text representa,on of your data
• save() writes an external representa,on of an R object
• write(), write.table(), write.csv
![Page 11: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/11.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Code
• write code that is easy to read by others • use spaces • make variable names concise, but informa,ve • use comments • remove everything that is not related • the shorter your code, the easier it is to understand
![Page 12: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/12.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Check for yourself
• Start up a fresh R session • Paste in your script
![Page 13: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/13.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Post it
• h[ps://gist.github.com/
• Gist is a simple way to share snippets and pastes with others. All gists are Git repositories, so they are automa,cally versioned, forkable and usable from Git.
![Page 14: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/14.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Reproducible Research Task View on CRAN
• h[p://cran.r-‐project.org/web/views/ReproducibleResearch.html
![Page 15: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/15.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
knitr() and Markdown
• special packages for reproducibility and document crea,on
• combines many other packages and their func,onality
• takes many input languages (e.g., R and Python) • output formats are op,onal (LaTex, HTML, Markdown, ASCII)
![Page 16: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/16.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Let’s Try
• In Rstudio, go to File > New File > R Markdown...
• Read in Title and Author, click OK
• You will see a new document with .Rmd extension
• Save this un,tled document
![Page 17: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/17.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
R Markdown
![Page 18: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/18.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
R Markdown
Click Knit HTML
![Page 19: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/19.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
R Markdown
• Your example markdown document should open as an html file.
![Page 20: reproducible$research$ - Texas A&M Universitypeople.tamu.edu/~alawing/materials/ESSM689/Repro.pdf · ESSM689$Quan,tave$Methods$in$ Ecology,$Evolu,on$and$Biogeography$ Ecosystem$Science$and$Management|$](https://reader030.fdocuments.in/reader030/viewer/2022041114/5f21ec0e76d8fc48b67400dd/html5/thumbnails/20.jpg)
ESSM 689 Quan,ta,ve Methods in Ecology, Evolu,on and Biogeography
Ecosystem Science and Management | Texas A&M University (c) 2015, A. Michelle Lawing
Let’s do it again
• michellelawing.info/Rmarkdown.Rmd
• michellelawing.info/Rmarkdown.html