1.ssGSEA简介
2.ssGSEA分析
rm(list=ls())setwd("E:\rxys\03") #设置工作目录#引用分析所用包。此处需要提前下载欧library(GSVA)library(limma)library(GSEABase)
#读取输入文件,并对输入文件处理symbol=read.table("symbol.txt",sep=" ",header=T,check.names=F)#读取输入文件,此处为TCGA-LUSC的FPKM标准化数据symbol=as.matrix(symbol)rownames(symbol)=symbol[,1]exp_data=symbol[,2:ncol(symbol)]dimnames=list(rownames(exp_data),colnames(exp_data))exp_data1=matrix(as.numeric(as.matrix(exp_data)),nrow=nrow(exp_data),dimnames=dimnames)exp_data1=avereps(exp_data1)exp_data1=exp_data1[rowMeans(exp_data1)>0,]geneSet=getGmt("immune cell.gmt", geneIdType=SymbolIdentifier())#读取我们所提供的免疫细胞基因文件ssGSEA_Score=gsva(exp_data1, geneSet, method='ssgsea', kcdf='Gaussian', abs.ranking=TRUE)#ssGSEA计算normalize=function(x){return((x-min(x))/(max(x)-min(x)))}#定义ssGSEA_Score矫正函数norm_ssGSEA_Score=normalize(ssGSEA_Score)#对ssGSEA_Score进行矫正norm_ssGSEA_Score=rbind(id=colnames(norm_ssGSEA_Score),norm_ssGSEA_Score)write.table(norm_ssGSEA_Score,file="norm_ssGSEA_Score.txt",sep=" ",quote=F,col.names=F)#此处的输出文件即为ssGSEA富集得分文件
3.可视化操作
screen=sapply(strsplit(colnames(norm_ssGSEA_Score),"\-"),"[",4)screen=sapply(strsplit(screen,""),"[",1)screen=gsub("2","1",screen)data=norm_ssGSEA_Score[,screen==0]#对肿瘤样品分组,TCGA的命名规则可以复习一波
h_cluster = hclust(dist(t(norm_ssGSEA_Score)))#计算样品距离并聚类cluster_result=cutree(h_cluster,3)#将聚类结果分成低,中,高免疫三组library(pheatmap)norm_ssGSEA_Score1=read.table("norm_ssGSEA_Score.txt",sep=" ",header=T,row.names=1,check.names=F)#读取结果文件V1<-names(cluster_result)V2<-as.integer(cluster_result)category<-data.frame(V1,V2)category$V1<-as.character(category$V1)category[,2]=paste0("Cluster",category[,2])category=category[order(category[,2]),]norm_ssGSEA_Score1=norm_ssGSEA_Score1[,as.vector(category[,1])]cluster=as.data.frame(category[,2])row.names(cluster)=category[,1]colnames(cluster)="Cluster"pdf("heatmap.pdf",height=5,width=9)color.key<-c("#3300CC","#3399FF","white","#FF3333","#CC0000")pheatmap(norm_ssGSEA_Score1, annotation=cluster, color =colorRampPalette(color.key)(50), cluster_cols =F, fontsize=8, fontsize_row=8, scale="row", show_colnames=T, fontsize_col=3, main = "Example heatmap")dev.off()
4.实际应用
结语
[1] GSVA: The Gene Set Variation Analysis package for microarray and RNA-seq data
[2] Xue Y, Tong L, LiuAnwei Liu F, et al. Tumor‑infiltrating M2 macrophages driven by specific genomic alterations are associated with prognosis in bladder cancer. Oncol Rep. 2019;42(2):581-594. doi:10.3892/or.2019.7196
[3] Jia Q, Wu W, Wang Y, et al. Local mutational diversity drives intratumoral immune heterogeneity in non-small cell lung cancer. Nat Commun. 2018;9(1):5361. Published 2018 Dec 18. doi:10.1038/s41467-018-07767-w
联系客服