<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; R</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/r/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>生信分析人员如何系统入门R？</title>
		<link>http://www.bio-info-trainee.com/2214.html</link>
		<comments>http://www.bio-info-trainee.com/2214.html#comments</comments>
		<pubDate>Thu, 29 Dec 2016 09:07:57 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[杂谈-随笔]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[生物信息学]]></category>
		<category><![CDATA[系统入门]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2214</guid>
		<description><![CDATA[R语言的重要性我也就不再赘述了，它不仅在生物信息数据处理中发挥着重要作用，也是其 &#8230; <a href="http://www.bio-info-trainee.com/2214.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>R语言的重要性我也就不再赘述了，它不仅在生物信息数据处理中发挥着重要作用，也是其它主流数据处理人士的首选工具。现在非常多的半路出家自学生物信息学的小伙伴必须学而且有可能学的就是R，所以写一个R的系统性入门指导是非常有必要的。这本来应该是我下面的生信分析人员如何系统入门编程语言的姊妹篇的，但是因为时隔太久，我的感悟可能发生了变化，所以这个R跟前面的两个看起来总结指引模式不太一样的。</div>
<div>
<h1><a title="Permalink to 生信分析人员如何系统入门perl？" href="http://www.bio-info-trainee.com/1667.html">生信分析人员如何系统入门perl？</a></h1>
<h1><a title="Permalink to 生信分析人员如何系统入门linux？" href="http://www.bio-info-trainee.com/1661.html">生信分析人员如何系统入门linux？</a></h1>
<p>我作为老一辈的生信工程师，所以喜欢perl一点，排斥python，其实呢，我也稍微看过一些python的语法，个人认为R和python几乎是一模一样的。R的特点就是内置了大量的函数，基本上你认识的英文单词都可以是一个函数，即使不是，你也可以自定义为函数。搞清楚了函数和变量，就可以看懂大部分的R代码了。<!--StartFragment --></p>
<p>下面是生信菜鸟团QQ群管理员赵云对这3种编程语言的心得体会！</p>
<div style="padding-left: 30px;">python跟perl都是高级语言， 两个开发的目的不同， perl更面向过程一些，优势是严谨，快。 python主流面向对象编程， 这个跟R类似， 数据结构等方面有些不同，但可以互相调用。 实际上以上三者之间可以互相调用部分功能。python的语法并不是很严谨，个人感觉，越偏向自然语言的编程语言越通俗但不严谨，以上，是跟C比较的。</p>
<div style="padding-left: 30px;"><!--StartFragment --></p>
<div style="padding-left: 30px;">R本身起源于S语言，是主要针对统计的， 也是面向对象的， 本质上，，是把一个比excel功能强大的软件归零化成了命令行吧.excel高级应用也是要编程的， 所以R的初级应用可以当成是没有用户交互界面的excel，细心一点， 把示例代码都打对，当功能强大但不好使版的excel吧， 这样至少心理上不会畏难跟抵触.</p>
<div style="padding-left: 30px;"><!--StartFragment --></p>
<div style="padding-left: 30px;">内部集成的越多，用户需要做的越少， 你用C画个图累死你， 用python得写几行， R一行就行了！</div>
<div style="padding-left: 30px;"><span style="color: #ff0000;"><strong>PS:菜鸟发言，如有误导，概不负责！</strong></span></div>
</div>
</div>
</div>
</div>
</div>
<p><span id="more-2214"></span></p>
<div> 接下来是我写的了：</div>
<p><b><span style="color: #ff0000;">必须要做的：</span></b></p>
<div>你首先肯定得安装R语言软件，然后推荐也安装一些R studio，在R studio里面写代码会比较方便。</div>
<div>下载R语言的软件：</div>
<div>•<a href="https://cran.r-project.org/bin/windows/base/">https://cran.r-project.org/bin/windows/base/</a></div>
<div>•下载Rstudio这个R编辑器:</div>
<div>•<a href="https://www.rstudio.com/products/rstudio/download/">https://www.rstudio.com/products/rstudio/download/</a></div>
<div>然后我就要强调help函数了，你必须要把help函数用一百次以上，不然你不可能入门的！你必须要自学R语言基础，或者看书，或者看视频，或者有人手把手教你，<b><span style="color: #ff0000;">书的话，我推荐：</span></b></div>
<div>
<div><b><span style="color: #ff0000;">《R in Action》</span></b></div>
<div><b><span style="color: #ff0000;">《The Art of_R Programming》</span></b></div>
</div>
<div><b><span style="color: #ff0000;"> </span></b></div>
<div>R的特性就是有着大量的包，所以你必须学会安装包：</div>
<div>
<div>安装包 install.packages(" xxxxxx  ")</div>
<div>加载包 library( xxxxx )</div>
<div>查看包的帮助文档help("xxxxx") 或?xxxxx</div>
<div>获取当前工作区间getwd()</div>
<div>更改工作区间 setwd( "xxxxxx")</div>
<div>清除当前对象rm()</div>
</div>
<div>安装包你一定会遇到错误，请参考： <a href="http://www.biotrainee.com/thread-144-1-1.html" target="_blank">R包终极解决方案！</a> ，还有<a title="Permalink to R的包（package）" href="http://www.bio-info-trainee.com/579.html">R的包（package）</a></div>
<div></div>
<p>上面的书籍都会提供一些简单的测试代码，你跟着傻瓜式的敲代码就好，但是实践的过程中，请务必注意一些英文单词file 文件路径 Description简述 Usage用法 Arguments参数 Details详细  value 数值 Examples例子 header 表标题 logical_value 逻辑值 delimiter 分隔符 object 对象 col列 row 行 vector向量 dimensions维度 data数据 。</p>
<div><b><span style="color: #ff0000;"> </span></b></div>
<div><b><span style="color: #ff0000;">首先你要明白的是变量：</span></b></div>
<div>
<div>向量和因子，我懒得说了。(向量特简单，没什么好说的，因子太复杂了，我说不清楚，你们慢慢理解。)</div>
<div>数据框–就像我们的表格,第一行就是每一列的名字,我们称之为字段,或者变量名.那么对应每列下面的数据就叫做记录或者观测.用data.frame( 字段1,字段2,…. )创建</div>
<div>列表–与数据框类似,区别就是每一列向量类型和长度可以不一致.用list( 字段1, 字段2,….. )创建</div>
<div>数组–其形式就像我们玩的模方,每一个面都是一个矩阵数据,用array(数据,各维度的最大值,各维度的名称)</div>
</div>
<div></div>
<p><b><span style="color: #ff0000;">然后要了解对这些变量的基础操作函数：</span></b></p>
<div>变量怎么来，对它们处理什么？</div>
<div>
<div>我们处理生物信息学数据一般很少会手动创建这些对象，都是从文本里面读取，比如kegg数据库文件，差异分析结果，RNA-seq的表达量矩阵，但是读入之后，我们的重点就是知道它们变成了什么，该如何去一步步的转换它们。</div>
<div>数据的特性函数也必须要知道，无非就是一些英文单词而已，你经常的玩一下，就慢慢的熟练了。str,class,names,row.names,col.names,length,unique,view,min,max,summay,table</div>
</div>
<div></div>
<p><b><span style="color: #ff0000;">可视化你的变量：</span></b></p>
<div>
<div>了解了R里面的基础变量和对象，也学会了对它们进行简单的转换，接下来就可以尝一尝R的甜头了，对任何数据都可以可视化，简简单单的就可以画一大堆的图。</div>
<div>plot,boxplot,barplot,pie,hist,pair,它们每个绘图函数都有自己要求的输入数据，特定的可视化结果，请务必在还没熟练使用之前help一下它们，自己主动查看它们好玩的地方，好好自学。</div>
<div>dev.new()新建画板</div>
<div>plot()绘制点线图,条形图,散点图.</div>
<div>barplot( ) 绘制条形图</div>
<div>dotchart( ) 绘制点图</div>
<div>pie( )绘制饼图.</div>
<div>pair( )绘制散点图阵</div>
<div>boxplot( )绘制箱线图</div>
<div>hist( )绘制直方图</div>
<div>scatterplot3D( )绘制3D散点图.</div>
<div>低级绘图函数:</div>
<div>par()　可以添加很多参数来修改图形</div>
<div>title( )　添加标题</div>
<div>axis( )　调整刻度</div>
<div>rug( )　添加轴密度</div>
<div>grid( )　添加网格线</div>
<div>abline( )　添加直线</div>
<div>lines( )　添加曲线</div>
<div>text( )　添加标签</div>
<div>legend(）　添加图例</div>
<div>它们还有一系列的绘图参数，坐标轴，图例，颜色，性状，大小，空白，布局，非常繁琐，想掌握，花费的时间会非常多，但是很多人直接跳到ggplot的绘图世界了，不想搞那么多底层绘图代码。</div>
<div>但是我看过一个底层R绘图集大成者，就是Combining gene mutation with gene expression data improves outcome prediction in myelodysplastic syndromes文章的作者的github里面有。</div>
<div></div>
<div>但是对大部分人来说，生信的绘图，都是有套路的，其实都被别人包装成函数了，做好数据，一个函数就出了所有复杂的图。比如热图，cluster等等</div>
</div>
<div></div>
<p><b><span style="color: #ff0000;">数据对象的一些高级操作</span></b></p>
<div>
<div>前面我们对向量，数据框，数组，列表都了解了，也知道如何查看数据的特性，但是要进行高级转换，就需要一些时间来学习apply系列函数，aggregate,split等函数的用法，这是一个分水岭，用好了你就算是R入门了。也可以用一些包，比如reshape2，dplyr</div>
<div>当然，R里面的字符串对象是另外完全不一样的操作模式，建议大家自行搜索学习。</div>
</div>
<div></div>
<p><b><span style="color: #ff0000;">R的bioconductor世界</span></b></p>
<div>这个是生物信息学特有的，也是为什么我要求搞生物信息学数据处理的人必须学习R，就是为了应用大量的bioconductor包。在这里面所有的对象都不在是基础的向量，数据框，数组，列表了，而是S3，S4对象，这个高级知识点我就不推荐了，你学会了前面的东西，就有了自己的学习经验了，后面的分分钟就搞定了。(其实你永远也搞不定的)</div>
<div><b><span style="color: #ff0000;">每学一个bioconductor的包，都是自己R水平的提升，</span></b>大家可以参考我的博客：<a href="http://www.bio-info-trainee.com/tag/bioconductor">http://www.bio-info-trainee.com/tag/bioconductor</a> 我就是这样学习过来的。我还创建了bioconductor中国这个社区，可惜效果不好，有志者可以继续联系我，我们看看有没有可能做起来。</div>
<div></div>
<div>当然R肯定不只是应用在生物信息学啦，其实它在非常多的地方都有应用，尤其是金融和地理，在如何一个方向学习R，就不仅仅是R本身的语法了，你需要学习的东西太多了，我简单列出几个我接触过的方向吧：</div>
<div></div>
<div>
<div>统计，科学计算，数据挖掘，文本挖掘，基础绘图，ggplot绘图，高级编程，都有着丰富的书籍和视频资料，<b><span style="color: #ff0000;">尤其推荐炼数成金的R七种武器系列。(全套视频很容易找到)</span></b></div>
<div>《A Handbook of Statistical Analyses_Using_R》</div>
<div>《Modern Applied Statistics With S》</div>
<div>《Introduction to Scientific Programming and Simulation Using R》</div>
<div>《Mastering Scientific Computing with R》</div>
<div>《Practical Data Science with R》</div>
<div>《Data Mining explain using R》</div>
<div>《ggplot2 Elegant Graphics for Data Analysis》</div>
<div>《R Graphics Cookbook》</div>
<div>《R Cookbook》</div>
<div>《R in a Nutshell》</div>
<div>《R Programming for Bioinformatics》</div>
<div>《software for data analysis programming with R》</div>
<div>看完这些，你就是R大神了，当然，前提是你看懂了也会灵活应用。</div>
<div></div>
<div># 网络资源#</div>
<div>- [R语言官方站](<a href="http://www.r-project.org/)">http://www.r-project.org/)</a></div>
<div>- [R-blogger](<a href="http://www.r-bloggers.com/)">http://www.r-bloggers.com/)</a></div>
<div>- [R语言资源汇总](<a href="https://github.com/qinwf/awesome-R)">https://github.com/qinwf/awesome-R)</a></div>
<div>- [R语言搜索引擎](<a href="http://www.rseek.org/)">http://www.rseek.org/)</a></div>
<div>- [R函数在线帮助](<a href="http://www.rdocumentation.org/)">http://www.rdocumentation.org/)</a></div>
<div>- [关于R的问答网站](<a href="http://stackoverflow.com/questions/tagged/r)">http://stackoverflow.com/questions/tagged/r)</a></div>
<div>- [一个入门级的R在线教程](<a href="http://tryr.codeschool.com/)">http://tryr.codeschool.com/)</a></div>
<div>- [交互式的R在线教程](<a href="https://www.datacamp.com%29/">https://www.datacamp.com)</a></div>
<div>- [统计之都](<a href="http://cos.name/)">http://cos.name/)</a></div>
<div>- [我的博客](<a href="http://xccds1977.blogspot.com%29/">http://xccds1977.blogspot.com)</a></div>
<div>- [美国计算机世界杂志提供的Ｒ语言初学者入门资料](<a href="http://www.computerworld.com/s/article/9239625/Beginner_s_guide_to_R_Introduction)">http://www.computerworld.com/s/article/9239625/Beginner_s_guide_to_R_Introduction)</a></div>
<div>- 各种cheatsheet</div>
<div><a href="http://cran.r-project.org/doc/contrib/Short-refcard.pdf">http://cran.r-project.org/doc/contrib/Short-refcard.pdf</a></div>
<div><a href="http://www.rstudio.com/resources/cheatsheets/">http://www.rstudio.com/resources/cheatsheets/</a></div>
<div></div>
</div>
<div>最后借鉴一个生物信息学习方法：</div>
<div>
<div>知识和耐心，是成为强者的唯一方法。</div>
<div>- 通过阅读来学习。</div>
<div>包括了阅读经典的教材、代码、论文、学习公开课。</div>
<div>- 通过牛人来学习。</div>
<div>包括同行的聚会、讨论、大牛的博客、微博、twitter、RSS。</div>
<div>- 通过练习来学习。</div>
<div>包括代码练习题、参加kaggle比赛、解决实际工作中的难题。</div>
<div>- 通过分享来学习。</div>
<div>包括自己写笔记、写博客、写书、翻译书，和同伴分享交流、培训新人。</div>
</div>
<div></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2214.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java版本GSEA软件的ES score图片的修改</title>
		<link>http://www.bio-info-trainee.com/2105.html</link>
		<comments>http://www.bio-info-trainee.com/2105.html#comments</comments>
		<pubDate>Thu, 01 Dec 2016 16:53:10 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[基础软件]]></category>
		<category><![CDATA[ES score]]></category>
		<category><![CDATA[GSEA]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2105</guid>
		<description><![CDATA[首先要明白这个ES score图片里面的数据是什么，这样才能修改它，因为java &#8230; <a href="http://www.bio-info-trainee.com/2105.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>首先要明白这个ES score图片里面的数据是什么，这样才能修改它，因为java是一个封闭打包好的软件，所以我们没办法在里面修改它没有提供的参数，运行完GSEA，默认输出的图就是下面这样：<span id="more-2105"></span></p>
<div style="width: 513px" class="wp-caption alignnone"><img class="" src="http://note.youdao.com/yws/api/group/23785548/noteresource/9ED49F972A0F4980AE784E76A7DFFC29/version/256?method=get-resource&amp;shareToken=DBDB0277A315444BBBAB2024190208AE&amp;entryId=123732909" alt="" width="503" height="504" /><p class="wp-caption-text">ES score</p></div>
<p>这个图片在发表的时候，就会发现其实蛮模糊的， 所以有可能需要自己重新制作这个图，那么就需要明白这个图后面的数据。</p>
<p>其中最下面的数据是量方法测到了2万个基因，那么这两万个基因在case和control组的差异度量(六种差异度量，默认是signal 2 noise，GSEA官网有提供公式，也可以选择大家熟悉的foldchange)肯定不一样,那么根据它们的差异度量，就可以对它们进行排序，并且Z-score标准化的结果。</p>
<p>而中间的就是该gene set在测到了的已经根据signal2noise排好序的2万个基因的位置。</p>
<p>最上面的图，就是所有的基因的ES score都要一个个加起来，叫做running  ES score，在加的过程中，什么时候ES score达到了最大值，就是这个gene set最终的ES score！</p>
<p>我这里全面解析了GSEA官网提供的R代码的绘图函数，如下：</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/ES-SCORE图的画法.png"><img class="alignnone size-full wp-image-2106" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/ES-SCORE图的画法.png" alt="es-score%e5%9b%be%e7%9a%84%e7%94%bb%e6%b3%95" width="1574" height="650" /></a></p>
<p>这个函数本身也被我抽离出来了：</p>
<p>这个知识点有点复杂，<strong><span style="color: #ff0000;">我解释的很清楚数据是什么，但是数据如何来的（就是下面代码读取的txt文件）</span></strong>，我没办法用博客写清楚，需要修改一个2500行的源代码才能获取数据！</p>
<blockquote><p>setwd('data')<br />
<strong><span style="color: #ff0000;">Obs.RES=read.table('Obs.RES.txt') </span></strong><br />
<strong><span style="color: #ff0000;">Obs.RES=t(Obs.RES) ## 每个基因在每个gene set里面的running ES score，一个矩阵</span></strong><br />
<strong><span style="color: #ff0000;">Obs.indicator=read.table('Obs.indicator.txt') </span></strong><br />
<strong><span style="color: #ff0000;">Obs.indicator=t(Obs.indicator) ## 每个基因是否属于每个gene set，一个0/1矩阵</span></strong><br />
<strong><span style="color: #ff0000;">obs.s2n=read.table('obs.s2n.txt')[,1]  ## 每个基因的signal 2 noise值，已经Z-score化，而且排好序了。</span></strong><br />
<strong><span style="color: #ff0000;">size.G=read.table('size.G.txt')[,1]  ## 每个gene set的基因数量，在图中需要显示</span></strong><br />
<strong><span style="color: #ff0000;">gs.names=read.table('gs.names.txt')[,1] ## 每个gene set的名字，在图中需要显示</span></strong><br />
<strong><span style="color: #ff0000;">Obs.arg.ES=read.table('Obs.arg.ES.txt')[,1]## 每个gene set的最大ES score出现在排序基因的位置</span></strong><br />
<strong><span style="color: #ff0000;">Obs.ES.index=read.table('Obs.ES.index.txt')[,1]## 这个用不着的，我也忘记是什么了</span></strong><br />
<strong><span style="color: #ff0000;">Obs.ES=read.table('Obs.ES.txt')[,1]  ##每个gene set的最大ES score是多少，如果是正值，用红色表示富集在case组，如果是负值，用蓝色，表示富集在control组。</span></strong></p>
<p>plot_ES_score &lt;- function(Ng=12,N=34688,phen1='control',phen2='case',Obs.RES,Obs.indicator,obs.s2n,size.G,gs.names,Obs.arg.ES,Obs.ES.index){<br />
for (i in 1:Ng) {<br />
png(paste0('number_',gs.names[i],'.png'))<br />
ind &lt;- 1:N<br />
min.RES &lt;- min(Obs.RES[i,])<br />
max.RES &lt;- max(Obs.RES[i,])<br />
if (max.RES &lt; 0.3) max.RES &lt;- 0.3<br />
if (min.RES &gt; -0.3) min.RES &lt;- -0.3<br />
delta &lt;- (max.RES - min.RES)*0.50<br />
min.plot &lt;- min.RES - 2*delta<br />
max.plot &lt;- max.RES<br />
max.corr &lt;- max(obs.s2n)<br />
min.corr &lt;- min(obs.s2n)<br />
Obs.correl.vector.norm &lt;- (obs.s2n - min.corr)/(max.corr - min.corr)*1.25*delta + min.plot<br />
zero.corr.line &lt;- (- min.corr/(max.corr - min.corr))*1.25*delta + min.plot<br />
col &lt;- ifelse(Obs.ES[i] &gt; 0, 2, 4)</p>
<p># Running enrichment plot</p>
<p>sub.string &lt;- paste("Number of genes: ", N, " (in list), ", size.G[i], " (in gene set)", sep = "", collapse="")</p>
<p>main.string &lt;- paste("Gene Set ", i, ":", gs.names[i])</p>
<p>plot(ind, Obs.RES[i,], main = main.string, sub = sub.string, xlab = "Gene List Index", ylab = "Running Enrichment Score (RES)", xlim=c(1, N), ylim=c(min.plot, max.plot), type = "l", lwd = 2, cex = 1, col = col)<br />
for (j in seq(1, N, 20)) {<br />
lines(c(j, j), c(zero.corr.line, Obs.correl.vector.norm[j]), lwd = 1, cex = 1, col = colors()[12]) # shading of correlation plot<br />
}<br />
lines(c(1, N), c(0, 0), lwd = 1, lty = 2, cex = 1, col = 1) # zero RES line<br />
lines(c(Obs.arg.ES[i], Obs.arg.ES[i]), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = col) # max enrichment vertical line<br />
for (j in 1:N) {<br />
if (Obs.indicator[i, j] == 1) {<br />
lines(c(j, j), c(min.plot + 1.25*delta, min.plot + 1.75*delta), lwd = 1, lty = 1, cex = 1, col = 1) # enrichment tags<br />
}<br />
}<br />
lines(ind, Obs.correl.vector.norm, type = "l", lwd = 1, cex = 1, col = 1)<br />
lines(c(1, N), c(zero.corr.line, zero.corr.line), lwd = 1, lty = 1, cex = 1, col = 1) # zero correlation horizontal line<br />
temp &lt;- order(abs(obs.s2n), decreasing=T)<br />
arg.correl &lt;- temp[N]<br />
lines(c(arg.correl, arg.correl), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = 3) # zero crossing correlation vertical line</p>
<p>leg.txt &lt;- paste("\"", phen1, "\" ", sep="", collapse="")<br />
text(x=1, y=min.plot, adj = c(0, 0), labels=leg.txt, cex = 1.0)</p>
<p>leg.txt &lt;- paste("\"", phen2, "\" ", sep="", collapse="")<br />
text(x=N, y=min.plot, adj = c(1, 0), labels=leg.txt, cex = 1.0)</p>
<p>adjx &lt;- ifelse(Obs.ES[i] &gt; 0, 0, 1)</p>
<p>leg.txt &lt;- paste("Peak at ", Obs.arg.ES[i], sep="", collapse="")<br />
text(x=Obs.arg.ES[i], y=min.plot + 1.8*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)</p>
<p>leg.txt &lt;- paste("Zero crossing at ", arg.correl, sep="", collapse="")<br />
text(x=arg.correl, y=min.plot + 1.95*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)<br />
dev.off()<br />
}</p>
<p>}</p>
<p>&nbsp;</p></blockquote>
<p>通过这个代码，就可以把当前所有gese set的 ES score图给重新画一下，如果需要调整字体大小，就去代码里面慢慢调整。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2105.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R语言画网络图三部曲之igraph</title>
		<link>http://www.bio-info-trainee.com/2082.html</link>
		<comments>http://www.bio-info-trainee.com/2082.html#comments</comments>
		<pubDate>Mon, 28 Nov 2016 10:08:59 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[网络分析]]></category>
		<category><![CDATA[网络图]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2082</guid>
		<description><![CDATA[经过热心的小伙伴的提醒，我才知道我以前写的R语言画网络图三部曲竟然漏掉了最基础的 &#8230; <a href="http://www.bio-info-trainee.com/2082.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>经过热心的小伙伴的提醒，我才知道我以前写的R语言画网络图三部曲竟然漏掉了最基础的一个包，就是igraph，不了解这个，后面的两个也是无源之水。</p>
<h2><a title="详细阅读 R语言画网络图三部曲之networkD3" href="http://www.bio-info-trainee.com/1357.html" rel="bookmark">R语言画网络图三部曲之networkD3</a></h2>
<h2><a title="详细阅读 R语言画网络图三部曲之sna" href="http://www.bio-info-trainee.com/1355.html" rel="bookmark">R语言画网络图三部曲之sna</a></h2>
<div>包说明书：<a href="https://cran.r-project.org/web/packages/igraph/igraph.pdf">https://cran.r-project.org/web/packages/igraph/igraph.pdf</a></div>
<div>包例子：<a href="https://www.r-project.org/conferences/useR-2008/slides/Csardi.pdf">https://www.r-project.org/conferences/useR-2008/slides/Csardi.pdf</a></div>
<div>包函数：<a href="http://igraph.org/r/doc/">http://igraph.org/r/doc/</a></div>
<div>PPI实例：<a href="http://a-little-book-of-r-for-bioinformatics.readthedocs.io/en/latest/src/chapter11.html">http://a-little-book-of-r-for-bioinformatics.readthedocs.io/en/latest/src/chapter11.html</a></div>
<div>其实包括了3个包：igraph/RBGL/Rgraphviz</div>
<div>用到了一个测试数据，是构建好的PPI网络对象：We will first analyse a curated data set of protein-protein interactions in the yeast Saccharomyces cerevisiae extracted from published papers. This data set comes from with an R package called “yeastExpData”, which calls the data set “litG”. This data was first described in a paper by Ge et al (2001) in Nature Genetics (<a href="http://www.nature.com/ng/journal/v29/n4/full/ng776.html">http://www.nature.com/ng/journal/v29/n4/full/ng776.html</a>).</div>
<div></div>
<p><span id="more-2082"></span></p>
<div><span style="color: #ff0000;">重点是graphNEL graph对象如何构造以及如何用函数来处理它！</span></div>
<div><span style="color: #ff0000;">构造方式，请记住，构造网络对象是重点，就是graph.data.frame+as_graphnel即可，一系列以网络对象为基础的包都需要这个步骤，学会了，也就没有问题了！</span></div>
<div>读取PPI数据到data.frame里面，比如my_edges</div>
<div><img src="file:///C:/Users/jimmy1314/AppData/Local/YNote/data/jmzeng1314@163.com/218613774f924593bf4f8c0c9409d9ec/clipboard.png" alt="" data-media-type="image" data-attr-org-src-id="A5A10EECE0EE4050BB621ECF2A264D50" /><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/11/clipboard1.png"><img class="alignnone size-full wp-image-2083" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/11/clipboard1.png" alt="clipboard" width="359" height="124" /></a></div>
<div>tmp &lt;- graph.data.frame(my_edges)</div>
<div>tmp;summary(tmp)</div>
<div>plot(tmp, layout=layout.kamada.kawai)</div>
<div>subnet &lt;- as_graphnel(tmp)</div>
<div>这个时候得到的subnet就是一个网络对象啦！</div>
<div>&gt; subnet</div>
<div>A graphNEL graph with directed edges</div>
<div>Number of Nodes = 818</div>
<div>Number of Edges = 12249</div>
<div>有了这个网络对象，就可以用BioNet来处理找<a href="http://www.bio-info-trainee.com/2071.html">maximal-scoring subgraph</a></div>
<div></div>
<div>对于网络对象，其它处理的函数有</div>
<div>mynodes &lt;- nodes(litG) 得到网络里面的所有节点信息</div>
<div>adj(litG, "YBR009C") 得到网络里面的YBR009C这个node节点的所有edges</div>
<div>mydegrees &lt;- graph::degree(litG) 算出网络里面的每个node的degree</div>
<div>table(mydegrees);mean(mydegrees);hist(mydegrees, col="red") 看看degree的分布情况。</div>
<div>对比较大的网络来说，并非里面的node都是连通的，可以用RBGL包来看看哪些nodes被隔离开了。</div>
<div>library("RBGL") myconnectedcomponents &lt;- connectedComp(litG)</div>
<div>返回的myconnectedcomponents这个list的每个元素都是一个被隔离开的网络图，可以去找最大连通图，也可以对这个list找到特定的某个node参与的连通图。</div>
<div>component3 &lt;- myconnectedcomponents[[3]]</div>
<div>mysubgraph &lt;- subGraph(component3, litG) 取指定的连通图，生成graphNEL对象，其实就是根据nodes来取子网络图。</div>
<div>下面代码可以把网络图展现出来：</div>
<div>library("Rgraphviz") mysubgraph &lt;- subGraph(component3, litG) mygraphplot &lt;- layoutGraph(mysubgraph, layoutType="neato") renderGraph(mygraphplot)</div>
<div></div>
<div>对网络图还可以找communities，这个又是一个网络图研究术语了： <a href="http://en.wikipedia.org/wiki/Community_structure">http://en.wikipedia.org/wiki/Community_structure</a></div>
<div>还可以进行聚类，就是cluster，还有很多，我就不一一介绍了。</div>
<div>上面的连通图也是一个网络研究术语：<a href="http://en.wikipedia.org/wiki/Connected_component_(graph_theory)">http://en.wikipedia.org/wiki/Connected_component_(graph_theory)</a></div>
<div></div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2082.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R一大利器之对象的操作函数查询</title>
		<link>http://www.bio-info-trainee.com/1951.html</link>
		<comments>http://www.bio-info-trainee.com/1951.html#comments</comments>
		<pubDate>Sat, 15 Oct 2016 13:44:09 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[基础软件]]></category>
		<category><![CDATA[bioconductor]]></category>
		<category><![CDATA[对象]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1951</guid>
		<description><![CDATA[对于生物出身的部分生物信息学工程师来说，很多计算机概念让人很头疼，尤其是计算机语 &#8230; <a href="http://www.bio-info-trainee.com/1951.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>对于生物出身的部分生物信息学工程师来说，很多计算机概念让人很头疼，尤其是计算机语言里面的高级对象。我以前学编程的时候，给我一个变量，一个数据，一个hash，我就心满意足了，可以解决大部分我数据处理问题，可事情远比想象之中复杂。因为很多高手喜欢用封装，代码复用，喜欢用高级对象。在R的bioconductor里面尤其是如此，经常会遇到各种包装好的S3，S4对象，看过说明书，倒是知道一些对象里面有什么，可以去如何处理那些对象，提取我们想要的信息，比如我就写过一系列的帖子：</p>
<div><a href="http://www.bio-info-trainee.com/886.html">Bioconductor系列之GenomicAlignments</a></div>
<div><a href="http://www.bio-info-trainee.com/883.html">Bioconductor系列之GenomicFeatures</a></div>
<div><a href="http://www.bio-info-trainee.com/831.html">R的bioconductor包TxDb.Hsapiens.UCSC.hg19.knownGene详解</a></div>
<div><a href="http://www.bio-info-trainee.com/828.html">R的bioconductor包里面的txdb对象及GRange对象详解</a></div>
<p><span id="more-1951"></span></p>
<p>那个时候傻傻的去搜集总结每个对象的操作函数，辛苦死了，一直想有没有地方可以查询这些对象，到底应该用什么函数呢？人怎么能记住一堆函数呢《比如seqnames(),strand(),cigar(),qwidth(),start(),end(),width(),njunc() 这些函数对这个GAlignments对象进行处理》</p>
<p>今天我又遇到了一个LumiBatch对象，也是很复杂，我明明知道里面有基因和探针，但就是拿它没办法：</p>
<blockquote><p>Summary of data information:<br />
Illumina Inc. BeadStudio version 1.4.0.1<br />
Normalization = none<br />
Array Content = 11188230_100CP_MAGE-ML.XML<br />
Error Model = none<br />
DateTime = 2/3/2005 3:21 PM<br />
Local Settings = en-US</p>
<p>Major Operation History:<br />
submitted finished command lumiVersion<br />
1 2007-04-22 00:08:36 2007-04-22 00:10:36 lumiR("../data/Barnes_gene_profile.txt") 1.1.6<br />
2 2007-04-22 00:10:36 2007-04-22 00:10:38 lumiQ(x.lumi = x.lumi) 1.1.6<br />
3 2007-04-22 00:13:06 2007-04-22 00:13:10 addNuId2lumi(x.lumi = x.lumi, lib = "lumiHumanV1") 1.1.6<br />
4 2007-04-22 00:59:20 2007-04-22 00:59:36 Subsetting 8000 features and 4 samples. 1.1.6</p>
<p>Object Information:<br />
LumiBatch (storageMode: lockedEnvironment)<br />
assayData: 8000 features, 4 samples<br />
element names: beadNum, detection, exprs, se.exprs<br />
protocolData: none<br />
phenoData<br />
sampleNames: A01 A02 B01 B02<br />
varLabels: sampleID label<br />
varMetadata: labelDescription<br />
featureData<br />
featureNames: oZsQEQXp9ccVIlwoQo 9qedFRd_5Cul.ueZeQ ... 33KnLHy.RFaieogAF4 (8000 total)<br />
fvarLabels: TargetID<br />
fvarMetadata: labelDescription<br />
experimentData: use 'experimentData(object)'<br />
Annotation: lumiHumanAll.db<br />
Control Data: Available<br />
QC information: Please run summary(x, 'QC') for details!</p></blockquote>
<p>看起来极度的复杂，教程里面有提到一些函数可以操作这个对象，用来画图，提取数据，但是不能满足我的需要。搜索了好久，终于找到了解决方法：</p>
<div><a href="https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/AnnotatedDataFrame?">https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/AnnotatedDataFrame?</a></div>
<div><a href="https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/ExpressionSet?">https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/ExpressionSet?</a></div>
<div><a href="https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/eSet?">https://www.rdocumentation.org/packages/Biobase/versions/2.26.0/topics/eSet?</a></div>
<div><a href="https://www.rdocumentation.org/packages/lumi/versions/2.24.0/topics/LumiBatch-class">https://www.rdocumentation.org/packages/lumi/versions/2.24.0/topics/LumiBatch-class</a></div>
<div><a href="https://www.rdocumentation.org/packages/GenomicFeatures/versions/1.24.4/topics/TxDb-class">https://www.rdocumentation.org/packages/GenomicFeatures/versions/1.24.4/topics/TxDb-class</a></div>
<div>这些函数是有规律的，而且这个网站也提供了查询接口，很容易就可以了解每个对象是如何设置的，有哪些属性，定义好了哪些函数可以去操作它。</div>
<div></div>
<div>我需要自己组合 pData(featureData(x.lumi)) 才能从 x.lumi这个对象里面提取到我想要的 ProbeID TargetID</div>
<blockquote>
<div>&gt; head(pData(featureData(x.lumi))）<br />
<span style="color: #ff0000;">ProbeID TargetID</span><br />
6450255 6450255 7A5<br />
2570615 2570615 A1BG<br />
6370619 6370619 A1BG<br />
2600039 2600039 A1CF<br />
2650615 2650615 A1CF<br />
5340672 5340672 A1CF</div>
</blockquote>
<div>以前就是把说明书给翻烂也找不到！</div>
<div> 而且，你只需要class一下你的对象，就知道它的具体名字，然后用method就可以看到它所有可供操作的函数！</div>
<div>
<div>&gt; class(x.lumi)</div>
<div>[1] "LumiBatch"</div>
<div>attr(,"package")</div>
<div>[1] "lumi"</div>
<div>&gt; methods(class='LumiBatch')</div>
<div>[1] $ $&lt;- [ [[ [[&lt;- abstract annotation annotation&lt;-</div>
<div>[9] as.matrix asBigMatrix assayData assayData&lt;- beadNum beadNum&lt;- boxplot classVersion</div>
<div>[17] classVersion&lt;- coerce combine controlData controlData&lt;- density description description&lt;-</div>
<div>[25] detection detection&lt;- dim dimnames dimnames&lt;- dims esApply experimentData</div>
<div>[33] experimentData&lt;- exprs exprs&lt;- fData fData&lt;- featureData featureData&lt;- featureNames</div>
<div>[41] featureNames&lt;- fvarLabels fvarLabels&lt;- fvarMetadata fvarMetadata&lt;- getHistory hist initialize</div>
<div>[49] isCurrent isVersioned makeDataPackage MAplot notes notes&lt;- pairs pData</div>
<div>[57] pData&lt;- phenoData phenoData&lt;- plot preproc preproc&lt;- protocolData protocolData&lt;-</div>
<div>[65] pubMedIds pubMedIds&lt;- rowMedians rowQ sampleNames sampleNames&lt;- se.exprs se.exprs&lt;-</div>
<div>[73] show storageMode storageMode&lt;- summary updateObject updateObjectTo varLabels varLabels&lt;-</div>
<div>[81] varMetadata varMetadata&lt;- write.exprs</div>
<div>see '?methods' for accessing help and source code</div>
<div>&gt;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1951.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R的shiny 服务器管理-入门</title>
		<link>http://www.bio-info-trainee.com/1683.html</link>
		<comments>http://www.bio-info-trainee.com/1683.html#comments</comments>
		<pubDate>Sat, 04 Jun 2016 01:14:09 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[生信基础]]></category>
		<category><![CDATA[shiny]]></category>
		<category><![CDATA[shiny服务器]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1683</guid>
		<description><![CDATA[如果你已经安装好了shiny 服务器，(安装教程)要开始使用了，掌握一些基础知识 &#8230; <a href="http://www.bio-info-trainee.com/1683.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>如果你已经安装好了shiny 服务器，(<a href="http://www.bio-info-trainee.com/1677.html">安装教程</a>)要开始使用了，掌握一些基础知识是必须的。这里我简单学习了一些入门资料，分享给大家，慢慢的我会写一个进阶资料。安装成功之后，系统会增加4个目录，是一定要掌握的：</p>
<blockquote>
<div><span style="color: #ff0000;">1、这个目录只存放关键配置文件：/etc/shiny-server/shiny-server.conf   初始状态只有一个文件，记录着非常多的默认信息，默认的网站目录是根目录下的srv的shiny-server目录，端口是3838<br />
</span></div>
<div>2、网站运行log日子存放：/var/log/shiny-server  初始状态下该目录为空</div>
<div>3、程序存放目录是：/srv/shiny-server 初始状态，有一个测试程序：</div>
</blockquote>
<div>
<blockquote>
<div>4、最后是/opt/shiny-server/ 目录，这里面也有一个配置文件：/opt/shiny-server/config/default.config</div>
</blockquote>
</div>
<p><span id="more-1683"></span></p>
<div>还有一个比较重要的文件，取决于linux系统的种类</div>
<div><strong>/etc/systemd/system/shiny-server.service 我的是 (RedHat 7, Ubuntu 15.04+, SLES 12+)</strong></div>
<div>如果是其它一些旧的系统会是/etc/init/shiny-server.conf  (Ubuntu 12.04 through 14.10 and RedHat 6)</div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">或者更旧的系统 </span>/etc/init.d/shiny-server   (RedHat 5, SLES 11)</div>
<div></div>
<div></div>
<div>关于shiny 服务器常见的需要控制的命令,基于我的linux系统版本<strong>(RedHat 7, Ubuntu 15.04+, SLES 12+)</strong></div>
<div>
<div>sudo systemctl start shiny-server</div>
<div>sudo systemctl stop shiny-server</div>
<div>sudo systemctl restart shiny-server</div>
<div>sudo systemctl kill -s HUP --kill-who=main shiny-server</div>
<div>sudo systemctl status shiny-server  ## 查看状态</div>
<div>sudo systemctl enable shiny-server  ## 开机启动</div>
<div>sudo systemctl disable shiny-server ## 关闭开机启动</div>
<div>## 如果是其它linux版本，请参照shiny官网的服务器维护指南：<a href="http://rstudio.github.io/shiny-server/latest/">http://rstudio.github.io/shiny-server/latest/</a></div>
<div></div>
<div>
<div>关于shiny 服务器配置，虽然默认根目录下的/srv的shiny-server目录，端口是3838</div>
<div>
<pre><code>server {
  listen 3838;location / {</code></pre>
<pre>    site_dir /srv/shiny-server;</pre>
<pre><code>log_dir /var/log/shiny-server;directory_index on;
  }
}</code></pre>
<pre><code>可以设置多个端口监听</code></pre>
<pre><code>server {
  listen 4949;location / {</code></pre>
<pre>    site_dir /srv/shiny-server;</pre>
<pre><code>log_dir /var/log/shiny-server;directory_index on; } }</code></pre>
<p>因为我们是以shiny这个用户来运行这些shiny的web app的，所以要给予一定的目录一些适当的权限给shiny用户。</p></div>
<div>首先是需要写的目录</div>
<div>
<ul>
<li><code>/var/lib/shiny-server/</code> (or whatever custom <code>SHINY_DATA_DIR</code> setting you're using)</li>
<li><code>/var/log/shiny-server/</code> (and/or whatever other directories you use for logging)</li>
</ul>
</div>
<div>然后是需要读取的目录</div>
<div>
<ul>
<li><code>/srv/shiny-server/</code> (and/or whatever other directories you're using to host Shiny applications)</li>
<li><code>/opt/shiny-server/</code></li>
<li><code>/etc/shiny-server/</code> (Note that you should enable <strong>only</strong> read access on this directory, as you likely don't want to allow your Shiny applications (which also run as <code>shiny</code>) to be able to write to your configuration or password file.)</li>
</ul>
</div>
<div>还有，如果<code>/tmp/shiny-server/目录存在的话，也需要设置好相应的权限。</code></div>
<div><code> </code></div>
<div></div>
<div>然后就可以把shiny官网的例子克隆到自己的服务器里面，开始在shiny的世界里面遨游啦！</div>
<div>
<div>git clone <a href="https://github.com/rstudio/shiny-examples.git">https://github.com/rstudio/shiny-examples.git</a></div>
</div>
<div>还有 <a href="https://github.com/ua-snap/shiny-apps">https://github.com/ua-snap/shiny-apps</a></div>
<div></div>
<div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">网页运行里面会经常需要Rmarkdown</span></div>
<div>
<div>sudo su - -c "R -e \"install.packages('rmarkdown',repos='<a href="http://mirror.bjtu.edu.cn/cran/">http://mirror.bjtu.edu.cn/cran/</a>')\""</div>
</div>
</div>
<div>收费版本还有很多其它功能:</div>
<div>The <code>app_session_timeout</code> setting can be used to automatically disconnect idle Shiny connections.</div>
<div>Shiny Server is capable of automatically inserting the necessary JavaScript code to enable Google Analytics tracking globally or for a particular <code>server</code> or <code>location</code>.</div>
<div>Memory limits will be added in a coming version of Shiny Server Professional.</div>
<div>Shiny Server can use a wide variety of techniques to keep the data in the web browser synchronized. The preferred technique, and the one most widely used, is the use of WebSockets.</div>
<div>Shiny Server Professional offers the ability to authenticate individual users. By specifying authentication requirements on particular <code>server</code>s or <code>location</code>s, the administrator can control the set of applications particular users are allowed to access.(<code> session$user  和 </code><code>session$groups</code>)</div>
<div>Regardless of which authentication mechanism is used, the duration of authentication can be configured using the <code>auth_duration</code> setting.</div>
<div>Shiny Server Pro supports the ability to rely on Google for the management of your users using the <code>auth_google</code> setting.</div>
<div>In Shiny Server Professional, SSL encryption is available for any configured <code>server</code> and in the <code>admin</code> interface. SSL is a means of encrypting traffic between web clients and servers and should be used for any application that will accept or transmit sensitive information such as passwords.</div>
</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1683.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装自己的shiny服务器-实战指南</title>
		<link>http://www.bio-info-trainee.com/1677.html</link>
		<comments>http://www.bio-info-trainee.com/1677.html#comments</comments>
		<pubDate>Sat, 04 Jun 2016 01:07:29 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[生信基础]]></category>
		<category><![CDATA[shiny服务器]]></category>
		<category><![CDATA[网页]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1677</guid>
		<description><![CDATA[个人比较欣赏R shiny制作的网页，入门简单，上手极快，多看点例子，制作复杂逻 &#8230; <a href="http://www.bio-info-trainee.com/1677.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>个人比较欣赏R shiny制作的网页，入门简单，上手极快，多看点例子，制作复杂逻辑的网页也不是问题。这篇实战指南有四个步骤：</p>
<blockquote><p>至少需要root权限的linux系统  （我测试了阿里云）<br />
安装R   （一般安装最新版，）<br />
在R中安装shiny模块   （一般还可以多安装一些模块）<br />
下载并且安装shiny server安装包    （根据系统选择）</p></blockquote>
<p><span id="more-1677"></span></p>
<p>前面三个步骤没有什么好说的了，如果你需要继续看这篇指南，我就默认你已经会了。</p>
<div>那么重点，就是安装shiny server本身咯：</div>
<div>这里<a href="http://www.rstudio.com/products/shiny/download-server/">http://www.rstudio.com/products/shiny/download-server/</a> 提供了下载链接，需要提供邮箱才会出现下载页面，选择对应Linux发行版的Shiny Server进行下载。<strong>我这里是CentOS 6.5.</strong></div>
<div></div>
<blockquote>
<div><strong>64bit</strong><br />
Size:  44.6 MB<br />
MD5: 45160b08eed65c89e0a9d03c58eba595<br />
Version:  1.4.2.786<br />
Released:  2016-02-19</div>
<div>#直接下载安装包，所以非常简单，我的命令是：</div>
<div><code>sudo yum install R</code></div>
<div><code><code>$ wget https://download3.rstudio.org/centos5.9/x86_64/<span style="color: #ff0000;">shiny-server-1.4.2.786-rh5-x86_64.rpm</span><br />
$ sudo yum install --nogpgcheck <strong>shiny-server-1.4.2.786-rh5-x86_64.rpm</strong></code><br />
</code></div>
</blockquote>
<div>这里我也是学习的别人的方法，参考：</div>
<div><a href="http://ju.outofmemory.cn/entry/162254">http://ju.outofmemory.cn/entry/162254</a></div>
<div>
<div><a href="http://www.lai18.com/content/1733097.html">http://www.lai18.com/content/1733097.html</a></div>
<div><strong>如果系统很烂，缺少一堆的库文件，</strong>简单的<code>sudo yum install</code>还会各种报错，如果需要下载源码来安装，那会很麻烦，这里就不讨论了。</div>
<div></div>
<div>如果安装成功，就有下面的界面：</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/11.png"><img class="alignnone size-full wp-image-1678" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/11.png" alt="1" width="440" height="472" /></a></div>
<div>成功之后就可以浏览shiny的网页了，程序自带测试例子，如果是在本地linux系统，而且自带浏览器的界面版linux，那么直接在浏览器中输入 localhost:3838 (或者对应IP地址， 如 <a href="http://192.168.1.100:3838/">http://192.168.1.100:3838/</a> 这个IP是假的 )就会出现。</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/4.png"><img class="alignnone size-full wp-image-1681" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/4.png" alt="4" width="694" height="380" /></a></div>
<div></div>
<div>但是阿里云服务器访问一般通过外网链接，因为要通过你的真正IP来访问3838端口，<strong>所以需要设置防火墙规则，不然依然是不能访问，防火墙自己学习如何设置把。</strong></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/3.png"><img class="alignnone size-full wp-image-1680" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/3.png" alt="3" width="593" height="264" /></a></div>
<div>安装成功了之后，还有一个更重要的事情就是维护，我下面简单介绍一些，然后会写一篇维护心得体会：</div>
<div>
<div>shiny官网上提供了详细的配置指导</div>
<div><a href="http://rstudio.github.io/shiny-server/latest/">http://rstudio.github.io/shiny-server/latest/</a></div>
<div>
<div>shiny-server 默认的安装目录是：/opt/shiny-server</div>
<div>目录内容：</div>
<div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/21.png"><img class="alignnone size-full wp-image-1679" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/21.png" alt="2" width="514" height="100" /></a></div>
<div></div>
<div>其中的默认配置文件是：/opt/shiny-server/config/default.config</div>
<div>内容是：</div>
<div></div>
</div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"># Instruct Shiny Server to run applications as the user “shiny”</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">run_as shiny;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"># Define a server that listens on port 3838</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">server {</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  listen 3838;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  # Define a location at the base URL</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  location / {</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # Host the directory of Shiny Apps stored in this directory</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    site_dir /srv/shiny-server;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # Log all Shiny output to files in this directory</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    log_dir /var/log/shiny-server;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # When a user visits the base URL rather than a particular application,</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # an index of the applications available in this directory will be shown.</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    directory_index on;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  }</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">}</span></div>
<div>
<div></div>
<div><span style="color: #ff0000;">这个文件和/etc/shiny-server/shiny-server.conf是一样的。</span></div>
<div><span style="color: #ff0000;">后面会具体讲解shiny server的配置细节。正如配置文件中所写，默认的网站目录是根目录下的srv的shiny-server目录，端口是3838，log目录是 /var/log/shiny-server。</span></div>
<div>
<div>默认程序存放在： <strong>/srv/shiny-server</strong></div>
<div>lrwxrwxrwx. 1 root root 38 Nov 25 00:02 index.html -&gt; /opt/shiny-server/samples/welcome.html</div>
<div>lrwxrwxrwx. 1 root root 37 Nov 25 00:02 sample-apps -&gt; /opt/shiny-server/samples/sample-apps</div>
<div>其实就是opt下对应的链接。</div>
</div>
</div>
</div>
</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1677.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>读书笔记（R语言）</title>
		<link>http://www.bio-info-trainee.com/1656.html</link>
		<comments>http://www.bio-info-trainee.com/1656.html#comments</comments>
		<pubDate>Mon, 23 May 2016 10:55:54 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[生信基础]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1656</guid>
		<description><![CDATA[R与ASReml-R统计分析教程（林元震）中国林业出版社 1-3章简单介绍了R的 &#8230; <a href="http://www.bio-info-trainee.com/1656.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>R与ASReml-R统计分析教程（林元震）中国林业出版社</p>
<p>1-3章简单介绍了R的基本语法，然后第4章着重讲了各种统计方法，第5章讲R的绘图，最后一张讲ASReml-R这个包<br />
语法重点:</p>
<p>1,install.packages(),library(),help(),example(),demo(),length(),attribute(),class(),mode(),dim(),names(),str(),head(),<br />
tail()</p>
<p>2,rep,seq,paste,array,matrix,data.frame,list,c(),factor(),</p>
<p>3,缺失值处理（na.omit,na.rm=T），类型转换（as.numeric(),as.character(),as.factor(),as.logical()）</p>
<p><span id="more-1656"></span></p>
<p>其中as.numeric()非常有用，在画图的时候经常需要加上，因为数据在处理的过程中经常被搞错成了字符串格式，而as.logical()可以进行分类，只有0，NA,NAN，NULL是FALSE</p>
<p>4,排序，合并，分割成子集，数据整合重构(reshape2和plyr包)</p>
<p>可以先了解一些R语言自带的数据包(见附录1)，然后试用一下aggregate函数，数据汇总，根据右边的因子来把左边的数据进行分割并处理一个函数</p>
<p>5,控制语句，自编函数<br />
统计分析</p>
<p>一、summary(),    library(pastecs);options(digits=2);stat.desc(),    library(psych);describe()</p>
<p>二、方差分析（analysis of variance,ANOVA）用来检验分组是否有显著差异</p>
<p>1，单因素+重复，数据框，df=data.frame(yield,treat)</p>
<p>fit=aov(yield~treat,data=df)</p>
<p>可以用summary来查看这次分析结果summary(fit)</p>
<p>用TukeyHSD(fit)进行多重比较，或者duncan.test(fit,”treat”,alpha=0.05)</p>
<p>2，双因素无重复，数据框，df=data.frame(yield,treat1,treat2)</p>
<p>fit=aov(yield~treat1+treat2,data=df)</p>
<p>这时候做多重比较就比较复杂了，library(agricolae)</p>
<p>Duncan.test(fit,”treat1”,alpha=0.5)</p>
<p>Duncan.test(fit,”treat2”,alpha=0.5)</p>
<p>3,双因素+重复，数据库首先要进行处理，把treat1和treat2合并成group来区分重复</p>
<p>Df$group=sapply(df,function(x) paste(df$treat1,df$treat2,sep=””))</p>
<p>然后fit=aov(yield~treat1+treat2+group,data=df)</p>
<p>4，多元方差与此类似，不停的增加因子来区分变量及group</p>
<p>三、随机分组的检验</p>
<p>1，完全随机实验，等同于方差分析的单因素+重复（判断不同的处理是否有差异）</p>
<p>2，单因素随机区组实验，等同于方差分析的双因素无重复，其中（区组这个因素是人为控制的差异，不需要检验，主要检验我们的不同的处理是否有差异）</p>
<p>3，双因素随机区组实验，不等同于方差分析的双因素+重复，但是与之类似，其中重复这个变量与之前的group变量有点区别，这里是我们的区组，而不是treat1和treat2的简单组合，所以我们需要分析treat1和treat2处理间的差异，但同时不需要考虑区组的差异</p>
<p>fit=aov(yield~treat1*treat2+block,data=df)，如果treat1有2个水平，treat2有3个水平，那么之前的group应该是6个，但是我们的block是区组的个数，还是3个，数据是18个。</p>
<p>4,三因素随机区组实验</p>
<p>看下面的例子</p>
<p>本地图片，请重新上传</p>
<p>其中npk数据框里面有着N,P,K三个因素，每个因素都有两个水平，共8个group组合，分成了6个区组block，即为6个重复。但是每个group组合并没有包括所有的8个水平组合，只有4个而已，所以数据量也只有4个。这就是方差分析与随机区组分析最大的区别所在。</p>
<p>本地图片，请重新上传</p>
<p>四、统计显著性检验（前提是符合各种概率分布模型）</p>
<p>1、t检验</p>
<p>i. 单样本，对一个多数据的向量x，看看是否是服从正态分布</p>
<p>qqnorm(x),qqline(x),正态QQ图，plot(density(x))核密度图 ,shapiro.test(x) 正态性检验，T.test(x,mu=8,alternative=”two.sided”)看看这个数据的均值与8的差异是否显著。</p>
<p>ii. 双样本检验是否显著差异，t.test(a,b)或者t.test(a~b)</p>
<p>2、卡方检验</p>
<p>i. 是否符合一定的比例chisq.test(c(49,51),c(0.5,0.5))，看看扔100次硬币的正反面比例是否正常</p>
<p>ii. 本地图片，请重新上传</p>
<p>iii. P值为0.8415，所以显著的正常</p>
<p>a) 独立性检验</p>
<p>i. 2x2列联表或者2xc列联表独立性检验，主要是为了看某个处理是否改变了原来的标准比例，比如本来正常1:1的扔硬币，扔一百次是49:50的，但是现在换了一个小硬币，再扔一百次，结果是48:52，我们就想看看这个硬币是否改变了比例</p>
<p>本地图片，请重新上传</p>
<p>很明显可以看出比例未发生变化，同理可以扩展到RxC列联表的比例是否变化</p>
<p>五、回归分析</p>
<p>1、简单线性回归，fit=lm(y~x)可以对此回归进行一系列分析，summary(fit)，round(fitted(fit),2) 预测值，round(residuals(fit),2)残差值，abline(fit)回归线</p>
<p>2、多项式回归fit=lm(y~x+I(x^2))以此类推</p>
<p>3、多元回归fit=lm(y~x1+x2+x3)以此类推，fit=lm(y~x1+x2+x1: x2)有交互项。</p>
<p>4、回归诊断，对fit对象plot可以输出四幅图par(mfrow=c(2,2)); plot(fit)</p>
<p>第一幅图是残差值与预测值的线性关系图，理论上残差值应该是随机分布在预测值的两端。</p>
<p>第二幅图是Q-Q图，判断残差值在标准正态分布下的概率，理论上应该是45度直线。</p>
<p>第三幅图是位置尺度图，判断同方差性，假设是方差不变，所以图中的点应该随机分布于水平线的两侧。</p>
<p>第四幅图是残差值的杠杆图，用来判断异常点，鉴别高杠杆点，离群点，强影响点，识别异常点。</p>
<p>5、广义线性模型</p>
<p>6、逻辑回归和泊松回归</p>
<p>六、概率分布</p>
<p>a) 分布+概率密度函数d+累计分布函数p+随机抽样r+分布检验ks.test(x,”pnorm”)</p>
<p>b) 正态分布（norm），指数分布(exp)，二项分布，泊松分布，卡方分布(chisq)，伽马分布(gama)，贝塔分布(beta)，T分布，F分布，均匀分布（unif），韦伯分布(weibull),一般连续分布，一般离散分布。</p>
<p>c) 很复杂，见附录2</p>
<p>附录I，datasets（R自带数据包）</p>
<p>向量<br />
euro    #欧元汇率，长度为11，每个元素都有命名<br />
landmasses    #48个陆地的面积，每个都有命名<br />
precip    #长度为70的命名向量<br />
rivers    #北美141条河流长度<br />
state.abb    #美国50个州的双字母缩写<br />
state.area    #美国50个州的面积<br />
state.name    #美国50个州的全称</p>
<p>因子<br />
state.division    #美国50个州的分类，9个类别<br />
state.region    #美国50个州的地理分类</p>
<p>矩阵、数组<br />
euro.cross    #11种货币的汇率矩阵<br />
freeny.x    #每个季度影响收入四个因素的记录<br />
state.x77    #美国50个州的八个指标<br />
USPersonalExpenditure    #5个年份在5个消费方向的数据<br />
VADeaths    #1940年弗吉尼亚州死亡率（每千人）<br />
volcano    #某火山区的地理信息（10米×10米的网格）<br />
WorldPhones    #8个区域在7个年份的电话总数<br />
iris3    #3种鸢尾花形态数据<br />
Titanic    #泰坦尼克乘员统计<br />
UCBAdmissions    #伯克利分校1973年院系、录取和性别的频数<br />
crimtab    #3000个男性罪犯左手中指长度和身高关系<br />
HairEyeColor    #592人头发颜色、眼睛颜色和性别的频数<br />
occupationalStatus    #英国男性父子职业联系</p>
<p>类矩阵<br />
eurodist    #欧洲12个城市的距离矩阵，只有下三角部分<br />
Harman23.cor    #305个女孩八个形态指标的相关系数矩阵<br />
Harman74.cor    #145个儿童24个心理指标的相关系数矩阵</p>
<p>数据框<br />
airquality    #纽约1973年5-9月每日空气质量<br />
anscombe    #四组x-y数据，虽有相似的统计量，但实际数据差别较大<br />
attenu    #多个观测站对加利福尼亚23次地震的观测数据<br />
attitude    #30个部门在七个方面的调查结果，调查结果是同一部门35个职员赞成的百分比<br />
beaver1    #一只海狸每10分钟的体温数据，共114条数据<br />
beaver2    #另一只海狸每10分钟的体温数据，共100条数据<br />
BOD    #随水质的提高，生化反应对氧的需求（mg/l）随时间（天）的变化<br />
cars    #1920年代汽车速度对刹车距离的影响<br />
chickwts    #不同饮食种类对小鸡生长速度的影响<br />
esoph    #法国的一个食管癌病例对照研究<br />
faithful    #一个间歇泉的爆发时间和持续时间<br />
Formaldehyde    #两种方法测定甲醛浓度时分光光度计的读数<br />
Freeny     #每季度收入和其他四因素的记录<br />
dating from     #配对的病例对照数据，用于条件logistic回归<br />
InsectSprays     #使用不同杀虫剂时昆虫数目<br />
iris    #3种鸢尾花形态数据<br />
LifeCycleSavings    #50个国家的存款率<br />
longley    #强共线性的宏观经济数据<br />
morley    #光速测量试验数据<br />
mtcars    #32辆汽车在11个指标上的数据<br />
OrchardSprays     #使用拉丁方设计研究不同喷雾剂对蜜蜂的影响<br />
PlantGrowth     #三种处理方式对植物产量的影响<br />
pressure     #温度和气压<br />
Puromycin     #两种细胞中辅因子浓度对酶促反应的影响<br />
quakes     #1000次地震观测数据（震级&gt;4）<br />
randu     #在VMS1.5中使用FORTRAN中的RANDU三个一组生成随机数字，共400组。<br />
#该随机数字有问题。在VMS2.0以上版本已修复。<br />
rock     #48块石头的形态数据<br />
sleep     #两药物的催眠效果<br />
stackloss     #化工厂将氨转为硝酸的数据<br />
swiss     #瑞士生育率和社会经济指标<br />
ToothGrowth     #VC剂量和摄入方式对豚鼠牙齿的影响<br />
trees    #树木形态指标<br />
USArrests    #美国50个州的四个犯罪率指标<br />
USJudgeRatings    #43名律师的12个评价指标<br />
warpbreaks    #织布机异常数据<br />
women    #15名女性的身高和体重</p>
<p>列表<br />
state.center    #美国50个州中心的经度和纬度</p>
<p>类数据框<br />
ChickWeight    #饮食对鸡生长的影响<br />
CO2    #耐寒植物CO2摄取的差异<br />
DNase    #若干次试验中，DNase浓度和光密度的关系<br />
Indometh    #某药物的药物动力学数据<br />
Loblolly    #火炬松的高度、年龄和种源<br />
Orange    #桔子树生长数据<br />
Theoph    #茶碱药动学数据</p>
<p>时间序列数据<br />
airmiles    #美国1937-1960年客运里程营收（实际售出机位乘以飞行哩数）<br />
AirPassengers    #Box &amp; Jenkins航空公司1949-1960年每月国际航线乘客数<br />
austres    #澳大利亚1971-1994每季度人口数（以千为单位）<br />
BJsales    #有关销售的一个时间序列<br />
BJsales.lead    #前一指标的先行指标（leading indicator）<br />
co2    #1959-1997年每月大气co2浓度（ppm）<br />
discoveries    #1860-1959年每年巨大发现或发明的个数<br />
ldeaths    #1974-1979年英国每月支气管炎、肺气肿和哮喘的死亡率<br />
fdeaths    #前述死亡率的女性部分<br />
mdeaths    #前述死亡率的男性部分<br />
freeny.y    #每季度收入<br />
JohnsonJohnson    #1960-1980年每季度Johnson &amp; Johnson股票的红利<br />
LakeHuron    #1875-1972年某一湖泊水位的记录<br />
lh     #黄体生成素水平，10分钟测量一次<br />
lynx    #1821-1934年加拿大猞猁数据<br />
nhtemp     #1912-1971年每年平均温度<br />
Nile     #1871-1970尼罗河流量<br />
nottem     #1920-1939每月大气温度<br />
presidents     #1945-1974年每季度美国总统支持率<br />
UKDriverDeaths     #1969-1984年每月英国司机死亡或严重伤害的数目<br />
sunspot.month     #1749-1997每月太阳黑子数<br />
sunspot.year     #1700-1988每年太阳黑子数<br />
sunspots    #1749-1983每月太阳黑子数<br />
treering    #归一化的树木年轮数据<br />
UKgas    #1960-1986每月英国天然气消耗<br />
USAccDeaths    #1973-1978美国每月意外死亡人数<br />
uspop    #1790–1970美国每十年一次的人口总数（百万为单位）<br />
WWWusage    #每分钟网络连接数<br />
Seatbelts     #多变量时间序列。和UKDriverDeaths时间段相同，反映更多因素。<br />
EuStockMarkets    #多变量时间序列。欧洲股市四个主要指标的每个工作日记录，共1860条记录。</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>Warpbreaks这个数据集有3列变量，我们根据wool和tension这两个因子变量来分类对breaks这个数据变量求均值</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>Airquality这个数据集有6个列变量，大气层，阳光，风，温度，月份，天数，虽然它们都是数据变量，但是我们可以把其中几个因子化来进行分类汇总计算，比如我们以month来作为因子，这样把数据分成了各个月份的，再对ozone和Temp进行分别求均值</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>Chickwts这个数据有两列，不同的喂养环境下统计小鸡的重量，可以根据6中喂养环境来对各自的小鸡统计平均重量</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>Esoph这个数据集有5个列变量，其中3个是因子，两个是数据，，同理做数据汇总</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>本地图片，请重新上传</p>
<p>这是一个时间序列数据，可以进行画图</p>
<p>还可以查看很多自己安装的包里面内置的数据</p>
<p>比如我安装一个ggplot2，它会自动下载几个相关的包一起安装</p>
<p>本地图片，请重新上传</p>
<p>data(package="ggplot2")可以查看这个包自带的数据集</p>
<p>本地图片，请重新上传</p>
<p>R还可以进行脚本运算，实习批量化处理数据</p>
<p>本地图片，请重新上传</p>
<p>附录二：各种统计分布函数</p>
<p>1.二项分布Binomial distribution：binom</p>
<p>二项分布指的是N重伯努利实验，记为X ~ b(n,p)，E(x)=np,Var(x)=np(1-p)</p>
<p>pbinom(q,size,prob)， q是特定取值，比如pbinom(8,20,0.2)指第8次伯努利实验的累计概率。size指总的实验次数，prob指每次实验成功发生的概率</p>
<p>dbinom(x,size,prob), x同上面的q同含义。dfunction()对于离散分布来说结果是特定值的概率，对连续变量来说是密度（Density）</p>
<p>rbinom(n, size, prob)，产生n个b(size,prob)的二项分布随机数</p>
<p>qbinom(p, size, prob),quantile function 分位数函数。</p>
<p>分位数：</p>
<p>若概率0&lt;p&lt;1，随机变量X或它的概率分布的分位数Za。是指满足条件p(X&gt;Za)=α的实数。如t分布的分位数表，自由度f=20和α=0.05时的分位数为1.7247。 --这个定义指的是上侧α分位数</p>
<p>α分位数：</p>
<p>实数α满足0 &lt;α&lt;1 时，α分位数是使P{X&lt; xα}=F(xα)=α的数xα</p>
<p>双侧α分位数是使P{X&lt;λ1}=F(λ1)=0.5α的数λ1、使 P{X&gt;λ2}=1-F(λ2)=0.5α的数λ2。</p>
<p>qbinom是上侧分位数，如qbinom(0.95,100,0.2)=27,指27之后P(x&gt;=27)&gt;=0.95。即对于b(100,0.2)为了达到0.95的概率至少需要27次重复实验。</p>
<p>2.负二项分布negative binomial distribution （帕斯卡分布）nbinom</p>
<p>掷骰子，掷到一即视为成功。则每次掷骰的成功率是1/6。要掷出三次一，所需的掷骰次数属于集合 { 3, 4, 5, 6, ... } 。掷到三次一的掷骰次数是负二项分布的随机变量。</p>
<p>dnbinom(4,3,1/6)=0.0334898，四次连续三次1的概率为这个数。</p>
<p>概率函数为f(k;r,p)=choose(k+r-1,r-1)*p^r*(1-p)^k, 当r=1时这个特例分布是几何分布</p>
<p>rnbinom(n,size,prob,mu) 其中n是需要产生的随机数个数，size是概率函数中的r，即连续成功的次数，prob是单词成功的概率，mu未知..(mu是希腊字母υ的读音)</p>
<p>3.几何分布Geometric Distribution,geom</p>
<p>n次伯努利试验，前n-1次皆失败，第n次才成功的机率</p>
<p>dgeom(x,prob),注意这里的x取值是0:n，即dgeom(0,0.2)=0.2,以上的二项分布和负二项分布也是如此。</p>
<p>ngeom(n,prob)</p>
<p>4.超几何分布Hypergeometric Distribution，hyper</p>
<p>它描述了由有限个(m+n)物件中抽出k个物件，成功抽出指定种类的物件的次数（不归还）。</p>
<p>概率：p(x) = choose(m, x) choose(n, k-x) / choose(m+n, k) for x = 0, ..., k.</p>
<p>当n=1时，这是一个0-1分布即伯努利分布，当n接近无穷大∞时，超几何分布可视为二项分布</p>
<p>rhyper(nn,m,n,k),nn是需要产生的随机数个数，m是白球数（计算目标是取到x个白球的概率），n是黑球数，k是抽取出的球个数</p>
<p>dhyper(x, m, n, k)</p>
<p>5.泊松分布 Poisson Distribution,pois</p>
<p>p(x) = lambda^x exp(-lambda)/x!</p>
<p>for x = 0, 1, 2, .... The mean and variance are E(X) = Var(X) = λ.  x ~ π(λ)</p>
<p>泊松分布的参数λ是单位时间(或单位面积)内随机事件的平均发生率.泊松分布适合于描述单位时间内随机事件发生的次数。如某一服务设施在一定时间内到达的人数，电话交换机接到呼叫的次数，汽车站台的候客人数，机器出现的故障数，自然灾害发生的次数等等.</p>
<p>rpois(n, lambda)</p>
<p>dpois(x,lambda)</p>
<p>连续型</p>
<p>6.均匀分布 Uniform Distribution，unif</p>
<p>f(x) = 1/(max-min) for min &lt;= x &lt;= max.</p>
<p>runif(n,min,max).</p>
<p>生成16位数的随机数：as.character(runif(1,1000000000000000,9999999999999999))</p>
<p>dunif(x,min,max)=1,恒定等于1/(max-min).</p>
<p>对于连续变量，dfunction的值是x去特定值代入概率密度函数得到的函数值。</p>
<p>7.正态分布Normal Distribution，norm</p>
<p>f(x) = 1/(sqrt(2 pi) sigma) e^-((x - mu)^2/(2 sigma^2))</p>
<p>其中mu是均值，sigma是standard deviation标准差</p>
<p>理论上可以证明如果把许多小作用加起来看做一个变量,那么这个变量服从正态分布</p>
<p>rnorm(n,mean=0,sd=1)后两个参数如果不填则默认为0,1。</p>
<p>dnorm(x,mean,sd),sd是标准差。</p>
<p>画出正态分布概率密度函数的大致图形：</p>
<p>x&lt;-seq(-3,3,0.1)</p>
<p>plot(x,dnorm(x)) plot中的x,y要有相关关系才会形成函数图。</p>
<p>qnorm(p,mean,sd),这个还是上侧分位数，如qnorm(0.05)=-1.644854,即x&lt;=这个数的累计概率小于0.05</p>
<p>3sigma法则：对于正态分布的x，x取值在(mean-3sd,mean+3sd)几乎是在肯定的。</p>
<p>因为pnorm(3)-pnorm(-3)=0.9973002</p>
<p>用正太分布产生一个16位长的随机数字：</p>
<p>as.character(10^16*rnorm(1))</p>
<p>8.伽玛分布Gamma Distribution，gamma</p>
<p>http://zh.wikipedia.org/w/index.php?title=伽玛分布&#038;variant=zh-cn</p>
<p>假设随机变量X为 等到第α件事发生所需之等候时间。</p>
<p>f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s) for x &gt;= 0, a &gt; 0 and s &gt; 0.</p>
<p>Gamma分布中的参数α，称为形状参数（shape parameter），即上式中的s，β称为尺度参数（scale parameter）上式中的a</p>
<p>E(x)=s*a, Var(x)=s*a^2. 当shape=1/2,scale=2时，这样的gamma分布是自由度为1的开方分</p>
<p>dgamma(x,shape,rate=1,scale=1/rate), 请注意R在这里提供的rate是scale尺度参数的倒数，如果dgamma(0,1,2)则表示dgamma(0,shape=1,rate=2),而 非dgamma(0,shape=1,scale=2)</p>
<p>pgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE,</p>
<p>log.p = FALSE)</p>
<p>qgamma(p, shape, rate = 1, scale = 1/rate, lower.tail = TRUE,</p>
<p>log.p = FALSE)</p>
<p>rgamma(n, shape, rate = 1, scale = 1/rate)</p>
<p>9.指数分布Exponential Distribution，exp</p>
<p>指数分布可以用来表示独立随机事件发生的时间间隔，比如旅客进机场的时间间隔、中文维基百科新条目出现的时间间隔等等。</p>
<p>记作X ~ Exponential（λ）。</p>
<p>f(x) = lambda e^(- lambda x) for x &gt;= 0.</p>
<p>其中lambda λ &gt; 0是分布的一个参数，常被称为率参数（rate parameter）. E(x)=1/λ,Var(x)=1/λ^2</p>
<p>dexp(x, rate = 1, log = FALSE)</p>
<p>pexp(q, rate = 1, lower.tail = TRUE, log.p = FALSE)</p>
<p>qexp(p, rate = 1, lower.tail = TRUE, log.p = FALSE)</p>
<p>rexp(n, rate = 1)</p>
<p>假设在公交站台等公交车平均10分钟有一趟车，那么每小时候有6趟车，即每小时出现车的次数~ Exponential(1/6)</p>
<p>我们可以产生10个这些随机数看看rexp(10,1/6)</p>
<p>60/(rexp10,1/6)即为我们在站台等车的随机时间，如下：</p>
<p>[1]  6.443148 24.337131  6.477096  2.824638 15.184945 14.594903</p>
<p>[7]  7.133842  8.222400 42.609784 15.182827</p>
<p>可以看见竟然有一个42.6分钟的随机数出现，据说这种情况下你可以投诉上海的公交公司。</p>
<p>不过x符合指数分布，1/x还符合指数分布吗？</p>
<p>pexp(6,1/6)=0.6321206, 也就是说这种情况下只有37%的可能公交车会10分钟以内来。</p>
<p>按照以上分析一个小时出现的公交车次数应该不符合指数分布。</p>
<p>10.卡方分布(non-central)Chi-Squared Distribution，chisq</p>
<p>它广泛的运用于检测数学模型是否适合所得的数据，以及数据间的相关性。数据并不需要呈正态分布</p>
<p>k个标准正态变量的平方和即为自由度为k的卡方分布。</p>
<p>E(x)=k,Var(x)=2k.</p>
<p>dchisq(x, df, ncp=0, log = FALSE)</p>
<p>pchisq(q, df, ncp=0, lower.tail = TRUE, log.p = FALSE)</p>
<p>qchisq(p, df, ncp=0, lower.tail = TRUE, log.p = FALSE)</p>
<p>rchisq(n, df, ncp=0)</p>
<p>其中df为degrees of freedom。ncp是non-centrality parameter (non-negative).ncp=0时是central卡方分布，ncp不为0时，表示这个卡方分布是由非标准正态分布组合而成，ncp=这些正态 分布的均值的平方和。</p>
<p>11.β分布Beta Distribution，beta</p>
<p>变量x仅能出现于0到1之间。</p>
<p>空气中含有的气体状态的水分。表示这种水分的一种办法就是相对湿度。即现在的含水量与空气的最大含水量（饱和含水量）的比值。我们听到的天气预告用语中就经常使用相对湿度这个名词。</p>
<p>相对湿度的值显然仅能出现于0到1之间（经常用百分比表示）。冬季塔里木盆地的日最大相对湿度和夏季日最小相对湿度。证实它们都符合贝塔分布</p>
<p>dbeta(x, shape1, shape2, ncp = 0, log = FALSE)</p>
<p>pbeta(q, shape1, shape2, ncp = 0, lower.tail = TRUE, log.p = FALSE)</p>
<p>qbeta(p, shape1, shape2, ncp = 0, lower.tail = TRUE, log.p = FALSE)</p>
<p>rbeta(n, shape1, shape2, ncp = 0)</p>
<p>shape1，shape2是beta分布的两个参数。E(x)=s1/(s1+s2),var(x)=s1*s2/(s1+s2)^2 * (s1+s2+1)</p>
<p>12.t分布Student t Distribution，t</p>
<p>应用在当对呈正态分布的母群体的均值进行估计。当母群体的标准差是未知的但却又需要估计时，我们可以运用学生t 分布。</p>
<p>学生t 分布可简称为t 分布。其推导由威廉·戈塞于1908年首先发表，当时他还在都柏林的健力士酿酒厂工作。因为不能以他本人的名义发表，所以论文使用了学生 （Student）这一笔名。之后t 检验以及相关理论经由罗纳德·费雪的工作发扬光大，而正是他将此分布称为学生分布。</p>
<p>dt(x, df, ncp, log = FALSE)</p>
<p>pt(q, df, ncp, lower.tail = TRUE, log.p = FALSE)</p>
<p>qt(p, df, ncp, lower.tail = TRUE, log.p = FALSE)</p>
<p>rt(n, df, ncp)</p>
<p>其中df是自由度，ncp是non-centrality parameter delta，If omitted, use the central t distribution。ncp出现时表示分布由非标准的卡方分布构成。</p>
<p>13.F分布</p>
<p>一个F-分布的随机变量是两个卡方分布变量的比率。F-分布被广泛应用于似然比率检验，特别是方差分析中</p>
<p>df(x, df1, df2, ncp, log = FALSE)</p>
<p>pf(q, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)</p>
<p>qf(p, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)</p>
<p>rf(n, df1, df2, ncp)</p>
<p>df1，df2是两个自由度，ncp同t分布中的ncp。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1656.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R包精讲第四篇：4种R包安装方式</title>
		<link>http://www.bio-info-trainee.com/1565.html</link>
		<comments>http://www.bio-info-trainee.com/1565.html#comments</comments>
		<pubDate>Tue, 12 Apr 2016 15:45:07 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[bioconductor]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[包]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1565</guid>
		<description><![CDATA[请先看：R包精讲第一篇：如何查看你已经安装了和可以安装哪些R包？ 第一种方式，当 &#8230; <a href="http://www.bio-info-trainee.com/1565.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>请先看：<a title="详细阅读 R包精讲第一篇：如何查看你已经安装了和可以安装哪些R包？" href="http://www.bio-info-trainee.com/1537.html" rel="bookmark">R包精讲第一篇：如何查看你已经安装了和可以安装哪些R包？</a></p>
<p>第一种方式，当然是R自带的函数直接安装包了，这个是最简单的，而且不需要考虑各种包之间的依赖关系。</p>
<p>对普通的R包，直接install.packages()即可，一般下载不了都是包的名字打错了，或者是R的版本不够，如果下载了安装不了，一般是依赖包没弄好，或者你的电脑缺少一些库文件，如果实在是找不到或者下载慢，一般就用repos=来切换一些镜像。</p>
<table class="GEM3DMTCOFB ace_text-layer ace_line GEM3DMTCKT" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left">
<blockquote>
<pre id="rstudio_console_output" class="GEM3DMTCFGB" tabindex="0"><span class="GEM3DMTCLGB ace_keyword">&gt; </span><span class="GEM3DMTCLFB ace_keyword">install.packages("ape")  ##直接输入包名字即可
</span><span class="GEM3DMTCPFB  ace_constant ace_language">Installing package into ‘C:/Users/jmzeng/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)  ##一般不指定lib，除非你明确知道你的lib是在哪里
</span><span class="GEM3DMTCPFB  ace_constant ace_language">trying URL '<span style="color: #ff0000;">http://mirror.bjtu.edu.cn/cran</span>/bin/windows/contrib/3.1/ape_3.4.zip'
</span><span class="GEM3DMTCPFB  ace_constant ace_language">Content type 'application/zip' length 1418322 bytes (1.4 Mb)
</span><span class="GEM3DMTCPFB  ace_constant ace_language">opened URL   ## 根据你选择的镜像，程序会自动拼接好下载链接url
</span><span class="GEM3DMTCPFB  ace_constant ace_language">downloaded 1.4 Mb

</span>package ‘ape’ successfully unpacked and MD5 sums checked  ##表明你已经安装好包啦

The downloaded binary packages are in  ##程序自动下载的原始文件一般放在临时目录，会自动删除
	C:\Users\jmzeng\AppData\Local\Temp\Rtmpy0OivY\downloaded_packages
</pre>
</blockquote>
</td>
</tr>
<tr>
<td align="left"></td>
</tr>
<tr>
<td align="left">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td rowspan="1" align="left" width="1" height="">
<div class="GEM3DMTCLGB ace_keyword">&gt;</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>对于bioconductor的包，我们一般是</p>
<blockquote><p>source("http://bioconductor.org/biocLite.R") ##安装BiocInstaller</p>
<p>#options(BioC_mirror=”<a href="http://mirrors.ustc.edu.cn/bioc/">http://mirrors.ustc.edu.cn/bioc/</a>“) 如果需要切换镜像<br />
biocLite("ggbio")</p>
<p>或者直接BiocInstaller::biocLite('ggbio') ## 前提是你已经安装好了BiocInstaller</p>
<p>某些时候你还需要卸载remove.packages("BiocInstaller") 然后安装新的</p></blockquote>
<p>第二种方式，是直接找到包的下载地址，需要进入包的主页</p>
<blockquote><p>packageurl &lt;- "<span style="text-decoration: underline; color: #ff00ff;">http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_0.9.1.tar.gz</span>"<br />
packageurl &lt;- "http://cran.r-project.org/src/contrib/Archive/gridExtra/gridExtra_0.9.1.tar.gz"<br />
install.packages(packageurl, repos=NULL, type="source")<br />
#packageurl &lt;- "http://www.bioconductor.org/packages/2.11/bioc/src/contrib/ggbio_1.6.6.tar.gz"<br />
#packageurl &lt;- "http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_1.0.1.tar.gz"<br />
install.packages(packageurl, repos=NULL, type="source")</p></blockquote>
<p>这样安装的就不需要选择镜像了，也跨越了安装器的版本！</p>
<p>第三种是，先把包下载到本地，然后安装：</p>
<blockquote>
<pre><b>download.file</b>("<a href="http://bioconductor.org/packages/release/bioc/src/contrib/BiocInstaller_1.20.1.tar.gz">http://bioconductor.org/packages/release/bioc/src/contrib/BiocInstaller_1.20.1.tar.gz</a>","BiocInstaller_1.20.1.tar.gz")
##也可以选择用浏览器下载这个包
<b>install.packages</b>("BiocInstaller_1.20.1.tar.gz", repos = NULL)
## 如果你用的RStudio这样的IDE，那么直接用鼠标就可以操作了
或者用choose.files()来手动交互的选择你把下载的源码BiocInstaller_1.20.1.tar.gz放到了哪里。</pre>
</blockquote>
<p>这种形式大部分安装都无法成功，因为R包之间的依赖性很强！</p>
<p>第四种是：命令行版本安装</p>
<blockquote>
<pre>如果是linux版本，命令行从网上自动下载包如下：
sudo su - -c \
<span class="pl-s"><span class="pl-pds">"</span>R -e <span class="pl-cce">\"</span>install.packages('shiny', repos='https://cran.rstudio.com/')<span class="pl-cce">\"</span><span class="pl-pds">"
如果是linux，命令行安装本地包，在shell的终端
sudo R CMD INSTALL package.tar.gz
window或者mac平台一般不推荐命令行格式，可视化那么舒心，何必自讨苦吃</span></span></pre>
</blockquote>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1565.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R包精讲第三篇：如何切换镜像？</title>
		<link>http://www.bio-info-trainee.com/1561.html</link>
		<comments>http://www.bio-info-trainee.com/1561.html#comments</comments>
		<pubDate>Tue, 12 Apr 2016 13:11:53 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[bioconductor]]></category>
		<category><![CDATA[镜像]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1561</guid>
		<description><![CDATA[这个技巧很重要，一般来说，R语言自带的install.packages函数来安装 &#8230; <a href="http://www.bio-info-trainee.com/1561.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>这个技巧很重要，一般来说，R语言自带的install.packages函数来安装一个包时，都是用的默认的镜像！</p>
<p>如果你是用的Rstudio这个IDE，你的默认镜像就是： <a href="https://cran.rstudio.com/bin/windows/contrib/3.2/">https://cran.rstudio.com/ </a></p>
<p>如果你直接用的R语言，那么就是："http://cran.us.r-project.org" 但是一般你安装的时候会提醒你选择。</p>
<p><span id="more-1561"></span></p>
<p>而我们一般需要更改成自己最方便的</p>
<blockquote><p>  install.packages(pkgs, lib,<strong> repos = getOption("repos"),</strong><br />
<strong> contriburl = contrib.url(repos, type),</strong><br />
method, available = NULL, destdir = NULL,<br />
dependencies = NA, type = getOption("pkgType"),<br />
configure.args = getOption("configure.args"),<br />
configure.vars = getOption("configure.vars"),<br />
clean = FALSE, Ncpus = getOption("Ncpus", 1L),<br />
verbose = getOption("verbose"),<br />
libs_only = FALSE, INSTALL_opts, quiet = FALSE,<br />
keep_outputs = FALSE, ...)</p></blockquote>
<p>如果是在国内， install.packages("ABC",repos="<span class="GEM3DMTCPFB  ace_constant ace_language">http://mirror.bjtu.edu.cn/ </span>"),换成北大的镜像，飞一般的感觉！</p>
<p>如果想永久设置，就用options修改即可。<span class="GEM3DMTCPFB  ace_constant ace_language"><br />
</span></p>
<p>如果你是Rstudio的IDE，那么直接进入全局设置，一劳永逸的选择好镜像！</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/04/tmp.png"><img class="alignnone size-full wp-image-1562" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/04/tmp.png" alt="tmp" width="488" height="406" /></a></p>
<p>你可以check一下每个镜像的包是不是一致的：</p>
<p>dim(available.packages(contriburl = "<span style="color: #ff0000;"><strong>http://cran.rstudio.com/</strong></span>bin/windows/contrib/<span style="color: #ff0000;">3.2</span>/"))</p>
<p>更改镜像主页及包的版本即可查看所有镜像各提供哪些包！</p>
<p>当然，我们的bioconductor其实也是有镜像的，只是大部分人都不知道，也不会去用而已！</p>
<blockquote>
<div>source("<a href="http://bioconductor.org/biocLite.R">http://bioconductor.org/biocLite.R</a>")</div>
<div>options(BioC_mirror="<a href="http://mirrors.ustc.edu.cn/bioc/">http://mirrors.ustc.edu.cn/bioc/</a>")</div>
<div>biocLite("RGalaxy")##这样就用中科大的镜像来下载包啦</div>
</blockquote>
<div>## bioconductor还有很多其它镜像：<a href="https://www.bioconductor.org/about/mirrors/">https://www.bioconductor.org/about/mirrors/</a></div>
<div>##<a href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/chooseBioCmirror.html">https://stat.ethz.ch/R-manual/R-devel/library/utils/html/chooseBioCmirror.html</a></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1561.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R包精讲第二篇：如何安装旧版本的包？</title>
		<link>http://www.bio-info-trainee.com/1556.html</link>
		<comments>http://www.bio-info-trainee.com/1556.html#comments</comments>
		<pubDate>Tue, 12 Apr 2016 12:46:56 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[bioconductor]]></category>
		<category><![CDATA[包]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1556</guid>
		<description><![CDATA[既然你点进来看，肯定是有需求咯！ 一般来说，R语言自带的install.pack &#8230; <a href="http://www.bio-info-trainee.com/1556.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<pre>既然你点进来看，肯定是有需求咯！
一般来说，R语言自带的install.packages函数来安装一个包时，都是默认安装最新版的。
但是有些R包的开发者他会引用其它的一些R包，但是它用的是人家旧版本的功能，但他自己来不及更新或者疏忽了。
而我们又不得不用他的包，这时候就不得不卸载最新版包，转而安装旧版本包。

</pre>
<p><span id="more-1556"></span></p>
<p>这时候该怎么做呢？</p>
<p>首先你要用remove.packages这个命令把现在的包卸载掉！</p>
<p>然后去包的官网上面找到它的旧版本的下载链接：</p>
<p>我这里拿ggplot2举例：<a href="http://cran.r-project.org/src/contrib/Archive/ggplot2/">http://cran.r-project.org/src/contrib/Archive/ggplot2/ </a></p>
<blockquote><p>#packageurl &lt;- "http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_1.0.1.tar.gz"<br />
install.packages(packageurl, repos=NULL, type="source")</p></blockquote>
<p>我这里安装它的1.0.1版本，而不是最新版！</p>
<p>还有很多其它方法，我就不一一举例了，这个是我认为最方便，最直观的！</p>
<blockquote>
<div># install yesterday's version of checkpoint, by date</div>
<div>install.dates('checkpoint', Sys.Date() - 1)</div>
<div></div>
<div># install earlier versions of checkpoint and devtools</div>
<div>install.versions(c('checkpoint', 'devtools'), c('0.3.3', '1.6.1'))</div>
<div></div>
<div>参考：<a href="http://stackoverflow.com/questions/17082341/installing-older-version-of-r-package">http://stackoverflow.com/questions/17082341/installing-older-version-of-r-package</a></div>
</blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1556.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
