Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to R for Life Scientists

Introduction to R for Life Scientists

Introduction to R workshop sponsored by the UVA Health Sciences Library. http://bioconnector.github.io/workshops/

Stephen Turner

June 25, 2014

More Decks by Stephen Turner

Other Decks in Education


  1. Introduction to R Stephen D. Turner, Ph.D. Bioinformatics Core Director

    1 Slides available at stephenturner.us/slides
  2. R is FREE. 4 Software Cost $1,140 - $4,370 +

    maintenance $8,700 - $140,000 / year $2,390 - $40,600 / year $2,150 + $1,000s for modules $0
  3. R Community 6 NYT: R is the “lingua franca” of

    data analysts inside corporations and academia. Norman Nie, scholar and co- founder of SPSS: R is “the most powerful and flexible statistical programming language in the world.”
  4. R Community 7 KDNuggets Poll Languages used for analytics, data

    mining, data science. http://www.kdnuggets.com/2013/08/languages-for-analytics-data-mining-data-science.html http://r4stats.com/
  5. R Community 8 CRAN = Comprehensive R Archive Network !

    http://cran.us.r-project.org/ ! Over 5,000 free add-on packages.
  6. R Community • Nearly 1000 free packages for bioinformatics analysis

    using R. • NGS analysis: - Manipulate: import FASTQ/bam, trim, transform, align, manipulate sequences, … - Applications: Quality Assessment, ChIP-seq, differential expression, RNA-seq, much more. - Annotation: gene, pathway, GO, homology, … Access GO, KEGG, NCBI, Biomart, UCSC, … • Much, much more: flow cytometry, DNA methylation, microarrays, TFBS analysis, eQTL analysis, functional annotation, … • BioC Community: Conferences (since 2002), mailing list, … • http://bioconductor.org/ 9
  7. Wind speeds. Inspired by http://hint.fm/wind/, currently on display at NYC

    MOMA. @cambecc Prosperity in France. http://coulmont.com/blog/ 2011/12/11/ah-36-000-communes/ (Article in French). @coulmont
  8. R and Big Data • What’s big data? - Too

    large to process using traditional processing applications 
 — Wikipedia - “Volume, velocity, variety” 
 — Doug Laney, 2001 - “When computing the answer takes longer than the cognitive process of designing the model” 
 — Hadley Wickham, R developer 22
  9. R and Big Data • ff: access datasets too large

    to fit into memory • bigmemory: store large objects in memory and files with external pointer, enabling transparent access from R to large objects. • pbdMPI: Interface to MPI • pbdNCDF4: multiple processes can read/write same file • snow (simple network of workstations): abstraction layer, hiding communication details from parallelized processed. • foreach: iterate over a collection without loop counter. • multicore: run parallel computation on computers with multiple cores without explicit user request. • RHIPE: interface between R and Hadoop • BatchJobs: Map/Reduce functionality to HPC systems using Torque/PBS, SGE, LSF, etc. • gputools: common data-mining algorithms implemented using nVidia CUDA language/library • Many, many more at http://cran.r-project.org/web/views/HighPerformanceComputing.html 23
  10. R as a programming language • New tools/procedures can be

    written in R, shared, and used by others. • Open-source. - Don’t know what a function does? Look at the code yourself. - Don’t like how a function works? Hack the code and re-write how it works yourself. • R packages: Extend R with more functions, data, graphics. - CRAN: >5,000 packages - Bioconductor: ~1,000 packages 25
  11. R as a programming language 26 Integration with other tools

    • twitteR: integration with Twitter - github.com/stephenturner/twitterchive • Call R from Python - http://rpy.sourceforge.net/ • Python from R - http://rpython.r-forge.r- project.org/ • Access a MySQL database (RMySQL) • Google Maps API (RgoogleMaps) • Interact with Garmin data / Strava API - github.com/stephenturner/trailprofile
  12. R as a programming language • Reproducible research - Point

    & click interfaces are NOT reproducible. - R code is written in plain text file. Running same code on same data should reproduce exact results. - R “scripts” are easily shared. - Latex, Knitr: Allow seamless integration of R code into self- documenting report. 27
  13. Resources 31 Programming Q&A Site. Over 40,000 questions tagged with

    “R”: http://stackoverflow.com/ CrossValidated Statistics Q&A Site. Over 1,000 questions tagged with “R”: http://stats.stackexchange.com/
  14. Resources 32 Computing for Data Analysis https://www.coursera.org/course/compdata ! R Programming:

    https://www.coursera.org/course/rprog Roger Peng: All videos on YouTube: http://www.youtube.com/user/rdpeng/videos
  15. Resources 33 TryR: A short, interactive course to let you

    jump right in. Learn and run code right in the browser. http://tryr.codeschool.com/ http://www.rseek.org/ A custom Google search engine for R-related topics.
  16. Resources • Quick-R: short examples, code:http://www.statmethods.net/ • University Resources: -

    http://www.ats.ucla.edu/stat/r/ - http://data.princeton.edu/R/gettingStarted.html - http://biostat.mc.vanderbilt.edu/wiki/Main/RS • Find the right package: - CRAN Tasks: http://cran.r-project.org/web/views/ - Bioconductor: http://www.bioconductor.org/packages/2.13/bioc/ - CRANtastic: http://crantastic.org/ • Cheat Sheets: - http://cran.r-project.org/doc/contrib/Short-refcard.pdf - http://cran.r-project.org/doc/contrib/Baggott-refcard-v2.pdf • Aggregated feed of 450 R blogs: http://www.r-bloggers.com/ • More: http://www.revolutionanalytics.com/r-language-resources 35