
#设置工作目录
setwd("xena")
#install.packages("tidyverse")
library(tidyverse)##每次重新打开R,都要重新打开Rlibrary一下
#xena官网下载相应数据
#https://xenabrowser.net/datapages/
##阅读文件
#读取tsv文件
counts1 = read.table(file = 'TCGA-LIHC.htseq_counts.tsv', sep = '\t', header = TRUE)
rownames(counts1) <- counts1[,1] #Alt <-
x <- counts1[,1:3]
counts1 = counts1[-1]#去掉第一列
#substr函数
substr("wanglihong";,1,4)#截取列名字符串第1至4个字母,返回结果:wang
#table函数
table(substr(colnames(counts1、14、16)#table是分组运算
#c("01A","11A") #01a代表肿瘤组,11A代表正常组
#%in%符号用于判断是否属于(判断符号前面的东西是否属于符号后面的东西)
counts1 <- counts1[,substr(colnames(counts1),14,16)%in% c("01A","11A")]
table(substr(colnames(counts1),14,16))
#保留行名前15位
rownames(counts1) <- substr(rownames(counts1),1,15)
#ceiling表示向上取整数
ceiling(1.2)
ceiling(3.8)
counts <- ceiling(2^(counts1)-1)#可以看TCGA官网关于数据的处理方法:log2(x 1)=counts1
##文件输出
#输出为文本
write.table(counts,"counts.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
#输出为表格
write.csv(counts, file = "counts.csv")
今天的文章就分享到这里,如果你也网赚副业项目感兴趣,可以添加 维信:beng6655 备注:副业!
如若转载,请注明出处:https://www.haoxue2.com/1139.html