PAM50的概念及分子分型算法原理
众所周知,癌症具有异质性,在乳腺癌领域,不同亚型的癌症比不同器官来源癌症的差异要大很多。最简单癌症分类,当然是一个基因,比如ER阳性或者ER阴性的乳腺癌患者,并不是说人类有2万多个蛋白编码基因就可以有2万多种分类,其实在乳腺癌领域常用的分类,就是ER,HER2,PR等等,如果这3个基因都不表达,就是临床里面比较恶性的三阴性乳腺癌啦。
激素受体(ER、PR)阳性组 管腔A型(ER阳性,PR≥20%,HER2阴性,Ki-67<20%) 管腔B型(ER阳性,PR<20%和/或HER2阳性和/或Ki-67≥20%) 激素受体(ER、PR)阴性组 HER2过表达型(ER阴性,PR阴性,HER2阳性) 基底样型(ER阴性,PR阴性,HER2阴性)
4个基因表达芯片数据集,定义了“intrinsic” gene set ,有1906个基因 对189病人的1906个基因的表达矩阵层次聚类(median centered by feature/gene, Pearson correlation, average linkage) 使用SigClust对层次聚类结果划分cluster SigClust得到9个cluster,包含 luminal A (dark blue), luminal B (light blue), HER2-enriched (pink), normal-like (green), and basal-like (red). 然后精简基因集,每个分组选择top10的基因,得到5个分组的共50个基因。这里使用了Classification by Nearest Centroids (ClaNC) 算法。 也就是说189个病人里面的122个划分结果与qRT-PCR 一致。
50个基因
的表达量即可对病人进行初步分类。而且作者提供了全套代码和数据:The centroids, gene lists, and R code to produce the classification are all available along with the clinical information for the training set on this page: https://genome.unc.edu/pubsup/breastGEO/ Specifically, the R code and supporting data files are here: https://genome.unc.edu/pubsup/breastGEO/PAM50.zip And the centroids alone are here: https://genome.unc.edu/pubsup/breastGEO/pam50_centroids.txt
step1:拿到50个基因在所有样本的表达量矩阵
phe=t(read.table(trainFile,sep = '\t',row.names = 1)[1:2,])
head(phe)
x<-read.table(trainFile,skip = 2,sep = '\t',row.names = 1)
x[1:4,1:4]
colnames(x)=phe[,1]
dim(x)
# 因为是 '220arrays_nonUBCcommon+12normal_50g.txt', 所以是232个样本:
boxplot(x[,1:4])
standardize<-function(x){
annAll<-dimnames(x)
x<-scale(x)
dimnames(x)<-annAll
return(x)
}
x<-standardize(x)
x[1:4,1:4]
boxplot(x[,1:4])
# 表达矩阵被zscore后,数据量集中在0附近
step2:读取分类器
# load the published centroids for classifcation
pamout.centroids<-read.table(trainCentroids,sep='\t',header=T,row.names=1)
head(pamout.centroids)
# pam50的5个亚型的50个基因的
boxplot(pamout.centroids)
pheatmap::pheatmap(pamout.centroids)
rowSums(pamout.centroids)
step3: 把表达矩阵和分类器进行比较
options(stringsAsFactors = F)
library(ctc)
load(file = 'input_for_pam50.Rdata')
overlapSets<-function(x,y){
# subset the two lists to have a commonly ordered gene list
x<-x[dimnames(x)[[1]] %in% dimnames(y)[[1]],]
y<-y[dimnames(y)[[1]] %in% dimnames(x)[[1]],]
#and sort such that thing are in the correct order
x<-x[sort.list(row.names(x)),]
y<-y[sort.list(row.names(y)),]
return(list(x=x,y=y))
}
temp <- overlapSets(pamout.centroids,x)
# 如果表达矩阵和分类器共有基因少于50个,要注意一下。
centroids <- temp$x
tmp <- temp$y
library('impute')
dat=t(as.data.frame(impute.knn(as.matrix(t(temp$y)))$data))
# 200个样本的表达矩阵,去PAM50矩阵进行对比计算
d1=apply(centroids,2,function(i){
# dist 函数返回倒三角矩阵
dist(t(cbind(i,dat)))[1:ncol(dat)]
})
d2=cor(dat,centroids,method='pearson',use='pairwise.complete.obs')
d3=cor(dat,centroids,method='spearman',use='pairwise.complete.obs')
p1=apply(d1,1, function(x){
colnames(d1)[which.min(x)]
})
p2=apply(d2,1, function(x){
colnames(d2)[which.max(x)]
})
p3=apply(d3,1, function(x){
colnames(d3)[which.max(x)]
})
table(p1,p2)
table(p3,p1)
table(p3,p2)
save(prediction,distances,centroids,dat,file = 'output_for_pam50.Rdata')
step4:检查分离器效果
options(stringsAsFactors = F)
library(ctc)
load(file = 'input_for_pam50.Rdata')
load(file = 'output_for_pam50.Rdata')
table(p1)
phe=as.data.frame(cbind(phe,p1,p2,p3))
colnames(phe)=c('sample','type','dist','pearson','spearman')
phe=phe[phe$type!='',]
table(phe$type,phe$dist)
table(phe$type,phe$pearson)
table(phe$type,phe$spearman)
step5: 把PAM50应用到你自己的数据
options(stringsAsFactors = F)
library(ctc)
load(file = 'input_for_pam50.Rdata')
if(F){
# 这里面的数据集文件有点大, 所以我注释掉这一块代码
# [AgilentG4502A_07_3]
# (n=597) TCGA hub
# 下载 AgilentG4502A_07_3 后自己格式化成为breat_array_tcga.Rdata
load('breat_array_tcga.Rdata')
cg=rownames(pamout.centroids)
cg
cg=cg[cg %in% rownames(breat_array_tcga)]
cg
dat=breat_array_tcga[cg,]
centroids=pamout.centroids[cg,]
save(centroids,dat,file = 'input_for_pam50_tcga_array.Rdata')
}
load(file = 'input_for_pam50_tcga_array.Rdata')
d1=apply(centroids,2,function(i){
# dist 函数返回倒三角矩阵
dist(t(cbind(i,dat)))[1:ncol(dat)]
})
p1=apply(d1,1, function(x){
colnames(d1)[which.min(x)]
})
table(p1)
pid=gsub('[.]','-',substring(colnames(dat),1,12))
nt=substring(colnames(dat),14,15)
aphe=data.frame(pid,nt,p1)
aphe=aphe[aphe$nt=='01',]
load('subtype_anno.Rdata')
lastPhe=merge(aphe,IHC_clin,by.x='pid',by.y='id')
table(lastPhe$p1,lastPhe$IHC_sub)
colnames(pam50_clin)
lastPhe=merge(aphe,pam50_clin,by.x='pid',by.y='TCGA.Participant.Barcode')
table(lastPhe$p1,lastPhe$TCGA.Subtype)