Skip to content

TOPIC: R

Ben Tully edited this page Jul 13, 2020 · 34 revisions

Suggested prerequisites for this topic

Overview

Lessons

Lesson 1 -- Introduction to R & access to RStudio Cloud

Introductory material

Date posted: 06 April 2020
Author(s): Dr. Sarah Hu, Dr. Liz Suter, Dr. Alexis Marshall
Instructor(s): Dr. Sarah Hu, Dr. Liz Suter, Dr. Alexis Marshall

  • Understand RStudio working environment
  • Basic syntax in R
  • Assigning a variable

Content | Video presentation

Interactive material

Date posted: 08 April 2020
Author(s): Dr. Sarah Hu, Dr. Liz Suter, Dr. Alexis Marshall
Instructor(s): Dr. Sarah Hu, Dr. Liz Suter, Dr. Alexis Marshall

Video presentation


Lesson 2 -- Dealing with data frames

Introductory material

Date posted: 11 April 2020
Author(s): Dr. Ella Sieradzki
Instructor(s): Dr. Ella Sieradzki

  • Basic data table manipulation
  • Import test data into R from .csv format
  • Applying basic functions to a data table

Content | Video presentation

Interactive material

Date posted: 20 April 2020
Author(s): Dr. Ella Sieradzki
Instructor(s): Dr. Ella Sieradzki

Video presentation


Lesson 3 -- Introduction to Tidyverse

Introductory material

Date posted: 22 April 2020
Author(s): Dr. Sarah Hu
Instructor(s): Dr. Sarah Hu

  • Overview of data frames, matrices, and tibbles
  • Showing how to work with data tables in base R vs. Tidyverse

Content | Video presentation

Interactive material

Date posted: 22 April 2020
Author(s): Dr. Sarah Hu
Instructor(s): Dr. Sarah Hu

Video presentation


Lesson 4 -- Dealing with NA

Interactive material

Date posted: 6 May 2020
Author(s): Dr. Philip Leftwich
Instructor(s): Dr. Philip Leftwich

  • Using RMarkdown format to plan chunks of code
  • Tutorial on how R handles empty (NA) data cells

Content | Video presentation


Lesson 5 -- Introduction to Plotting in R

Interactive material

Date posted: 9 May 2020
Author(s): Dr. Ella Sieradzki
Instructor(s): Dr. Ella Sieradzki

  • Scatter plots in base R and ggplot2

Content | Video presentation


Lesson 6 -- Plotting & Data Wrangling Part II

Interactive material

Date posted: 14 May 2020
Author(s): Dr. Sarah Hu
Instructor(s): Dr. Sarah Hu

  • Bar plots and box plots with ggplot2
  • Plot annotations (e.g., colors, axis labels, etc.)
  • Tidyverse data wrangling review
  • Long-format data frame
  • Making a taxonomy bar plot

Content | Video presentation


Lesson 7 -- Correlations and linear models

Interactive material Part 1

Date posted: 26 May 2020
Author(s): Dr. Jacob Cram
Instructor(s): Dr. Jacob Cram

Content | Video presentation

Interactive material Part 2

Date posted: 6 June 2020
Author(s): Dr. Jacob Cram
Instructor(s): Dr. Jacob Cram

Content | Video presentation


Lesson 8 -- Ordination

Lesson 8a

Demonstration

Date posted: 26 June 2020
Author(s): Dr. Liz Suter
Instructor(s): Dr. Liz Suter

  • Amplicons crossover tutorial, see Topic Amplicons Lesson 5 for more
  • Using the output from Qiime2 analysis in Topic Amplicons Lesson 4
  • Import ASV table into phyloseq
  • Explore functionality of phyloseq: making tree, re-rooting tree, bar plot of taxa
  • Ordinations with phyloseq: PCoA, weighted UniFrac PCoA, NMDS

Content | Video presentation

Primary tools/programs used:


Lesson 8b

Demonstration

Date posted: 7 July 2020
Author(s): Dr. Sarah Hu
Instructor(s): Dr. Sarah Hu

Content | Video presentation - Part 1 | Video presentation - Part 2


Extended Resources and Publications

List of shortcut commands reviewed

  • Execute command in R: (Mac) COMMAND+ENTER and (PC) CONTROL+ENTER
  • Comment (#) or uncomment whole line: (Mac) COMMAND+SHIFT+C and (PC) CONTROL+SHIFT+C
  • Insert -> operator: (Mac) OPTION+- and (PC) ALT+-

List of questions addressed during R Office hours

  • When you do cbind does it make it a dataframe and if not what is the difference between dataframes and cbinding?
    Answer: cbind() makes a matrix, while data.frame() makes a dataframe, otherwise they behave very similarly. To add, if you cbind() numeric and character type columns, it will make everything a character (because matrices require all contents are the same data type.
    • Compare data frames and matrices: Data frames and matrices are similar, but have some key differences. Matrices are basically a grid of things, those could be numbers or character strings. Data frames are technically lists, so each column can be a column of different data "types". Meaning, one column of a dataframe could be words (Factors) and other numbers.
  • For index locations in lists or matrices, the first item is index 1, is this correct? (vs. python with 0 indexing) Answer: yes!