{"id":283,"date":"2018-03-21T22:30:14","date_gmt":"2018-03-21T14:30:14","guid":{"rendered":"http:\/\/www.wuchangsong.com\/?p=283"},"modified":"2018-03-23T20:35:27","modified_gmt":"2018-03-23T12:35:27","slug":"deseq%e5%88%86%e6%9e%90%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/www.wuchangsong.com\/?p=283","title":{"rendered":"DESeq\u5206\u6790\u6d41\u7a0b"},"content":{"rendered":"<pre>source(\"https:\/\/bioconductor.org\/biocLite.R\")\r\nbiocLite(\"DESeq\")\r\nlibrary(\"DESeq\")\r\ndatabase &lt;- read.table(file = \"macrophage_genes.count_table.matrix\", sep = \"\\t\", header = T, row.names = 1)\r\ncountData &lt;- database[,1:3]\r\ncondition &lt;- factor(c(\"A\",\"B\",\"C\"))#\u65e0\u751f\u7269\u5b66\u91cd\u590d\r\n#type &lt;- factor(c(rep(\"A\",3), rep(\"B\",3))) \u6709\u751f\u7269\u5b66\u91cd\u590d\r\ndatabase &lt;- round(as.matrix(countData))#\u53d6\u6574\u6570\u578b\r\ndds &lt;- newCountDataSet(database,condition)\r\ndds &lt;- estimateSizeFactors(dds)\r\ndds &lt;- estimateDispersions(dds, method=\"blind\", sharingMode=\"fit-only\" )#\u65e0\u751f\u7269\u5b66\u91cd\u590d\r\ndds &lt;- estimateDispersions(dds) # \u6709\u751f\u7269\u5b66\u91cd\u590d\r\nresAvsB &lt;- nbinomTest(dds,\"A\",\"B\")\r\nresAvsC &lt;- nbinomTest(dds,\"A\",\"C\")\r\ntable(resAvsB$pval &lt;0.05)\r\ntable(resAvsC$pval &lt;0.05)\r\nresAvsB &lt;- resAvsB[order(resAvsB$pval),]#\u6392\u5e8f\r\nresAvsC &lt;- resAvsC[order(resAvsC$pval),] \r\nplotMA(resAvsB, ylim = c(-5,5), col = ifelse(resAvsB$pval&gt;=0.05, \"gray32\", \"red3\"),linecol = \"#ff000080\" )#\u753bMA\u56fe\r\nnorcounts &lt;- counts(dds, normalized=T)#\u63d0\u53d6\u6807\u51c6\u5316\u540e\u7684counts\r\nwrite.table(as.data.frame(norcounts),\r\nfile=\"normalized_counts_ABC.txt\",\r\nsep=\"\\t\",\r\nquote = F)\r\nresAvsBup &lt;- subset(resAvsB, pval &lt; 0.05 &amp; log2FoldChange &gt;0 )\r\nresAvsBdown &lt;- subset(resAvsC, pval &lt; 0.05 &amp; log2FoldChange &lt;0 )\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>source(&#8220;https:\/\/bioconductor.org\/biocLite.R&#8221;) biocLite(&#8220;DESeq&#8221;) library(&#8220;DESeq&#8221;) database &lt;- read.table(file = &#8220;macrophage_genes.count_table.matrix&#8221;, sep = &#8220;\\t&#8221;, header = T, row.names = 1) countData &lt;- database[,1:3] condition &lt;- factor(c(&#8220;A&#8221;,&#8221;B&#8221;,&#8221;C&#8221;))#\u65e0\u751f\u7269\u5b66\u91cd\u590d #type &lt;- factor(c(rep(&#8220;A&#8221;,3), rep(&#8220;B&#8221;,3))) \u6709\u751f\u7269\u5b66\u91cd\u590d database &lt;- round(as.matrix(countData))#\u53d6\u6574\u6570\u578b dds &lt;- newCountDataSet(database,condition) dds &lt;- estimateSizeFactors(dds) dds &lt;- estimateDispersions(dds, method=&#8221;blind&#8221;, sharingMode=&#8221;fit-only&#8221; )#\u65e0\u751f\u7269\u5b66\u91cd\u590d dds &lt;- estimateDispersions(dds) # \u6709\u751f\u7269\u5b66\u91cd\u590d resAvsB &lt;- nbinomTest(dds,&#8221;A&#8221;,&#8221;B&#8221;) resAvsC &lt;- nbinomTest(dds,&#8221;A&#8221;,&#8221;C&#8221;) table(resAvsB$pval [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10],"tags":[],"_links":{"self":[{"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts\/283"}],"collection":[{"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":4,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":287,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions\/287"}],"wp:attachment":[{"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}