Laptop Setup Instructions
Instructions for setting up your laptop can be found here: Laptop Setup Instructions
Difference Between R and R Studio
RStudio doesn’t know where libraries are installed, when they are not installed through the RStudio package manager. To tell RStudio the location, you can define the path in a startup file. Create a file called .Renviron
. Inside there:
R_LIBS=<R Library Path of other installed packages>
That was the problem when students installed things in R Studio at the command line using the R command install.package()
.
… or you could use the package manger to install libraries.
Syntax highlighting
… of scripts in the R editor does not seem to work under Windows. If you want highlighted syntax, use RStudio instead. Or (seriously), get a Mac.
Helpful Materials
Day 1
Welcome
*Faculty: Michelle Brazas*Module 1: First Steps
*Faculty: Boris Steipe*Lecture:
2015_Intro_to_R.pdf
2015_Intro_to_R.mp4
Scripts:
Data:
Practical:
Resources:
Helpful links
- The R help mailing list
- Rseek: the specialized search engine for R topics
- R questions on stackoverflow
- The Comprehensive R Archive Network CRAN
- The CRAN task-view collection
- Bioconductor task views
Module 2: Programming Basics
*Faculty: Boris Steipe*Practical:
Module 3: Using R for Data Analysis
*Faculty: Boris Steipe*Scripts:
Resources:
Practical:
Code Scratchpad
?read.csv
rawDat <- read.csv("table_S3.csv",
header = FALSE,
stringsAsFactors = FALSE)
head(rawDat, 10)
rawDat <- rawDat[-(1:6), ]
head(rawDat, 10) # now note rownames problem
types <- c("genes",
"B.ctrl",
"B.LPS",
"MF.ctrl",
"MF.LPS",
"NK.ctrl",
"NK.LPS",
"Mo.ctrl",
"Mo.LPS",
"pDC.ctrl",
"pDC.LPS",
"DC1.ctrl",
"DC1.LPS",
"DC2.ctrl",
"DC2.LPS",
"cluster")
colnames(rawDat) <- types
# Fix rownames problem
nrow(rawDat)
rownames(rawDat) <- 1:nrow(rawDat)
for (i in 2:ncol(rawDat)) {
rawDat[,i] <- as.numeric(rawDat[ ,i])
}
typeInfo(rawDat)
filtering, preparing data for heatmap
sup3 <- read.csv("table_S3.csv",
skip = 6,
header = FALSE,
colClasses = c("character", rep("numeric", 15)),
col.names = c("genes",
"B.ctrl", "B.LPS",
"MF.ctrl", "MF.LPS",
"NK.ctrl", "NK.LPS",
"Mo.ctrl", "Mo.LPS",
"pDC.ctrl", "pDC.LPS",
"DC1.ctrl", "DC1.LPS",
"DC2.ctrl", "DC2.LPS",
"cluster"),
stringsAsFactors = FALSE)
summary(sup3[ ,2])
head(sup3)
dfMo <- abs(sup3[ ,"Mo.ctrl"] - sup3[ ,"Mo.LPS"])
summary(dfMo)
# example of order()
dfMo[1:5]
order(dfMo[1:5])
dfMo[order(dfMo[1:5])]
# for all genes ...
dfMoOrdered <- order(dfMo)
dfGenes <- tail(sup3[dfMoOrdered, 1], 10)
# convert to matrix
sup3M <- as.matrix(sup3[ ,2:15], ncol=14)
heatmap(sup3M)