Cancer Outlier Profile Analysis (COPA) is a common analysis to identify genes that might be down-regulated or up-regulated only in a proportion of samples with the codition of interest. OPPAR is the R implementation of modified COPA (mCOPA) method, originally published by Chenwei Wang et al. in 2012. The aim is to identify genes that are outliers in samples with condition of interest, compared to normal samples. The methods implemented in OPPAR enable the users to perform the analysis in various ways, namely detecting outlier features in control versus condition samples (whether or not there is a information on subtypes), and detecting genes that are outlier in one subtype compared to the other samples, if the subtypes are known.
OPPAR can also be used for Gene Set Enrichment Analysis (GSEA). Here,
a modified version of GSVA
method is implemented. GSVA can be used to determine which samples in
the study are enriched for gene expression signatures that are of
interest. The gsva function in GSVA package returns an
enrichment score for each sample, for the given signatures/gene sets.
With the current implementation of the method, samples that strongly
show enrichment for down(-regulated) gene expression signatures will
receive negative scores. However, Often it is in the interest of the
biologists and researchers to get positive scores for samples that are
enriched in both up and down signatures. Therefore, the
gsva function has been modified to assign positive scores
to samples that are enriched for the up-regulated and down-regulated
gene expression signatures.
OPPAR comes with four functions:
This vignette illustrates a possible workflow for OPPAR, using Tomlins et al. prostate cancer data. In addition, Maupin’s TGFb data have been analyzed for enrichement of a TGFb gene signature in the samples measured in this study.
Please note although the analysis presented here have been done on microarray studies, one can apply oppar tools to RPKM values of gene expression measurements in NGS studies.
Data was retrieved from GEO database, checked for normalization and
subsetted according to procedure outlined in the mCOPA paper. In
addition, probes with no annotation were removed. The
impute package was used to impute the missing values using
K-nearest neighbours method (k = 10). The subsetted dataset is available
in the package as a sample data, and contains an ExpressionSet object,
storing information on samples, genes and gene expressions. We apply
opa on Tomlins et al. data, then use
getSubtypeProbes to get all down- regulated and all
up-regulated outliers.
opa returns the outlier profile matrix, which is a
matrix of -1 ( for down-regulated outliers), 0 ( not an outlier) and 1
(up-regulated outlier). For more information see ?opa
For a brief overview of oppar package and functions,
please see ?oppar
## Loading required package: knitr
## Warning: multiple methods tables found for 'gsva'
## Warning in utils::data(Tomlins): data set 'Tomlins' not found
# the first 21 samples are Normal samples, and the rest of
# the samples are our cases (metastatic). We, thus, generate a group
# variable for the samples based on this knowledge.
g <- factor(c(rep(0,21),rep(1,ncol(exprs(eset)) - 21)))
g## [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [77] 1 1 1 1 1 1 1 1 1 1
## Levels: 0 1
# Apply opa on Tomlins data, to detect outliers relative to the
# lower 10% (lower.quantile = 0.1) and upper 5% (upper.quantile = 0.95 -- Default) of
# gene expressions.
tomlins.opa <- opa(eset, group = g, lower.quantile = 0.1)
tomlins.opa## Object of type OPPARList
## Features: 663
## Samples: 65
## Upper quantile: 0.95
## Lower quantile: 0.10
## Groups:
## [1] 1 1 1 1 1 1 1 1 1 1
## Levels: 0 1
The matrix containing the outlier profiles is called
profileMatrix and can be accessed using the $ operator. The
upper.quantile and lower.quantile parameters
used to run the function can also be retrieved using this operator.
## GSM141341 GSM141342 GSM141343 GSM141356 GSM141357
## Hs6-1-10-7 0 0 0 0 0
## Hs6-1-11-3 0 0 0 0 0
## Hs6-1-12-24 0 0 0 0 0
## Hs6-1-12-8 0 0 0 0 0
## Hs6-1-13-12 0 0 0 0 0
## Hs6-1-13-13 0 0 0 0 0
## [1] 0.95
## [1] 0.1
We can extract outlier profiles for any individual samples in the
profileMatrix, using getSampleOutlier. see
?getSampleOutlier for more detailed information
## $GSM141341.up
## [1] "Hs6-26-18-3"
##
## $GSM141341.down
## [1] "Hs6-17-9-11" "Hs6-2-11-4"
##
## $GSM141357.up
## [1] "Hs6-10-22-5" "Hs6-14-25-7" "Hs6-15-22-3" "Hs6-15-5-11" "Hs6-16-2-15"
## [6] "Hs6-16-9-2" "Hs6-18-9-13" "Hs6-20-13-20" "Hs6-20-7-7" "Hs6-22-21-5"
## [11] "Hs6-26-23-5" "Hs6-28-5-5"
##
## $GSM141357.down
## [1] "Hs6-13-3-14" "Hs6-22-5-9" "Hs6-24-7-23" "Hs6-25-12-19" "Hs6-25-2-9"
Extracting down-regulated and up-regulated outliers in all samples
using getSubtypeProbes:
We can then obtain a list of GO terms from org.Hs.eg.db.
Each element of the list will be a GO terms with the Entrez gene IDs
corresponding to that term. We can the apply mroast from
limma package for multiple gene set enrichment testing.
# gene set testing with limma::mroast
#BiocManager::install(org.Hs.eg.db)
library(org.Hs.eg.db)
library(limma)
org.Hs.egGO2EG## GO2EG map for chip org.Hs.eg (object of class "Go3AnnDbBimap")
## $`GO:0060396`
## IBA IBA IBA IBA IBA IBA IDA NAS IBA IBA IDA
## "1" "1438" "1442" "1443" "1444" "2688" "2688" "2688" "2689" "2690" "2690"
## IEA IMP NAS IMP IDA IDA IDA IDA IDA IDA
## "2690" "2690" "2690" "3479" "3717" "5295" "5747" "5829" "6774" "8835"
##
## $`GO:0001869`
## IDA IDA
## "2" "710"
##
## $`GO:0006805`
## TAS TAS IDA TAS TAS IEA TAS TAS
## "9" "10" "13" "13" "100" "196" "196" "218"
## TAS IDA IEA TAS TAS IDA TAS IEA
## "314" "316" "405" "405" "590" "670" "670" "790"
## IDA TAS IEA TAS IDA IDA TAS IDA
## "873" "874" "1244" "1244" "1543" "1544" "1544" "1545"
## NAS IBA IDA IMP IBA TAS IBA IBA
## "1545" "1548" "1548" "1548" "1549" "1551" "1553" "1555"
## IDA IMP TAS IDA IEA TAS IDA IEA
## "1555" "1555" "1555" "1557" "1557" "1557" "1558" "1558"
## TAS IDA IEA IMP TAS IEA TAS IBA
## "1558" "1559" "1559" "1559" "1559" "1562" "1562" "1564"
## IDA IBA IDA IMP TAS IBA IDA IMP
## "1564" "1565" "1565" "1565" "1565" "1571" "1571" "1571"
## TAS IBA TAS IBA TAS IDA TAS TAS
## "1571" "1572" "1572" "1573" "1573" "1576" "1576" "1577"
## IEA ISS IDA NAS TAS TAS TAS TAS
## "1580" "1580" "1592" "1645" "1645" "1728" "2030" "2052"
## IBA IDA IBA IDA IBA IBA IBA IBA
## "2327" "2327" "2329" "2330" "2938" "2939" "2940" "2941"
## IDA IDA IDA TAS IMP IEA TAS TAS
## "2941" "2950" "2987" "2987" "3172" "4363" "4363" "5243"
## IEA ISS ISS IDA TAS TAS IDA IDA
## "6095" "6095" "6097" "6283" "6579" "6580" "6799" "6817"
## IDA IDA IDA TAS IDA IDA TAS IDA
## "6818" "6822" "7172" "7172" "7363" "7364" "7364" "7366"
## TAS TAS IMP IMP ISS IEA TAS TAS
## "7366" "7367" "8529" "8647" "8647" "8714" "8714" "8824"
## IDA TAS IEA TAS TAS TAS TAS TAS
## "8856" "9153" "9915" "9915" "10057" "10249" "10257" "10599"
## IDA IDA IDA TAS IDA TAS TAS IDA
## "10720" "10741" "10858" "10864" "10941" "11309" "23491" "27233"
## IDA TAS IBA TAS IDA IEA TAS IDA
## "27284" "28234" "29785" "54498" "54575" "54575" "54575" "54576"
## IEA IC IDA IEA IDA IEA TAS IDA
## "54576" "54577" "54577" "54577" "54578" "54578" "54578" "54600"
## IEA TAS IC IDA TAS IDA TAS IBA
## "54600" "54600" "54658" "54658" "54658" "54659" "54659" "54905"
## IDA TAS IDA IDA IEA TAS TAS ISS
## "54905" "55315" "55347" "56603" "57491" "57491" "64078" "66002"
## IMP IDA ISS IBA TAS IDA IBA TAS
## "79001" "79799" "80777" "113612" "116285" "119391" "120227" "134147"
## IBA TAS NAS IDA IDA IDA IDA
## "221357" "348158" "407019" "442038" "445329" "494327" "574537"
##
## $`GO:0006954`
## NAS TAS IBA IDA TAS TAS
## "12" "23" "101" "101" "133" "134"
## TAS TAS IMP TAS IBA IBA
## "135" "140" "143" "177" "185" "186"
## IEA ISS NAS TAS IEA ISS
## "186" "199" "199" "246" "301" "301"
## TAS NAS NAS NAS IEA IC
## "301" "329" "330" "566" "623" "624"
## IEA ISS IEA IEA IEA TAS
## "650" "650" "654" "658" "718" "719"
## IEA IEA IEA TAS IEA NAS
## "720" "721" "727" "727" "834" "840"
## IDA TAS IDA IBA TAS TAS
## "948" "958" "959" "960" "976" "1051"
## IEP IEA TAS IBA IEA TAS
## "1116" "1147" "1147" "1230" "1230" "1230"
## IBA IEA TAS IEA TAS IBA
## "1232" "1232" "1232" "1233" "1233" "1234"
## IEA TAS IEA NAS TAS TAS
## "1234" "1234" "1236" "1236" "1241" "1401"
## TAS IMP IEA ISS TAS IEA
## "1436" "1535" "1536" "1536" "1536" "1800"
## ISS TAS IBA IEP ISS IEA
## "1828" "1903" "1990" "1999" "2149" "2200"
## TAS NAS TAS TAS IEA ISS
## "2213" "2350" "2353" "2358" "2475" "2529"
## IBA IEA IEA ISS IBA TAS
## "2532" "2532" "2625" "2625" "2687" "2829"
## IEA TAS TAS IDA IDA IDA
## "2833" "2919" "2920" "3039" "3040" "3043"
## IDA IEA IDA IDA ISS TAS
## "3075" "3075" "3146" "3240" "3269" "3339"
## IDA TAS IEA TAS IBA IEA
## "3373" "3440" "3551" "3551" "3552" "3552"
## IBA IDA IEA NAS TAS NAS
## "3553" "3553" "3553" "3553" "3553" "3556"
## TAS IBA IEA TAS IBA IDA
## "3556" "3557" "3557" "3567" "3569" "3569"
## NAS TAS NAS NAS IBA TAS
## "3569" "3569" "3570" "3572" "3576" "3576"
## TAS TAS NAS TAS IBA TAS
## "3578" "3579" "3588" "3588" "3596" "3596"
## IEA NAS IBA IEA IBA TAS
## "3605" "3605" "3606" "3606" "3627" "3627"
## TAS NAS NAS IEA ISS IEA
## "3656" "3683" "3689" "3815" "3815" "3868"
## ISS IDA TAS IDA TAS IEA
## "3868" "3965" "4065" "4067" "4069" "4086"
## IDA IBA TAS TAS TAS TAS
## "4210" "4283" "4283" "4775" "4776" "4790"
## TAS IDA IBA TAS IBA IBA
## "4799" "4814" "4843" "5004" "5196" "5197"
## TAS TAS IBA TAS IBA TAS
## "5293" "5294" "5473" "5724" "5733" "5806"
## TAS IEA IDA TAS TAS TAS
## "5879" "5919" "5970" "6279" "6280" "6283"
## IBA IBA IBA IDA IBA TAS
## "6346" "6347" "6348" "6348" "6349" "6349"
## IBA TAS IBA IBA IBA IBA
## "6351" "6351" "6352" "6354" "6355" "6356"
## TAS IBA TAS IBA IBA IBA
## "6356" "6357" "6357" "6358" "6359" "6360"
## IBA IBA NAS TAS IBA NAS
## "6362" "6363" "6363" "6364" "6366" "6366"
## TAS IBA TAS IBA TAS IBA
## "6366" "6367" "6367" "6368" "6368" "6369"
## TAS IBA IBA TAS IBA IBA
## "6369" "6370" "6372" "6373" "6374" "6375"
## IBA TAS ISS NAS ISS IBA
## "6376" "6401" "6556" "6614" "6774" "6846"
## IBA TAS IDA IBA IDA IEA
## "6863" "6869" "6885" "6915" "7057" "7057"
## IBA IDA IEA IDA NAS TAS
## "7099" "7099" "7099" "7124" "7124" "7130"
## IBA IEA ISS NAS IEA NAS
## "7132" "7132" "7132" "7132" "7133" "7133"
## NAS NAS IBA IBA IEA IDA
## "7186" "7188" "7292" "7293" "7293" "7412"
## IMP TAS TAS TAS IDA IDA
## "7474" "7852" "7857" "8111" "8288" "8372"
## IEA TAS NAS TAS NAS NAS
## "8452" "8517" "8605" "8639" "8717" "8737"
## TAS TAS IEA ISS IBA ISS
## "8767" "8807" "8876" "8876" "9034" "9034"
## IDA IEA ISS NAS IBA IEA
## "9097" "9173" "9173" "9173" "9258" "9258"
## IMP IBA IEA ISS IBA TAS
## "9258" "9261" "9261" "9261" "9373" "9435"
## TAS TAS IDA IMP TAS IDA
## "9734" "9759" "9830" "9867" "10014" "10135"
## TAS IBA TAS IBA IMP IBA
## "10219" "10344" "10392" "10551" "10551" "10563"
## TAS IEA IDA IEA IBA IDA
## "10628" "10663" "10758" "10758" "10850" "10855"
## IEA ISS ISS IEA IBA TAS
## "10949" "10949" "11019" "11280" "11334" "11343"
## IBA IEA IBA IDA TAS IEA
## "22861" "22861" "22900" "23118" "25824" "26258"
## TAS IBA IEA TAS IBA IBA
## "26279" "26525" "26525" "27035" "27040" "27177"
## IEA IBA IEA IBA IEA IEA
## "27177" "27178" "27178" "27179" "27179" "27189"
## TAS IEA IEA IBA IEA TAS
## "27189" "27190" "27347" "29108" "29108" "29110"
## TAS TAS TAS NAS TAS IMP
## "29760" "30814" "50507" "50616" "50848" "51776"
## IDA IEA NAS IMP IDA IEA
## "53342" "53342" "53832" "54899" "54959" "55331"
## IDA NAS IBA IEA IBA TAS
## "55693" "55801" "56300" "56300" "56477" "57413"
## ISS NAS IEA NAS NAS IEA
## "58484" "59082" "59340" "60675" "64386" "65266"
## NAS TAS NAS IBA IDA IBA
## "80274" "80833" "83737" "84632" "84632" "84639"
## IEA IBA IEA ISS IEA IMP
## "84639" "84651" "84695" "84695" "90139" "90139"
## NAS IEA IDA IMP NAS IBA
## "90865" "112744" "114548" "114548" "150372" "255061"
## NAS IBA IBA IEA ISS IBA
## "259197" "353345" "375387" "375387" "375387" "388372"
## IMP IGI IDA IDA IMP IBA
## "406920" "406925" "406982" "407006" "407008" "414062"
## TAS IBA IEA TAS NAS
## "414062" "729230" "729230" "729230" "100137049"
##
## $`GO:0019216`
## NAS ISS TAS ISS IEA IEA ISS IDA
## "12" "585" "2168" "2264" "2475" "2874" "2874" "3172"
## ISS IMP IMP IBA TAS IEA NAS TAS
## "3398" "5336" "5563" "5660" "6256" "6342" "8611" "8660"
## TAS IEA IMP IEA ISS IEA ISS ISS
## "8721" "8877" "9555" "9572" "9572" "9975" "9975" "10347"
## IEA ISS IEA ISS IEA ISS IEA ISS
## "10499" "10499" "29956" "29956" "51094" "51094" "51548" "51548"
## IBA IDA IMP IBA IDA IEA IEA IDA
## "53345" "53345" "54209" "55908" "55908" "55908" "56848" "57674"
## ISS IDA IEA IBA IDA IEA ISS IEA
## "80183" "85441" "85441" "114294" "114294" "114898" "114898" "139735"
## ISS IEA ISS IBA
## "139735" "339559" "339559" "768239"
##
## $`GO:0030277`
## NAS IEA ISS IMP ISS IBA IMP NAS
## "12" "3360" "3360" "4583" "4583" "4585" "4585" "4588"
## IDA IBA IEA IBA IBA IMP IEA ISS
## "5950" "7031" "7031" "7032" "7033" "11171" "54106" "54106"
## IMP IBA ISS IMP IMP IBA IEA
## "56667" "57482" "57482" "64081" "64127" "340547" "340547"
# Gene Set analysis using rost from limma
# need to subset gene express data based on up outliers
up.mtrx <- exprs(eset)[fData(eset)$ID %in% outlier.list[["up"]], ]
# get Entrez gene IDs for genes in up.mtrx
entrez.ids.up.mtrx <- fData(eset)$Gene.ID[fData(eset)$ID %in% rownames(up.mtrx)]
# find the index of genes in GO gene set in the gene expression matrix
gset.idx <- lapply(go2eg, function(x){
match(x, entrez.ids.up.mtrx)
})
# remove missing values
gset.idx <- lapply(gset.idx, function(x){
x[!is.na(x)]
})
# removing gene sets with less than 10 elements
gset.ls <- unlist(lapply(gset.idx, length))
gset.idx <- gset.idx[which(gset.ls > 10)]
# need to define a model.matrix for mroast
design <- model.matrix(~ g)
up.mroast <- mroast(up.mtrx, index = gset.idx, design = design)
head(up.mroast, n=5)## NGenes PropDown PropUp Direction PValue FDR PValue.Mixed FDR.Mixed
## GO:0005576 50 0 1 Up 5e-04 5e-04 5e-04 5e-04
## GO:0005813 20 0 1 Up 5e-04 5e-04 5e-04 5e-04
## GO:0061630 20 0 1 Up 5e-04 5e-04 5e-04 5e-04
## GO:0005635 16 0 1 Up 5e-04 5e-04 5e-04 5e-04
## GO:0005694 16 0 1 Up 5e-04 5e-04 5e-04 5e-04
The GO terms for the first 10 GO Ids detected by mroast
can be retrieved in the following way.
## [1] "DEFINITION" "GOID" "ONTOLOGY" "TERM"
## [1] "DEFINITION" "GOID" "ONTOLOGY" "TERM"
## GOID TERM
## 1 GO:0005576 extracellular region
## 2 GO:0005813 centrosome
## 3 GO:0061630 ubiquitin protein ligase activity
## 4 GO:0005635 nuclear envelope
## 5 GO:0005694 chromosome
## 6 GO:0004674 protein serine/threonine kinase activity
## 7 GO:0007186 G protein-coupled receptor signaling pathway
## 8 GO:0005783 endoplasmic reticulum
## 9 GO:0008017 microtubule binding
## 10 GO:0005814 centriole
We repeating the above steps for down-regulated outliers, to see what GO terms they are enriched for.
## GO2EG map for chip org.Hs.eg (object of class "Go3AnnDbBimap")
## $`GO:0060396`
## IBA IBA IBA IBA IBA IBA IDA NAS IBA IBA IDA
## "1" "1438" "1442" "1443" "1444" "2688" "2688" "2688" "2689" "2690" "2690"
## IEA IMP NAS IMP IDA IDA IDA IDA IDA IDA
## "2690" "2690" "2690" "3479" "3717" "5295" "5747" "5829" "6774" "8835"
##
## $`GO:0001869`
## IDA IDA
## "2" "710"
##
## $`GO:0006805`
## TAS TAS IDA TAS TAS IEA TAS TAS
## "9" "10" "13" "13" "100" "196" "196" "218"
## TAS IDA IEA TAS TAS IDA TAS IEA
## "314" "316" "405" "405" "590" "670" "670" "790"
## IDA TAS IEA TAS IDA IDA TAS IDA
## "873" "874" "1244" "1244" "1543" "1544" "1544" "1545"
## NAS IBA IDA IMP IBA TAS IBA IBA
## "1545" "1548" "1548" "1548" "1549" "1551" "1553" "1555"
## IDA IMP TAS IDA IEA TAS IDA IEA
## "1555" "1555" "1555" "1557" "1557" "1557" "1558" "1558"
## TAS IDA IEA IMP TAS IEA TAS IBA
## "1558" "1559" "1559" "1559" "1559" "1562" "1562" "1564"
## IDA IBA IDA IMP TAS IBA IDA IMP
## "1564" "1565" "1565" "1565" "1565" "1571" "1571" "1571"
## TAS IBA TAS IBA TAS IDA TAS TAS
## "1571" "1572" "1572" "1573" "1573" "1576" "1576" "1577"
## IEA ISS IDA NAS TAS TAS TAS TAS
## "1580" "1580" "1592" "1645" "1645" "1728" "2030" "2052"
## IBA IDA IBA IDA IBA IBA IBA IBA
## "2327" "2327" "2329" "2330" "2938" "2939" "2940" "2941"
## IDA IDA IDA TAS IMP IEA TAS TAS
## "2941" "2950" "2987" "2987" "3172" "4363" "4363" "5243"
## IEA ISS ISS IDA TAS TAS IDA IDA
## "6095" "6095" "6097" "6283" "6579" "6580" "6799" "6817"
## IDA IDA IDA TAS IDA IDA TAS IDA
## "6818" "6822" "7172" "7172" "7363" "7364" "7364" "7366"
## TAS TAS IMP IMP ISS IEA TAS TAS
## "7366" "7367" "8529" "8647" "8647" "8714" "8714" "8824"
## IDA TAS IEA TAS TAS TAS TAS TAS
## "8856" "9153" "9915" "9915" "10057" "10249" "10257" "10599"
## IDA IDA IDA TAS IDA TAS TAS IDA
## "10720" "10741" "10858" "10864" "10941" "11309" "23491" "27233"
## IDA TAS IBA TAS IDA IEA TAS IDA
## "27284" "28234" "29785" "54498" "54575" "54575" "54575" "54576"
## IEA IC IDA IEA IDA IEA TAS IDA
## "54576" "54577" "54577" "54577" "54578" "54578" "54578" "54600"
## IEA TAS IC IDA TAS IDA TAS IBA
## "54600" "54600" "54658" "54658" "54658" "54659" "54659" "54905"
## IDA TAS IDA IDA IEA TAS TAS ISS
## "54905" "55315" "55347" "56603" "57491" "57491" "64078" "66002"
## IMP IDA ISS IBA TAS IDA IBA TAS
## "79001" "79799" "80777" "113612" "116285" "119391" "120227" "134147"
## IBA TAS NAS IDA IDA IDA IDA
## "221357" "348158" "407019" "442038" "445329" "494327" "574537"
##
## $`GO:0006954`
## NAS TAS IBA IDA TAS TAS
## "12" "23" "101" "101" "133" "134"
## TAS TAS IMP TAS IBA IBA
## "135" "140" "143" "177" "185" "186"
## IEA ISS NAS TAS IEA ISS
## "186" "199" "199" "246" "301" "301"
## TAS NAS NAS NAS IEA IC
## "301" "329" "330" "566" "623" "624"
## IEA ISS IEA IEA IEA TAS
## "650" "650" "654" "658" "718" "719"
## IEA IEA IEA TAS IEA NAS
## "720" "721" "727" "727" "834" "840"
## IDA TAS IDA IBA TAS TAS
## "948" "958" "959" "960" "976" "1051"
## IEP IEA TAS IBA IEA TAS
## "1116" "1147" "1147" "1230" "1230" "1230"
## IBA IEA TAS IEA TAS IBA
## "1232" "1232" "1232" "1233" "1233" "1234"
## IEA TAS IEA NAS TAS TAS
## "1234" "1234" "1236" "1236" "1241" "1401"
## TAS IMP IEA ISS TAS IEA
## "1436" "1535" "1536" "1536" "1536" "1800"
## ISS TAS IBA IEP ISS IEA
## "1828" "1903" "1990" "1999" "2149" "2200"
## TAS NAS TAS TAS IEA ISS
## "2213" "2350" "2353" "2358" "2475" "2529"
## IBA IEA IEA ISS IBA TAS
## "2532" "2532" "2625" "2625" "2687" "2829"
## IEA TAS TAS IDA IDA IDA
## "2833" "2919" "2920" "3039" "3040" "3043"
## IDA IEA IDA IDA ISS TAS
## "3075" "3075" "3146" "3240" "3269" "3339"
## IDA TAS IEA TAS IBA IEA
## "3373" "3440" "3551" "3551" "3552" "3552"
## IBA IDA IEA NAS TAS NAS
## "3553" "3553" "3553" "3553" "3553" "3556"
## TAS IBA IEA TAS IBA IDA
## "3556" "3557" "3557" "3567" "3569" "3569"
## NAS TAS NAS NAS IBA TAS
## "3569" "3569" "3570" "3572" "3576" "3576"
## TAS TAS NAS TAS IBA TAS
## "3578" "3579" "3588" "3588" "3596" "3596"
## IEA NAS IBA IEA IBA TAS
## "3605" "3605" "3606" "3606" "3627" "3627"
## TAS NAS NAS IEA ISS IEA
## "3656" "3683" "3689" "3815" "3815" "3868"
## ISS IDA TAS IDA TAS IEA
## "3868" "3965" "4065" "4067" "4069" "4086"
## IDA IBA TAS TAS TAS TAS
## "4210" "4283" "4283" "4775" "4776" "4790"
## TAS IDA IBA TAS IBA IBA
## "4799" "4814" "4843" "5004" "5196" "5197"
## TAS TAS IBA TAS IBA TAS
## "5293" "5294" "5473" "5724" "5733" "5806"
## TAS IEA IDA TAS TAS TAS
## "5879" "5919" "5970" "6279" "6280" "6283"
## IBA IBA IBA IDA IBA TAS
## "6346" "6347" "6348" "6348" "6349" "6349"
## IBA TAS IBA IBA IBA IBA
## "6351" "6351" "6352" "6354" "6355" "6356"
## TAS IBA TAS IBA IBA IBA
## "6356" "6357" "6357" "6358" "6359" "6360"
## IBA IBA NAS TAS IBA NAS
## "6362" "6363" "6363" "6364" "6366" "6366"
## TAS IBA TAS IBA TAS IBA
## "6366" "6367" "6367" "6368" "6368" "6369"
## TAS IBA IBA TAS IBA IBA
## "6369" "6370" "6372" "6373" "6374" "6375"
## IBA TAS ISS NAS ISS IBA
## "6376" "6401" "6556" "6614" "6774" "6846"
## IBA TAS IDA IBA IDA IEA
## "6863" "6869" "6885" "6915" "7057" "7057"
## IBA IDA IEA IDA NAS TAS
## "7099" "7099" "7099" "7124" "7124" "7130"
## IBA IEA ISS NAS IEA NAS
## "7132" "7132" "7132" "7132" "7133" "7133"
## NAS NAS IBA IBA IEA IDA
## "7186" "7188" "7292" "7293" "7293" "7412"
## IMP TAS TAS TAS IDA IDA
## "7474" "7852" "7857" "8111" "8288" "8372"
## IEA TAS NAS TAS NAS NAS
## "8452" "8517" "8605" "8639" "8717" "8737"
## TAS TAS IEA ISS IBA ISS
## "8767" "8807" "8876" "8876" "9034" "9034"
## IDA IEA ISS NAS IBA IEA
## "9097" "9173" "9173" "9173" "9258" "9258"
## IMP IBA IEA ISS IBA TAS
## "9258" "9261" "9261" "9261" "9373" "9435"
## TAS TAS IDA IMP TAS IDA
## "9734" "9759" "9830" "9867" "10014" "10135"
## TAS IBA TAS IBA IMP IBA
## "10219" "10344" "10392" "10551" "10551" "10563"
## TAS IEA IDA IEA IBA IDA
## "10628" "10663" "10758" "10758" "10850" "10855"
## IEA ISS ISS IEA IBA TAS
## "10949" "10949" "11019" "11280" "11334" "11343"
## IBA IEA IBA IDA TAS IEA
## "22861" "22861" "22900" "23118" "25824" "26258"
## TAS IBA IEA TAS IBA IBA
## "26279" "26525" "26525" "27035" "27040" "27177"
## IEA IBA IEA IBA IEA IEA
## "27177" "27178" "27178" "27179" "27179" "27189"
## TAS IEA IEA IBA IEA TAS
## "27189" "27190" "27347" "29108" "29108" "29110"
## TAS TAS TAS NAS TAS IMP
## "29760" "30814" "50507" "50616" "50848" "51776"
## IDA IEA NAS IMP IDA IEA
## "53342" "53342" "53832" "54899" "54959" "55331"
## IDA NAS IBA IEA IBA TAS
## "55693" "55801" "56300" "56300" "56477" "57413"
## ISS NAS IEA NAS NAS IEA
## "58484" "59082" "59340" "60675" "64386" "65266"
## NAS TAS NAS IBA IDA IBA
## "80274" "80833" "83737" "84632" "84632" "84639"
## IEA IBA IEA ISS IEA IMP
## "84639" "84651" "84695" "84695" "90139" "90139"
## NAS IEA IDA IMP NAS IBA
## "90865" "112744" "114548" "114548" "150372" "255061"
## NAS IBA IBA IEA ISS IBA
## "259197" "353345" "375387" "375387" "375387" "388372"
## IMP IGI IDA IDA IMP IBA
## "406920" "406925" "406982" "407006" "407008" "414062"
## TAS IBA IEA TAS NAS
## "414062" "729230" "729230" "729230" "100137049"
##
## $`GO:0019216`
## NAS ISS TAS ISS IEA IEA ISS IDA
## "12" "585" "2168" "2264" "2475" "2874" "2874" "3172"
## ISS IMP IMP IBA TAS IEA NAS TAS
## "3398" "5336" "5563" "5660" "6256" "6342" "8611" "8660"
## TAS IEA IMP IEA ISS IEA ISS ISS
## "8721" "8877" "9555" "9572" "9572" "9975" "9975" "10347"
## IEA ISS IEA ISS IEA ISS IEA ISS
## "10499" "10499" "29956" "29956" "51094" "51094" "51548" "51548"
## IBA IDA IMP IBA IDA IEA IEA IDA
## "53345" "53345" "54209" "55908" "55908" "55908" "56848" "57674"
## ISS IDA IEA IBA IDA IEA ISS IEA
## "80183" "85441" "85441" "114294" "114294" "114898" "114898" "139735"
## ISS IEA ISS IBA
## "139735" "339559" "339559" "768239"
##
## $`GO:0030277`
## NAS IEA ISS IMP ISS IBA IMP NAS
## "12" "3360" "3360" "4583" "4583" "4585" "4585" "4588"
## IDA IBA IEA IBA IBA IMP IEA ISS
## "5950" "7031" "7031" "7032" "7033" "11171" "54106" "54106"
## IMP IBA ISS IMP IMP IBA IEA
## "56667" "57482" "57482" "64081" "64127" "340547" "340547"
# subsetting gene expression matrix based on down outliers
down_mtrx <- exprs(eset)[fData(eset)$ID %in% outlier.list[["down"]], ]
entrez_ids_down_mtrx <- fData(eset)$Gene.ID[fData(eset)$ID %in% rownames(down_mtrx)]
gset_idx_down <- lapply(go2eg, function(x){
match(x, entrez_ids_down_mtrx)
})
# remove missing values
gset_idx_down <- lapply(gset_idx_down, function(x){
x[!is.na(x)]
})
# removing gene sets with less than 10 elements
gset_ls_down <- unlist(lapply(gset_idx_down, length))
gset_idx_down <- gset_idx_down[which(gset_ls_down > 10)]
# apply mroast
down_mroast <- mroast(down_mtrx, gset_idx_down, design)
head(down_mroast, n=5)## NGenes PropDown PropUp Direction PValue FDR PValue.Mixed FDR.Mixed
## GO:0005739 28 1 0 Down 5e-04 5e-04 5e-04 5e-04
## GO:0005794 24 1 0 Down 5e-04 5e-04 5e-04 5e-04
## GO:0042802 24 1 0 Down 5e-04 5e-04 5e-04 5e-04
## GO:0000139 18 1 0 Down 5e-04 5e-04 5e-04 5e-04
## GO:0005813 17 1 0 Down 5e-04 5e-04 5e-04 5e-04
And extract GO terms for the top 10 results:
go_terms_down <- rownames(down_mroast[1:10,])
dr2tab <- select(GO.db, keys=go_terms_down,
columns=c("GOID","TERM"),
keytype="GOID")
dr2tab## GOID TERM
## 1 GO:0005739 mitochondrion
## 2 GO:0005794 Golgi apparatus
## 3 GO:0042802 identical protein binding
## 4 GO:0000139 Golgi membrane
## 5 GO:0005813 centrosome
## 6 GO:0007165 signal transduction
## 7 GO:0048471 perinuclear region of cytoplasm
## 8 GO:0008270 zinc ion binding
## 9 GO:0031012 extracellular matrix
## 10 GO:0016607 nuclear speck
We are now going to perform enrichment analysis for on Maupin’s TGFb
data (see ?maupin), given a gene signature. The
maupin data object contains a matrix containing gene
expression measurements on 3 control samples and 3 TGFb induced samples.
We run the modified gsva function introduced in this package to get one
large positive scores for samples enriched in the given gene signature,
both for down gene signature and up gene signature. This is while the
original gsva function returns negative scores for samples that are
enriched in down gene signature, and positive scores for samples
enriched in up gene signature. Therefore, the scores returned by the
gsva function in this package are the sum of the scores for up gene
signature and down gene signature. Note that in order for the modified
version of the gsva function to work properly, the
gset.idx.list has to be a named list, with the up signature
gene list being named ‘up’ and down gene signature gene list being names
‘down’ (see example code below). Also note that the
is.gset.list.up.down argument has to be set to TRUE if the
user wishes to use the modified version (i.e to get the sum of es scores
for up and down gene signatures). See ?gsva for more
details.
## [1] "data" "sig"
## M_Ctrl_R1 M_Ctrl_R2 M_Ctrl_R3 M_TGFb_R1 M_TGFb_R2 M_TGFb_R3
## 2 4.551955 4.391799 4.306602 4.738577 4.579810 4.576038
## 9 7.312850 7.155411 7.274249 7.520725 7.381180 7.279445
## 10 4.699286 4.625667 4.624420 4.613213 4.779147 4.845243
## 12 5.552299 5.806786 5.891174 6.976169 7.169206 7.200424
## 13 5.524958 5.341497 5.422172 5.569487 5.597191 5.585326
## 14 9.025984 9.075223 8.951924 9.062231 9.130251 9.204617
## EntrezID Symbol upDown_integrative_signature upDown_comparative_signature
## 1 19 ABCA1 0 up
## 2 87 ACTN1 0 up
## 3 136 ADORA2B 0 down
## 4 182 JAG1 up up
## 5 220 ALDH1A3 down 0
## 6 224 ALDH3A2 0 down
## upDown
## 1 up
## 2 up
## 3 down
## 4 up
## 5 down
## 6 down
geneSet<- maupin$sig$EntrezID #Symbol ##EntrezID # both up and down genes:
up_sig<- maupin$sig[maupin$sig$upDown == "up",]
d_sig<- maupin$sig[maupin$sig$upDown == "down",]
u_geneSet<- up_sig$EntrezID #Symbol # up_sig$Symbol ## EntrezID
d_geneSet<- d_sig$EntrezID
enrichment_scores <- gsva(maupin$data, list(up = u_geneSet, down= d_geneSet), mx.diff=1,
verbose=TRUE, abs.ranking=FALSE, is.gset.list.up.down=TRUE, parallel.sz = 1 )$es.obs## Estimating GSVA scores for 2 gene sets.
## Computing observed enrichment scores
## Estimating ECDFs in microarray data with Gaussian kernels
## Using parallel with 1 cores
## | | | 0% | |=================================== | 50% | |======================================================================| 100%
## M_Ctrl_R1 M_Ctrl_R2 M_Ctrl_R3 M_TGFb_R1 M_TGFb_R2 M_TGFb_R3
## GeneSet -0.8991905 -0.7841492 -0.8329552 0.9041564 0.7714735 0.8147947
## calculating enrichment scores using ssgsea method
# es.dif.ssg <- gsva(maupin, list(up = u_geneSet, down= d_geneSet),
# verbose=TRUE, abs.ranking=FALSE, is.gset.list.up.down=TRUE,
# method = "ssgsea")A histogram of enrichment scores is plotted below and the density of es scores for TGFb samples is shown in red. The distribution of es scores of control samples is shown in blue. As it can be seen from the plot below, TGFb induced samples that are expected to be enriched in the given TGFb signature have received positive scores and are on the right side of the histogram, whereas the control samples are on the left side of the histogram. In addition, TGFb induced samples and contorl samples have been nicely separated from each other.
hist(enrichment_scores, main = "enrichment scores", xlab="es")
lines(density(enrichment_scores[,1:3]), col = "blue") # control samples
lines(density(enrichment_scores[,4:6]), col = "red") # TGFb samples
legend("topleft", c("Control","TGFb"), lty = 1, col=c("blue","red"), cex = 0.6)