Affymetrix 芯片数据处理流程及原理简介

版权所有,转载必究!

本文作者:任红雷, 联系邮箱: renhongleiz@126.com

本文整理自个人汇报的PPT

首先,本文将结合代码讲解常用的Affymetrix 芯片数据处理流程

以GSE11787为例,数据为关于副猪嗜血杆菌对猪炎症发生影响的数据,请下载数据,并将其解压到任意的文件夹,以供之后使用:

http://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE11787&format=file

首先介绍一下关于基因表达芯片的背景。(最后附上流程代码)

1.提纲

提纲

2.中心法则(可自行百度)

中心法则

3.DNA 芯片是什么,作用如何?

芯片的含义与作用

5.Affymetrix 芯片

Affymetrix 芯片

6.芯片上的信息

芯片上的信息

7.PM和MM

PM和MM

8.芯片扫描结果

芯片扫描结果及其工作原理

9..CEL文件格式

.CEL文件格式

10.intensity(信号强度)的实际含义

intensity(信号强度)的实际含义

11..CEL文件以及.CDF文件

.CEL文件以及.CDF文件

12.数据处理流程

数据处理流程

13.拓展学习书籍列表

(本教程内容整理自Bioconductor Case Studies)

1.A (very) short introduction to R

https://cran.r-project.org/doc/contrib/Torfs+Brauer-Short-R-Intro.pdf

2.An Introduction to R

https://cran.r-project.org/doc/manuals/R-intro.pdf

3.Bioconductor Case Studies

lots of bioconductor workflows with source codes

链接: http://pan.baidu.com/s/1qYBtvIk

密码: eq85

Affymetrix 芯片数据处理流程的源代码

1.Read data

##1.ReadData##
#add bioconductor source

source("https://bioconductor.org/biocLite.R")

#install affy package from bioconductor

biocLite("affy")

#load affy package

library("affy")

#set the directory that you are working with,this can be replaced by your own CEL files path

setwd("/Users/Ren/Documents/Rcode/GSE11787_RAW")

#set the .CEL files path,this can be replaced by your own CEL files path

celpath="/Users/Ren/Documents/Rcode/GSE11787_RAW/"

#read .CEL files from directory of celfile.path

data = ReadAffy(celfile.path =celpath)

#replace the sample names of the data by trim off the ".CEL" suffix

sampleNames(data) = sub("\\.CEL$", "", sampleNames(data))

#read the phenoData of the CEL file.The "type.csv" file is consitituded with .csv format after you comprehensed the samples grouping on the GEO: http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE11787

samplestype <- read.csv(paste(celpath,"type.csv",sep = ""),header = TRUE,row.names = 1,na.strings = "NA",sep = ',',stringsAsFactors = F,as.is = !default.stringsAsFactors())

#replace the rownames of the samplestype by its sampleID

rownames(samplestype) = samplestype$sampleID

#match the rownames of your phenoData to the samplenames of experiments data,which will return the matched index

mt = match(rownames(samplestype), sampleNames(data))

#give a completed column description of the phenoData

vmd = data.frame(labelDescription = c("Sample ID", "Samples type: Haemophilus Parasuis infected or control"))

#make the matched sampletype rows and varMetadata to your data's phenoData

phenoData(data) = new("AnnotatedDataFrame", data = samplestype[mt, ], varMetadata = vmd)

#erase samples which has no type

data = data[,!is.na(data$type)]

其中type.csv的文件形式如下:


type.csv

2.Quality Control

##2.Quality Control##

#install the essential packages from Bioconductor

source("https://bioconductor.org/biocLite.R")

biocLite(c("affyQCReport","simpleaffy"))

#load the pakages of affyQCReport and simpleaffy

library("affyQCReport")

library("simpleaffy")

#Execute the Quality Control

saqc = qc(data)

#plot the quality control result

plot(saqc)

QC 之后的结果,如下图:

Quality Control

3.Data Normalization

##3.Data Normalization##
#packaged affyPLM provides another set of diagnostics that can be used to help assess array quality

source("https://bioconductor.org/biocLite.R")

biocLite(c("affyPLM"))

library("affyPLM")

#fit the basic probe-level model

dataPLM = fitPLM(data)

#plot normalized unscaled standard error (NUSE)

boxplot(dataPLM, main="NUSE", outline = FALSE, col="lightblue", las=3, whisklty=0, staplelty=0)

#plot relative log expression (RLE)

Mbox(dataPLM, main="RLE", outline = FALSE, col="mistyrose", las=3, whisklty=0, staplelty=0)

#if some sample was significantly elevated or more spread out,you can remove it as bad arrays

#here we don not have bad array ,the code next line is just a example to remove the sample "GSM298263",to execute this ,you can remove the sharp at the head of next line

#badArray = data[,-match(c("GSM298263"), sampleNames(data)) ]

normalized unscaled standard error (NUSE) 的各样本结果。

NUSE

relative log expression (RLE) 的各样本结果。

RLE

4.Data preprocessing

##4.Data preprocessing##
#load affy package

library("affy")

#rma preprocessing:which concluded 1.background correction,2.between array normalization 3.reporter summarization

datarma = rma(data)

source("https://bioconductor.org/biocLite.R")

#install the porcines' db for get its specices annotation of the probe set

biocLite(c("porcine.db"))

#load the package of porcine.db

library("porcine.db")

#to filter out probe sets with no Entrez Gene identifiers and Affymetrix control probes

datafiltered = nsFilter(datarma, remove.dupEntrez=FALSE, var.cutof =0.5)$eset


#t-tests for rows of a matrix, intended to be speed efficient

#The function computes the t-statistic, the difference of the group means between the two disease groups, and the corresponding p-value by using the t-distribution.

datatt = rowttests(datafiltered, "type")

#draw the volcano plot using x-axis:dm(difference of the group means),y-axis:group log(p-value) 

lod = -log10(datatt$p.value)

plot(datatt$dm, lod, pch=".", xlab="log-ratio",ylab=expression(-log[10]~p))

#line indicates an untransformed p-value of 0.01, so points above it will be significant

abline(h=2)

source("https://bioconductor.org/biocLite.R")

#install the porcine's db for get its specices annotation of the probe set

biocLite(c("limma"))

library("limma")

#make the design of the experiment as a matrix with its type

design = model.matrix(~datafiltered$type)

datalim = lmFit(datafiltered, design)

#When there are few replicates, the variance is not well estimated and the t-statistic can perform poorly. 

#It can be solved by a improved method called empirical Bayes to give a sensible estimation of variance and t-statistic

#When sample sizes are moderate or large, say ten or more in each group, there is generally no advantage (but also no disadvantage) to using the Bayesian approach.

dataeb = eBayes(datalim)

火山图的结果(Volcano plot),黑线之上的基因代表p值显著的基因

Volcano plot

5.GO analysis

##GO analysis##

source("https://bioconductor.org/biocLite.R")

#install the porcine's db for get its specices annotation of the probe set

biocLite(c("topGO"))

library(topGO)

#multiple testing problem corrected by multtest package

#Alternatively,the function topTable in the limma package provides multiple testing adjustment methods, including Benjamini and Hochberg’s false discovery rate (FDR), simple Bonferroni correction, and several others.

#for more information you can access:http://www.jianshu.com/p/9e97e9b351fd,and http://www.jianshu.com/p/a262cf3d18b9

#get the top 10 differential expressed gene by multiple testing correction of Benjamini-Hochberg (FDR) method

tabofallgene = topTable(dataeb, coef=2, adjust.method="BH", n=length(datatt[,1]))

#get the p-value of all genes named with the probe set name

geneList=setNames(tabofallgene[,5],rownames(tabofallgene))

annotation_db_name=paste(annotation(datafiltered),".db",sep="")

#load the annotation db package

library(package = annotation_db_name, character.only = TRUE)

#method to extract top differential expressed gene

topDiffGenes <- function(allScore) {
  return(allScore < 0.01)
}

#get the count of the differential expressed gene set

sum(topDiffGenes(geneList))

#new a topGOdata type object and use biology process(a gene ontology category),all gene is geneList, differential expressed gene is  topDiffGenes

sampleGOdata <- new("topGOdata", description = "Simple session", ontology = "BP",allGenes = geneList, geneSel = topDiffGenes,nodeSize = 10,annot = annFUN.db, affyLib = annotation_db_name)

#Performing the enrichment tests

#Fisher’s exact test which is based on gene counts

resultFisher <- runTest(sampleGOdata, algorithm = "classic", statistic = "fisher")

#Kolmogorov-Smirnov like test which computes enrichment based on gene scores.

resultKS <- runTest(sampleGOdata, algorithm = "classic", statistic = "ks")

resultKS.elim <- runTest(sampleGOdata, algorithm = "elim", statistic = "ks")

#make all GO enrichment result to a table called allRes

allRes <- GenTable(sampleGOdata, classicFisher = resultFisher,classicKS = resultKS, elimKS = resultKS.elim,orderBy = "elimKS", ranksOf = "classicFisher", topNodes = 10)

#draw the GO tree graph,with a depth of 10

tree_depth=10

showSigOfNodes(sampleGOdata, score(resultKS.elim), firstSigNodes = tree_depth, useInfo = 'all')

GO terms的DAG图:

GO

6.可选步骤.绘制样本集的热图(heatmap)和level plot

##prestep:1.read data from .CEL files and 2.Quality control

##generate sample's level plot and heatmap##

#calculate the distance of a n*n matrix,and set the diagonal to zero

dd = dist2(log2(exprs(data)),diagonal=0)

#Hierarchical clustering of dd

dd.row <- as.dendrogram(hclust(as.dist(dd)))

#x or y axis sample order index in dd matrix

row.ord <- order.dendrogram(dd.row)

source("https://bioconductor.org/biocLite.R")

biocLite(c("latticeExtra"))

library("latticeExtra")

#add lengend

legend = list(top=list(fun=dendrogramGrob, args=list(x=dd.row, side="top")))

#give a level plot

lp = levelplot(dd[row.ord, row.ord],scales=list(x=list(rot=90)), xlab="", ylab="", legend=legend)

lp

install.packages(c("gplots","RColorBrewer"))

library(gplots)

library(RColorBrewer)

# creates a own color palette from red to green

my_palette <- colorRampPalette(c( "green","yellow", "red"))(n = 299)

gplots:::heatmap.2(dd, Rowv =FALSE,Colv=dd.row, col = my_palette, tracecol=NA,density.info="none",cexRow=0.4,cexCol=0.4)

热图如下:

heatmap

level plot如下:

levelplot
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容