【R>>配对样本】提取TCGA中的配对样本

肿瘤研究中,常常需要关注癌和癌旁组织,这个时候就需要找出这些配对样本。下面就来实战吧!

1.下载counts数据转为TPM

counts转TPM教程:【R>>IOBR】counts转TPM

rm(list = ls())
library(IOBR)
tcga_eset <- data.table::fread("HTSeq_Counts_PRAD.txt",data.table = F) %>% 
  mutate(Tags=str_sub(Tags,1,15)) %>% 
  column_to_rownames("Tags")
tcga_tpm <- count2tpm(countMat = tcga_eset,
                      idType = "Ensembl",
                      source = "default")

2.分别提取normal和tumor

exp_nor <- tcga_tpm[,str_sub(colnames(tcga_tpm),14,15)=="11"]
exp_tum <- tcga_tpm[,str_sub(colnames(tcga_tpm),14,15)=="01"]
patient <- str_sub(colnames(exp_nor),1,12)
k <- str_sub(colnames(exp_tum),1,12) %in% patient;table(k)

神奇的事情发生了,癌旁有52个,但配对的有54个。



原来是有重复测的样本,将它去掉就好喽。


3.去重+合并

exp_tum <- exp_tum[,!str_detect(colnames(exp_tum),"Rep")]
exp2 <- cbind(exp_nor,exp_tum)
exp2 <- log2(exp2+1)
index <- paste(patient,"01",sep = "-")
exp2 <- exp2[,c(colnames(exp_nor),index)] #保证配对顺序

参考链接:
从TCGA表达矩阵里拆出配对样本

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容