Handout

Reproducing Visualization in Publications

Quick recap/practice To warm up, we’re going to use one of Cassandra’s data sets, which has chromosome positions and z-scores. We’ll do each of these exercises together. # Load in the data BSAResults = read.

Pivoting and ggplot2

Function cheatsheet Base R mean() sum() head() tail() length() dim() as.numeric() as.character() typeof() unique() - NEW - prints each categorical value only once (so the unique of c(1,2,2,4,5,5,5,8) would be 1,2,4,5,8) Dplyr filter() group_by() summarize() na.

ggplot2 and dplyr

Review A quick review before we get into more complicated exercises: #Load in your data penguins <- read.csv("penguins.csv") #Look at the column names and types of your data using str() str(penguins) ## 'data.

Introduction to ggplot2

Review A quick review before we get into more complicated exercises: #We can create a data frame using the c() function myplants <- data.frame(Plants = c("Aloe", "Pothos", "Spider", "ZZ", "Snake", "Aloe", "Pothos", "Spider", "ZZ", "Snake"), Growth = c(1.

Functions and Data Types

Outline Review: Write yourself some functions Types: How they matter and how to avoid being bitten by them Function practice: Normalizing RNA-Sequencing We will be using part of the data from a study on spinal motor neurons.

Understanding Functions

Review Let’s create our data frames again by running the following code: NewDataFrame <- data.frame(Random = c(4, 20, 10, 21, 63, 3, 14, 60, 9, 6), Index = 1:10, Categories = c("Month", "Day", "Month", "Day", "Year", "Month", "Day", "Year", "Month", "Day")) Examples for plotting subsetted values If you wanted to plot only specific values, you could use these same booleans inside the functions to plot.

Understanding Indexing and Subsetting

Indexing What do we mean by indexing? So far, we’ve worked with data frames in R. Each data frame is really a set of rows and columns with values populated, and these can be broken down into what are called vectors.

Hands-On Data Wrangling

Loading data Following what we did last week, we are going to keep working with the penguins today. You can find the dataset after you extracted session3.zip which you can download from here.

Prepare your computer for R

AGENDA Introductions Installing R This Worksheet :) Adpated from material curated by Eugene Plavskin and Grace Avecilla Exploring RStudio The console: Where you run commands one by one (bottom) The environment: Where you can see what is loaded in R (upper right) The file explorer: An easier way for you to find files (otherwise you’ll need to know the path of a file to use it in R; lower right) Installing packages Packages are like kits in experiments: They package the reagents and instructions for otherwise complicated processes for you.