%\VignetteEngine{knitr::knitr} %\VignetteIndexEntry{10 Visualization in R——Slides} \documentclass[xcolor=dvipsnames]{beamer} \usepackage{biocutorslides} \hypersetup{colorlinks,linkcolor=,urlcolor=Blue} \AtBeginSection[] {\begin{frame} {Outline} \tableofcontents[currentsection] \end{frame}} \begin{document} < >= library(knitr) opts_chunk$set(tidy=FALSE) @ \title{Visualization} \author{Martin Morgan (\href{mailto:mtmorgan@fhcrc.org}{mtmorgan@fhcrc.org}) \\ Fred Hutchinson癌症研究中心\\西雅图,华盛顿州}\date{2月7日2014}\maketitle \begin{frame}[vulnerable]{Visualization} \begin{columns}[t] \column{. \5\textwidth} General \begin{itemize} \item基础图形\item \Rpkg{lattice} \item \Rpkg{ggplot2} \end{itemize} \column{。5\textwidth} \Bioconductor \begin{itemize} \item \Biocpkg{Gviz}, \Biocpkg{ggbio} \item \Biocpkg{Rgraphviz}, \Biocpkg{RCytoscape}, \Biocpkg{RedeR} \end{itemize} Interactive \begin{itemize} \item \Rpkg{shiny}!\end{itemize} \end{columns} \href{http://accidental-art.tumblr.com/archive}{Accidental aRt} \end{frame} \begin{frame}[vulnerable]{基础图形}\begin{columns}[t] \column{。开始一个\Rfunction{plot}, \Rfunction{matplot}, \Rfunction{hist}, \Rfunction{boxplot}, \ldots,指定选项\item添加\Rfunction{legend}, \Rfunction{points}, \ldots \item帮助:\Rcode{?情节}\ Rcode {?Par} \结束{itemize} \列{。5\textwidth}几个plot \begin{itemize} \item Layout with \Rcode{par(mfcol=c(1, 2))}, \Rcode{screen}, \ldots \item创建单个plot \item恢复原来的\Rcode{par}设置\end{itemize} \end{columns} \bigskip\par \end{frame} \begin{frame}[vulnerable]{基础图形}< >= fl <- system。file(package="SummerX", "extdata", "abc.csv") stopifnot(file.exists(fl)) abc <- read.csv(fl, row.names=1) fl <- system. csvfile(package="SummerX", "extdata", " brfss -sub .csv") stopifnot(file.exists(fl)) brfss <- read.csv(fl) @ < >= fileName <- file.choose() # 'abc.csv' abc <- read.csv(fileName, row.names=1) @ \begin{columns} \column{。5 \ textwidth} < >= ##从##矩阵matplot(t(abc), type="l", lty=1, lwd=3, xlab="Cycle", ylab="Count", cex.lab=2) ##添加一个图例图例("topright", legend=rownames(abc), lty=1, lwd=3, col=1:5, cex=1.8) @ \column{。5\textwidth} \includegraphics[width=\textwidth]{figures/abc} \end{columns} \end{frame} \begin{frame}[vulnerable]{Base graphics}数据:美国疾病控制中心行为风险因素监测系统(\href{http://www.cdc.gov/brfss/}{BRFSS}) < >= fl <- system。file(package="SummerX", "extdata", " brfss -sub .csv") brfss <- read.csv(fl) brfss2010 <- brfss[brfss$Year == "2010",] @ < >= brfss <- read.csv(file.choose()) # ' brfss -sub .csv' brfss2010 <- brfss[brfss$Year == "2010",] @ Plot < >= ##设置布局,捕获旧选项opar <- par(mfcol=c(1,2)) plot(sqrt(Weight) ~ Height, brfss2010[brfss2010$Sex == "Female",], main="2010, Female") plot(sqrt(Weight) ~ Height, brfss2010[brfss2010$Sex == "Male",], main="2010, Male") ##恢复旧选项par(sqrt(Weight) ~ Height, brfss2010[brfss2010$Sex == "Male",], main="2010, Male") @ \end{frame} \begin{frame}{\Rpkg{lattice} graphics} \begin{itemize} \item主要函数如\Rfunction{xyplot},\Rfunction{dotplot}, \Rfunction{contourplot} \item完成此工作的“面板”函数,例如\Rfunction{Panel。xyplot} \ Rfunction{面板。小提琴}\物品帮助:\Rcode{?xyplot}用于处理整体的情节,\Rcode{?面板。Xyplot}(以及类似的)用于单个面板。\end{itemize} \end{frame} \begin{frame}[vulnerable]{\Rpkg{lattice} graphics} < >= fl <- system。file(package="SummerX", "extdata", " brfss -sub .csv") brfss <- read.csv(fl) @ < >= brfss <- read.csv(file.choose()) # ' brfss -sub .csv' @ < >= library(lattice) xyplot(sqrt(Weight) ~ Height | Sex, brfss2010) @ \includegraphics[width=\textwidth]{figures/brfss-xyplot} \end{frame} \begin{frame}[vulnerable]{\Rpkg{lattice} graphics} < >= bwplot(sqrt(Weight) ~ factor(Year) | Sex, brfss, panel=panel.violin) @ \includegraphics[width=\textwidth]{figures/brfss-violin} \end{frame} \begin{frame}{\Rpkg{ggplot2} \begin{itemize} \item使用\Rfunction{ggplot} \item添加\emph{layers}(例如,\Rfunction{geom\_density}和\emph{aesthetics}(例如,\Rfunction{aes}) \end{itemize} \begin{frame}[fragile]{\Rpkg{ggplot2} graphics} < >= fl <- system。file(package="SummerX", "extdata", " brfss -sub .csv") brfss <- read.csv(fl) brfss2010 <- brfss[brfss$Year == "2010",] @ < >= brfss <- read.csv(file.choose()) # ' brfss -sub .csv' brfss2010 <- brfss[brfss$Year == "2010",] @ < >= library(ggplot2) ggplot(brfss2010) + geom_density(alpha=.2) + aes(sqrt(Weight), fill=Sex) @ \includegraphics[width=\textwidth]{figures/brfss-geom_density} \end{frame} \begin{frame}{Genomic Visualization} \begin{itemize} \item非常灵活的基础,\Rpackage{lattice},和\Rpkg{ggplot2}设施\item范围和基因组:\Biocpkg{Gviz}, \Biocpkg{ggbio} \item图和网络:\Biocpkg{Rgraphviz}, \Biocpkg{RCytoscape} \end{itemize} \end{frame} \begin{frame}[fragile]{Interactive Visualization} \Rpkg{shiny}提供了一种创建交互式图形的简单方法。探索火山!}应用程序通过包中的源代码在类中开发。< > =系统。file(package="SummerX", "shiny") @ \end{frame} \end{document}