4.R

R: How to make professional and beautiful plots

1) lnstall R and R Studio

R: https://www.r-project.org/

R Studio: https://www.rstudio.com/

2) Reference cards for data analysis

3) R packages

How to install R Packages:

> install.packages("PACKAGE")

# using bioconductor.org
> source("https://bioconductor.org/biocLite.R")
> biocLite("PACKAGE")

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: link

  • 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:

4) Homework

  1. Plot one heatmap using function "heatmap.2" in package "gplots" or package "pheatmap" . Here are some files to help you finish this job: plotHeatmap.zip .

  2. Make your own plots using other packages, like plotly or ggvis.

5) Teaching video

a.Basics

@Youtube

@Bilibili

b.Advanced (by Yang Eric Li)

@Youtube

@Bilibili

6) References

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