GSVA的用途
一般我们做GSEA都是先进行差异基因分析,然后取差异倍数排序结果进行GSEA。但如果你没有条件进行差异基因分析也可以进行GSEA,这就是ssGSEA(single sample GSEA, 单样品GSEA)对每个样品进行GSEA,R包GSVA(Gene Set Variation Analysis)可以用来进行ssGSEA,GSVA可以将表达矩阵转换成通路富集分数(ES)矩阵
Cite:GSVA + limma进行差异通路分析
也就是说GSVA最终的结果得到的是一个GSVA矩阵,这个矩阵衡量的是pathway的"表达矩阵",GSVA所分析的是pathway(功能)上的表达情况
GSVA计算原理
可参考文献:《GSVA: gene set variation analysis for microarray and RNA-Seq data》
第一步:
对于RNA-seq的原始count数据我们需要利用泊松核函数计算Fr:
其中:
- xij 是第 j 个sample中第 i 个基因的原始count数
- n为总的sample数
- k与sample数有关系,k=1...n
- y=1...xij
- xik 为第 k 个sample中第 i 个基因的count值
- r = 0.5
对于芯片数据,首先得对芯片的表达矩阵取一个log2,然后利用高斯核函数计算Fhi:
其中:
- xij 是第 j 个sample中第 i 个基因的log2表达值
- n为总的sample数
- k与sample数有关系,k=1...n
- t 为形式变量
- xik 为第 k 个sample中第 i 个基因的log2表达值
- hi = si / 4,si 为第 i 个基因在所有sample中表达量的标准差;hi可以控制分辨率
第二步:
我们把计算出来的 Fr 和 Fhi 称为zij,那么每一个sample每一个基因都会有对应的 Fr 和 Fhi 的值,接下来对于每一个sample由zij的大小进行排序
即对于每一个sample,zij大的排前面,小的排后面,排完序后将zij改写为z(i)j,z(i)j定义为排过序的zij;并定义:rij = | p/2 - z(i)j |,其中 p 为表达矩阵中所有的基因数
第三步:
这一步是利用 Kolmogorov-Smirnov 计算富集分数,首先计算vjk
其中:
- τ 取 1 为权重参数
- rij 为第二步所定义,rij = | p/2 - z(i)j |
- p 为表达矩阵中所有的基因数
- ℓ 代表的是排序后从i = 1...ℓ 的基因
- γk 代表第 k 个gene set ,类似于GSEA,每个gene set 对应一个功能(pathway)
- I 其实是判别函数,当g(i)∈γk,值为1;当g(i)不属于γk,值为0
那么富集分数怎么计算呢?类似于GSEA:
对于某一个sample j,定义富集分数为vjk(ℓ)所构成的集合中(ℓ = 1...p)的最大值减去vjk(ℓ)所构成的集合中(ℓ = 1...p)的最小值,用它们的差值作为富集分数。
其数学表达式为:
(加 0 是为了做矫正)
GSVA的简单运用
这一块主要看官网,官方链接:GSVA官网
其主函数为:
gsva(expr, gset.idx.list, annotation,
method=c("gsva", "ssgsea", "zscore", "plage"),
kcdf=c("Gaussian", "Poisson", "none"),
abs.ranking=FALSE,
min.sz=1,
max.sz=Inf,
parallel.sz=0,
parallel.type="SOCK",
mx.diff=TRUE,
tau=switch(method, gsva=1, ssgsea=0.25, NA),
ssgsea.norm=TRUE,
verbose=TRUE)
参数说明:
expr:Gene expression data which can be given either as an ExpressionSet object or as a matrix of expression values where rows correspond to genes and columns correspond to samples.
gset.idx.list:Gene sets provided either as a list object or as a GeneSetCollection object.
annotation:In the case of calling gsva() with expression data in a matrix and gene sets as a GeneSetCollection object, the annotation argument can be used to supply the name of the Bioconductor package that contains annotations for the class of gene identifiers occurring in the row names of the expression data matrix. By default gsva() will try to match the identifiers in expr to the identifiers in gset.idx.list just as they are, unless the annotation argument is set.
method: Method to employ in the estimation of gene-set enrichment scores per sample. By default this is set to gsva (Hänzelmann et al, 2013) and other options are ssgsea (Barbie et al, 2009), zscore (Lee et al, 2008) or plage (Tomfohr et al, 2005). The latter two standardize first expression profiles into z-scores over the samples and, in the case of zscore, it combines them together as their sum divided by the square-root of the size of the gene set, while in the case of plage they are used to calculate the singular value decomposition (SVD) over the genes in the gene set and use the coefficients of the first right-singular vector as pathway activity profile.
kcdf:Character string denoting the kernel to use during the non-parametric estimation of the cumulative distribution function of expression levels across samples when method="gsva". By default, kcdf="Gaussian" which is suitable when input expression values are continuous, such as microarray fluorescent units in logarithmic scale, RNA-seq log-CPMs, log-RPKMs or log-TPMs. When input expression values are integer counts, such as those derived from RNA-seq experiments, then this argument should be set to kcdf="Poisson".
abs.ranking:Flag used only when mx.diff=TRUE. When abs.ranking=FALSE (default) a modified Kuiper statistic is used to calculate enrichment scores, taking the magnitude difference between the largest positive and negative random walk deviations. When abs.ranking=TRUE the original Kuiper statistic that sums the largest positive and negative random walk deviations, is used. In this latter case, gene sets with genes enriched on either extreme (high or low) will be regarded as 'highly' activated.
min.sz:Minimum size of the resulting gene sets.
max.sz: Maximum size of the resulting gene sets.
parallel.sz:Number of processors to use when doing the calculations in parallel. This requires to previously load either the parallel or the snow library. If parallel is loaded and this argument is left with its default value (parallel.sz=0) then it will use all available core processors unless we set this argument with a smaller number. If snow is loaded then we must set this argument to a positive integer number that specifies the number of processors to employ in the parallel calculation.
parallel.type: Type of cluster architecture when using snow.
mx.diff :Offers two approaches to calculate the enrichment statistic (ES) from the KS random walk statistic. mx.diff=FALSE: ES is calculated as the maximum distance of the random walk from 0. mx.diff=TRUE (default): ES is calculated as the magnitude difference between the largest positive and negative random walk deviations.
tau:Exponent defining the weight of the tail in the random walk performed by both the gsva (Hänzelmann et al., 2013) and the ssgsea (Barbie et al., 2009) methods. By default, this tau=1 when method="gsva" and tau=0.25 when method="ssgsea" just as specified by Barbie et al. (2009) where this parameter is called alpha.
ssgsea.norm:Logical, set to TRUE (default) with method="ssgsea" runs the SSGSEA method from Barbie et al. (2009) normalizing the scores by the absolute difference between the minimum and the maximum, as described in their paper. When ssgsea.norm=FALSE this last normalization step is skipped.
verbose:Gives information about each calculation step. Default: FALSE.
其中重点说一下参数gset.idx.list,这个其实就是功能注释文件gmt,这个可以去GSEA官网下载:msigdb
这个数据库的注释是基于人的,如果是其他物种需要做同源转换
一共有这么几类:
而kcdf则是你要进行转换的核函数