分享

使用R从RNA-seq数据绘制热图代码

 yjt2004us 2018-06-22

文/伍鸿荣


要做热图,首先我们是要准备好数据,比如说TCGA的rna-seq,或者你自个测有的数据。然后可能利用deseq  包进行差异分析。比如说作者提出的用阿扎胞苷对AML3细胞影响的基因表达谱数据。


 数据筛选:在热图上绘制所有5704个FDR调整p值<>


  1. Read the count matrix and DESeq table into R and merge into one table

  2. Sort based on p-value with most significant genes on top

  3. Select the columns containing gene name and raw counts

  4. Scale the data per row

  5. Select the top 100 genes by significance

  6. Generate the heatmap with mostly default values


以下是我将在以下R脚本代码:

#read in the count matrix

mx<-read.table('aza_aml3_countmatrix.xls', row.names="1" ,="" header="">


#read in the DESeq DGE spreadsheet

dge<-read.table('deb_deseq.xls', row.names="1" ,="" header="">

#merge the counts onto the DGE spreadsheet

mg<>


#sort the merged table by p-value

smg<-mg[order(mg$pval),>


#select only the columns containing the gene names and count data

x<-subset(smg, select="c('Row.names'," 'untr1',="" 'untr2',="" 'untr3',="" 'aza1',="" 'aza2',="">


#make the table a data frame with gene names then remove duplicate gene name column

y<-(as.data.frame(x, row.names="">

x<-subset(y,>


#scale rows

xt<>

xts<>

xtst<>


#only grab top 100 by p-value

h<-head(xtst, n="">


#set layout options - adjust if labels get cut off

pdf('heatmap.pdf',width=7, height=8)


#draw heatmap allowing larger margins and adjusting row label font size

heatmap(h, margins = c(4,10), cexRow=.4)


#output plot to file

dev.off()


正如您所看到的,热图显示了这100个最显着差异基因的严重表达变化。还要注意,前100名中的大多数基因是下调的。



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多