原文載于生信技能樹
我寫此文是為了致敬生信技能樹團隊!感謝他們無私分享!
以下是生信技能樹學員筆記投稿
芯片分析中經常會遇到Affymetrix Human Transcriptome Array 2.0芯片,由于目前還沒有現成的R包可以用,因此分析方法也不統一。見生信技能樹Jimmy老師HTA2.0芯片比較麻煩,其實這類常見的有3個平臺,3種類型:
GPL17586 [HTA-2_0] Affymetrix Human Transcriptome Array 2.0 [transcript (gene) version]
GPL19251 [HuGene-2_0-st] Affymetrix Human Gene 2.0 ST Array [probe set (exon) version]
GPL16686 [HuGene-2_0-st] Affymetrix Human Gene 2.0 ST Array [transcript (gene) version]
對于這三種平臺可以去Affymetrix的官網去查看其區別,也可以去NCBI去查看。
一、獲得芯片平臺信息文件
通常基因芯片分析,一般要下載其平臺信息。一般來說我們下載GPL是為了得到芯片的探針對應基因ID的關系列表。詳情可以了解:解讀GEO數據存放規律及下載,一文就夠一文就夠-從GEO數據庫下載得到表達矩陣首先是GPL17586平臺的芯片,下載其對應的平臺文件GPL17586.soft.gz,這類文件通常都比較大,加上國內下載速度太慢,通常都是等了很久,還是下載不了。
查看GPL17586平臺下單個的GSE對應的GSEXXX.soft.gz文件,發現其信息與GPL17586.soft.gz相同;下載單個GSE對應的soft文件后,同樣可以做id轉換。
下面以GPL17586平臺下的GSE110359為例,進行id轉換,首先是下載GSE110359對應的GSE110359_family.soft.gz文件
1、讀入下載好的soft文件
##
rm(list = ls())
options(stringsAsFactors = F)
#加載R包
library(GEOquery)
gse <- getGEO(filename = "GSE110359_family.soft.gz",destdir = ".")
str(gse)
length(gse)
2、提取探針、探針對應的基因及其位于染色體上的位置等信息
id_probe <- gse@gpls$GPL17586@dataTable@table
dim(id_probe)
head(id_probe)
id_probe[1:4,1:15]
View(head(id_probe))## you need to check this , which column do you need
提取需要的第1列(ID)或者第2列(probeset_id)和第8列(gene_assignment)。當然也可以不提取,每一列都保留。
probe2gene <- id_probe[,c(2,8)]
3、提取第8列 gene_assignment中的基因名稱,并添加到probe2gene
library(stringr)
probe2gene$symbol=trimws(str_split(probe2gene$gene_assignment,'//',simplify = T)[,2])
plot(table(table(probe2gene$symbol)),xlim=c(1,50))
head(probe2gene)
dim(probe2gene)
View(head(probe2gene))
ids2 <- probe2gene[,c(1,3)]
View(head(ids2))
ids2[1:20,1:2]#含有缺失值
table(table(unique(ids2$symbol)))#30907 ,30906個基因,一個空字符
save(ids2,probe2gene,file='gse-probe2gene.Rdata')
以上為id轉換的第一種方法,下面看第二種方法:
4、使用biomaRt包進行id轉換
biomaRt包其實也依賴于網速
load("gse-probe2gene.Rdata")
dim(probe2gene)
View(head(probe2gene))
# 加載biomaRt包
library(biomaRt)
value <- probe2gene$probeset_id
attr <- c("affy_hta_2_0","hgnc_symbol")
ensembl <- useMart("ensembl", dataset = "hsapiens_gene_ensembl")
ids <- getBM(attributes = attr,
filters = "affy_hta_2_0",
values = value,
mart = ensembl,
useCache = F)
dim(ids)#[1] 1041 2
View(head(ids))
save(ids,file = "GPL17586_ids.Rdata")
#去重之后
attributes <- listAttributes(ensembl)
View(attributes) # 查看支持的芯片轉換格式
save(ids,ensembl,y,file = "ensembl.Rdata")
plot(table(table(ids$hgnc_symbol)),xlim=c(1,50))
table(table(unique(ids$hgnc_symbol)))#去重之后有29262,丟失了一很多
# 去重復
ids3 <- ids[!duplicated(ids$hgnc_symbol),]
綜上,可以看出兩種方法得到的基因數量差別不大都是從7萬多個探針中,獲得了差不多3萬個基因。
5、表達矩陣和基因id的合并
下面就是表達矩陣和id的合并了;下載表達矩陣,推薦使用Jimmy的萬能包GEOmirror一行命令搞定。
library(GEOmirror)
geoChina(gse = "GSE110359", mirror = "tercent")
library(GEOmirror)
gset <- geoChina(gse = "GSE110359", mirror = "tercent")
gset
a=exprs(gset[[1]])
a[1:4,1:4]
gset[[1]]@annotation
#過濾表達矩陣
exprSet <- a
library(dplyr)
exprSet <- exprSet[rownames(exprSet) %in% ids2$probeset_id,]
dim(exprSet)
exprSet[1:5,1:5]
#ids過濾探針
ids <- ids2[match(rownames(exprSet),ids2$probeset_id),]
dim(ids)
ids[1:5,1:2]
#ids2[1:5,1:2]
#合并表達矩陣和ids
idcombine <- function(exprSet, ids){
tmp <- by(exprSet,
ids$symbol,
function(x) rownames(x)[which.max(rowMeans(x))])
probes <- as.character(tmp)
print(dim(exprSet))
exprSet <- exprSet[rownames(exprSet) %in% probes,]
print(dim(exprSet))
rownames(exprSet) <- ids[match(rownames(exprSet), ids$probeset_id),2]
return(exprSet)
}
new_exprSet <- idcombine(exprSet,ids)
new_exprSet[1:4,1:6]
dim(new_exprSet)
rownames(new_exprSet)
save(new_exprSet,file = "new_exprSet.Rdata")
接下來就是質控、差異分析,火山圖、GO和KEEG分析,生信技能樹上已經有很多這類的推文了,這里就不做演示了。
該方法也適用于GPL16686與GPL19251平臺的芯片。只是GPL16686的信息這樣的可以用Y叔叔的包進行轉換id。
GPL16686平臺信息GPL19251平臺信息
轉換id之后總會有很多探針得不到對應的基因或者很多探針對應一個基因。其實,基因和探針的關系是多對多的關系。