Microbial Informatics

Lecture 03

Patrick D. Schloss, PhD (microbialinformatics.github.io)
Department of Microbiology & Immunology

Announcements

  • No class on Thursday. We will use first hour of Friday's lab to cover Thursday's material and then I will turn you loose to work on the lab material.
  • Some of you have gotten comments back from me already about your "Pull Requests". Responding to these will enable you to get a better grade if you can satisfy what I comment on.
  • Note that problems 2 and 3 need to be submitted as pull requests to different repositories as indicated in the assignment materials
  • My office is 1520A, not 1150, MSRB I [sorry!]

Learning objectives

  • Learn some best practices in using git
  • Learn how to integrate R code into R markdown documents using knitr
  • Learn to navigate your way around R
  • Learn the different types of variables within R

More git

  • When: Each commit should represent a single functionality or error fix.
  • How ("The seven rules of a great git commit message"):
    1. Separate subject from body with a blank line
    2. Limit the subject line to 50 characters
    3. Capitalize the subject line
    4. Do not end the subject line with a period
    5. Use the imperative mood in the subject line
    6. Wrap the body at 72 characters
    7. Use the body to explain what and why vs. how
  • git cheat sheet

Philosophy...

  • Think of this as a foreign language class.
  • There's a lot of vocabulary to learn in R, but a lot of it you can create on your own. E.g. sum command
  • Today we will be learning the basic parts of speech
  • Later we will learn about sentence structure
  • Programming languages have similar parts of speech and sentence structure, it's just a matter of getting the syntax right
  • The hard part is getting the thinking right!

Starting / running / quitting R

  • Many ways to customize your version of R
  • Get working directory: getwd()
  • Set working directory: Files -> More -> Change working directory
  • Quit R: q()
  • If there is a + instead of > as the prompt: Hit Control+C or esc
  • up arrow allows you to cycle through your history (it's also in the top right corner)
  • hitting tab from the command line auto-completes command and file names

Looking for help...

  • google
  • ?heatmap
  • example(heatmap)
  • apropos("heat")

Code chunks in knitr

  • Embed R code into reports, documents, and slide shows
  • Cheat sheet

{r, echo=TRUE, eval=TRUE}

exp(10)  
## [1] 22026

{r, echo=FALSE, eval=TRUE}

## [1] 22026

{r, echo=TRUE, eval=FALSE}

exp(10)  

{r, echo=FALSE, eval=FALSE}

Cache

  • , cache=TRUE
  • Evaluate it once so that you don't have to waste time redoing the analysis over and over
  • Can cause problems as documents get bigger and bigger; may need to compile in command line R

How to run code chunks

Code chunk output