美文网首页ggplot集锦
TCGA乳腺癌芯片数据分组为TNBC和NOT TNBC

TCGA乳腺癌芯片数据分组为TNBC和NOT TNBC

作者: SolomonTeng | 来源:发表于2018-11-29 23:35 被阅读56次

    健明老师布置的作业,感觉还是蛮吃力的。这篇会有点凌乱,一点一点来吧。

    1、转义符

    首先我遇到了一个问题,就是我的变量里的id是‘TCGA-B6-A0X7-01’诸如此类,而我的数据集中则是‘TCGA·B6·A0X7·01’,所以首先我要统一id名,这里就用到了gsub函数,但是这里需要用一个转义符。

    colnames(exprSet1) <- gsub('\\.','-',colnames(exprSet1))  #转义符
    

    这两个‘\\’是必须加的,不然是替换不了的。

    2、找出临床数据中,TNBC的患者id

    临床数据在上一篇我说的UCSC网站上可以下载

    rm(list = ls())
    options(stringsAsFactors = F)
    
    a=read.table('BRCA_clinicalMatrix.tsv',header = T,sep = '\t',quote = '')
    (tmp=as.data.frame(colnames(a)))
    tmp=a[,grepl('her2',colnames(a))]
    head(tmp)
    table(a$breast_carcinoma_estrogen_receptor_status)
    table(a$breast_carcinoma_progesterone_receptor_status)
    table(a$lab_proc_her2_neu_immunohistochemistry_receptor_status)
    eph=a[,grepl('receptor_status',colnames(a))]
    head(eph)
    eph=eph[,1:3]
    tnbc_s=a[apply(eph,1, function(x) sum(x=='Negative'))==3,1]
    

    3、找出tumor样本,舍弃掉not tumor

    exprSet1=na.omit(array_brca)
      exprSet1=exprSet1[,group_list=='tumor']
    

    4、顺序对应TNBC和not TNBC的变量

    phe$er <- ifelse(phe$breast_carcinoma_estrogen_receptor_status=='Negative',1,0)
    table(phe$er)
    phe$pr <- ifelse(phe$breast_carcinoma_progesterone_receptor_status=='Negative',1,0)
    table(phe$pr)
    phe$her2 <- ifelse(phe$lab_proc_her2_neu_immunohistochemistry_receptor_status=='Negative',1,0)
    table(phe$her2)
    phe$TNBC <- ifelse((phe$er==1 & phe$pr==1 & phe$her2 ==1),'TNBC','NOT_TNBC')
    group_list=phe$TNBC[match(colnames(exprSet1),phe$sampleID)]
    table(group_list)
    save(exprSet1,group_list,file = 'tcga_brca_TNBC_tumor.Rdata')
    

    ok,我承认这一篇整理的很差,可能也反映了我最近浮躁的心态,需要好好调整一下了。

    相关文章

      网友评论

        本文标题:TCGA乳腺癌芯片数据分组为TNBC和NOT TNBC

        本文链接:https://www.haomeiwen.com/subject/tgwqcqtx.html