{"id":700,"date":"2021-03-15T21:51:29","date_gmt":"2021-03-15T13:51:29","guid":{"rendered":"http:\/\/www.wuchangsong.com\/?p=700"},"modified":"2021-03-20T16:47:28","modified_gmt":"2021-03-20T08:47:28","slug":"preprocesscore%e5%88%86%e4%bd%8d%e6%95%b0%e6%a0%87%e5%87%86%e5%8c%96","status":"publish","type":"post","link":"http:\/\/www.wuchangsong.com\/?p=700","title":{"rendered":"preprocessCore\u5206\u4f4d\u6570\u6807\u51c6\u5316"},"content":{"rendered":"<pre>library(\"preprocessCore\")\nlibrary(\"ggplot2\")\ndata &lt;- read.table(\"mouse_gc.xls\",sep=\"\\t\",header = TRUE)\nrownames(data) &lt;- data$GeneID\n#rownames(data) &lt;- data[,1]\n#data_mat &lt;- data.matrix(data[,-1]) \nquantile_normalisation &lt;- function(df){\n  df_rank &lt;- apply(df,2,rank,ties.method=\"min\")\n  df_sorted &lt;- data.frame(apply(df, 2, sort))\n  df_mean &lt;- apply(df_sorted, 1, mean)\n\n  index_to_mean &lt;- function(my_index, my_mean){\n    return(my_mean[my_index])\n  }\n\n  df_final &lt;- apply(df_rank, 2, index_to_mean, my_mean=df_mean)\n  rownames(df_final) &lt;- rownames(df)\n  return(df_final)\n}\nnew_data &lt;- quantile_normalisation(data[,2:19])\nboxplot(data)\nboxplot(new_data)\nwrite.table(new_data, file=\"111.xls\", sep=\"\\t\", quote=F, row.names=T, col.names=T)\n##############################################################\ncol_names &lt;- colnames(data)\nrow_names &lt;- rownames(data)\ndata &lt;- as.matrix(data)\nb=normalize.quantiles(data)\nboxplot(b)\n##\u4f7f\u7528normalize.quantiles\u51fd\u6570\u548c\u4e0a\u9762\u7ed3\u679c\u76f8\u540c<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>library(&#8220;preprocessCore&#8221;) library(&#8220;ggplot2&#8221;) data &lt;- read.table(&#8220;mouse_gc.xls&#8221;,sep=&#8221;\\t&#8221;,header = TRUE) rownames(data) &lt;- data$GeneID #rownames(data) &lt;- data[,1] #data_mat &lt;- data.matrix(data[,-1]) quantile_normalisation &lt;- function(df){ df_rank &lt;- apply(df,2,rank,ties.method=&#8221;min&#8221;) df_sorted &lt;- data.frame(apply(df, 2, sort)) df_mean &lt;- apply(df_sorted, 1, mean) index_to_mean &lt;- function(my_index, my_mean){ return(my_mean[my_index]) } df_final &lt;- apply(df_rank, 2, index_to_mean, my_mean=df_mean) rownames(df_final) &lt;- rownames(df) return(df_final) } new_data &lt;- quantile_normalisation(data[,2:19]) boxplot(data) boxplot(new_data) write.table(new_data, [&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\/700"}],"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=700"}],"version-history":[{"count":3,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts\/700\/revisions"}],"predecessor-version":[{"id":718,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=\/wp\/v2\/posts\/700\/revisions\/718"}],"wp:attachment":[{"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=700"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wuchangsong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}