记录一次获取top1000表达量以及字符串简单处理

目的:

1,提取指定列表达量之和排名前1000的id
2,修改ID列为指定名称(字符串split)

过程:

  • 使用rowSums、sort函数获取top1000的索引,并重新写入
  • 修改ID:使用strsplit(),将字符串拆分成列表(strsplit(string,delim)),并将列表转换成向量(unlist)重新写入。
#step1, load origin data
input_table <- fread(in_file_main,header = T,fill=T,quote=""); #load file;
  paste("1_load file success!\n")
#step2,进行top1000fpkm表达量的计算
input_table$sum_top1000 <- rowSums(input_table[,c(29:40,45)])
  paste("2_calculate data of sum fpkm success!\n")
  #head(input_table$sum_top1000)

#step3,获取top1000的fpkm以及gopath注释
  #step3.1 get index of top 1000
  sort_index <- as.data.frame(sort(input_table$sum_top1000, decreasing = TRUE,index.return = TRUE ))
  sort_index_top1000 <- sort_index[1:1000,2]
  #step3.2 get data by index of top 1000
  exp_data <- data.frame(input_table[sort_index_top1000,c(1,29:40,45,176:185)]) #索引列自动作为row.names
#step4, draw exp_cluster by above data.
  #step4.1, tran rownames
  x <- "brain   eye fin gill    hood    heart   intestine   muscle  kidney  liver   testis  spleen  skin"#new row
  y <- strsplit(x,split = "\t")
  z <- unlist(y)
  
  colnames(exp_data)[2:14] <- z
  
  write.table(exp_data,sep="\t",col.names =TRUE,row.names = FALSE,file = out_file_name2) 
  paste("4_1_write table of cluster success!")
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ORA-00001: 违反唯一约束条件 (.) 错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常。 O...
    我想起个好名字阅读 10,791评论 0 9
  • 关于Mongodb的全面总结 MongoDB的内部构造《MongoDB The Definitive Guide》...
    中v中阅读 32,120评论 2 89
  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 9,946评论 0 5
  • 概要 64学时 3.5学分 章节安排 电子商务网站概况 HTML5+CSS3 JavaScript Node 电子...
    阿啊阿吖丁阅读 13,102评论 0 3
  • 2016-03-04 宝木大仙 浅白轩 午后阳光正好,照在窗前的地上明晃晃的一片光亮,小女孩甚至觉得,那可能是一片...
    宝木大仙阅读 3,161评论 0 1