2.R_basics
R: How to make professional and beautiful plots
1. lnstall R and Rstudio
RStudio: https://www.rstudio.com/

Open RStudio platform:

2. R basics
R reference card:
https://cran.r-project.org/doc/contrib/Short-refcard.pdf
basic data types
vector
matrix
list
data frame
3. install.packages
Common used packages
To load data:
RMySQL: read in data from a database or Excel.
xlsx: read in data from a Excel.
To manipulate data:
stringr: easy to learn tools for regular expressions and character strings.
reshape2: transform data between wide and long formats.
To visualize data:
gplots: heatmap.2
ggplot2: plotting system for R, based on the grammar of graphics
plotly: R package for creating interactive web-based graphs
To model data:
lme4, nlme: Linear and Non-linear mixed effects models
randomForest: Random forest methods from machine learning
glmnet: Lasso and elastic-net regression methods with cross validation
NMF: do non-negative matrix factorization
To do bioinformatics:
limma, DESeq2, edgeR: do differential expression (https://www.nature.com/articles/nprot.2013.099\
survival: Tools for survival analysis
motifRG, MotIV, MotifDb: motif search and enrichment
enrichR: GO term enrichment
To write your own R packages:
devtools: An essential suite of tools for turning your code into an R package.
To color your figure:
colorbrewer: Creates nice looking color palettes especially for thematic maps http://colorbrewer2.org/
4. Statistics
R reference card (introductory statistics):
http://www.u.arizona.edu/~kuchi/Courses/MAT167/Files/R-refcard.pdf
5. Data mining
R reference card (data mining):
https://cran.r-project.org/doc/contrib/YanchangZhao-refcard-data-mining.pdf
6. Data visualizations
Basic visualizations
Histogram

Bar / Line Chart


Box plot

Scatter plot

Advanced visualizations
ggplot2: http://ggplot2.tidyverse.org/reference/

The Anatomy of a Plot

plot heatmap using ggplots

Homework
level 1: type the code in your computer and understand the meaning for each command
level 2: create one heatmap using function "heatmap.2" in package "gplots" (https://www.rdocumentation.org/packages/gplots/versions/3.0.1/topics/heatmap.2\ or package "pheatmap" (https://github.com/raivokolde/pheatmap
download link: Week_2_files/homework/plotHeatmap.zip
level 3: create your own plots using other packages, like plotly(https://plot.ly/r/, ggvis(http://ggvis.rstudio.com/
download link: Week_2_files/homework/plotHeatmap.zip
Reference
http://sape.inf.usi.ch/quick-reference/ggplot2
http://tutorials.iq.harvard.edu/R/Rgraphics/Rgraphics.html
https://www.analyticsvidhya.com/blog/2015/07/guide-data-visualization-r/
Last updated