HyperGParams
class from the Category
package to perform enrichment
calculation quickly for multiple gene sets.
"makeValidParams"(object)
"drive"(p)
"drive"(p) <- dri
"ontology"(object)
"ontology"(object) <- go
"conditional"(r)
"conditional"(r) <- cond
"hyperGTest"(p)
ListHyperGParams
object.makeValidParmas
returns another ListHyperGParams
instance that has the same class as its arguments'.ontology
returns a character vector of length one.conditional
returns a logical vector of length one.drive
returns a logical vector of length one.
Category
package, the only difference is that they handle
ListHyperGParams
objects. makeValidParams
validates ListHyperGParams
object, in
particular, it removes duplicate genes, both from the gene universe
and the specified gene sets; and it also makes sure that all genes in
the gene sets are included in the universe. ontology
can be used to query or set the ontology for
enrichment calculated against the GO database. conditional
queries or sets whether conditional GO enrichment
will be performed. This feature is not implemented yet, see the
Category
and GOstats
packages for a working
implementation and more information. drive
queries or sets whether the intersections of the gene sets
and the universe are stored in the result object. This information can
be calculated later as well, but it is faster to store it at the same
time when the hypergeometric test is performed.ListHyperGParams
abstract class extends HyperGParams
and allows to specify a list of gene sets for the enrichment
calculation instead of a single set. ListHyperGParams
calculates the enrichment much faster than the
original HyperGParams
classes in the Category
package,
especially if the calculation is performed against the same gene
universe for many gene sets.
ListHyperGParams
is an abstract class, it is not possible to
instantiate objects from it. Instead, its various extensions must be
used: GOListHyperGParams
, KEGGListHyperGParams
,
CHRListHyperGParams
and miRNAListHyperGParams
.
The various ListHyperGParams
objects can be created with the
standard new
command, by giving all necessary arguments. Please
see the examples below.
ISAGO
, ISAKEGG
, ISACHR
,
ISAmiRNA
.
Perhaps see also the vignette in the GOstats
package.
# GO enrichment, "by hand"
# Load data first
data(ALLModulesSmall)
# Create gene sets
library(hgu95av2.db)
genes <- getFeatureNames(ALLModulesSmall)
entrez <- lapply(genes, function(x) na.omit(unlist(mget(x,
hgu95av2ENTREZID))))
# Create universe
universe <- na.omit(unlist(mget(featureNames(ALLModulesSmall),
hgu95av2ENTREZID)))
# Create parameter object
param <- new("GOListHyperGParams", geneIds=entrez, universeGeneIds=universe,
pvalueCutoff=0.01, drive=FALSE, ontology="BP",
conditional=FALSE, testDirection="over",
annotation=annotation(ALLModulesSmall))
# Do the calculation
GOBP <- hyperGTest(param)
# Inspect the result
GOBP
summary(GOBP)[[1]]
# How to create other parameter objects
paramKEGG <- new("KEGGListHyperGParams", geneIds=entrez,
universeGeneIds=universe, drive=FALSE,
annotation=annotation(ALLModulesSmall))
paramCHR <- new("CHRListHyperGParams", geneIds=entrez,
universeGeneIds=universe, drive=FALSE,
annotation=annotation(ALLModulesSmall))
# Enrichment with user-supplied categories, we use a list of
# hand-picked genes that are involved in myelin formation
mygenes <- c("YARS", "NFKB2", "NGFR", "CDH1", "NFAT5", "NDRG1", "GAP43",
"EGR2", "MSN", "ROCK1", "SREBF2", "SOX10", "FIG4", "EGR1", "PIK3R1",
"CDC42", "EDN3", "EDNRB", "NCAM1", "DHH", "OMG", "PMP22", "LAMA4",
"MPDZ", "MTMR2", "REL", "S100A1", "ITGA4", "GFAP", "FGF2", "RPSA",
"CADM1", "CDH19", "DNM2", "PAX3", "SREBF1", "DAG1", "DRP2", "SDC2",
"MBP", "RELA", "RELB", "JUN", "NAB1", "MOBP", "SKI", "COL5A2", "RHOA",
"NFASC", "NEFL", "MPZ", "MAG", "EDNRA", "ERBB4", "LITAF", "MMP2",
"PLP1", "CDKN1A", "PAK1", "RDX", "GJB1", "LAMA5", "JAM3", "ITGB1",
"PARD3", "FABP7", "LAMA2", "ERBB3", "CADM4", "FOXO4", "TSPAN31",
"GPR126", "PTK2", "RAC1", "CDKN2A", "CLDN5", "ID2", "LAMC1", "SOX2",
"CNTN2", "ERBB2", "NFKB1", "NAB2", "EDN2", "MMP9", "CCND1", "L1CAM",
"MOG")
library(org.Hs.eg.db)
myentrez <- na.omit(mapIds(org.Hs.eg.db, mygenes, 'ENTREZID',
keytype='SYMBOL'))
categories <- list(myelin=myentrez)
data(ALLModules)
genes2 <- getFeatureNames(ALLModules)
entrez2 <- lapply(genes2, function(x) na.omit(unlist(mget(x,
hgu95av2ENTREZID))))
# Create universe
universe2 <- na.omit(unlist(mget(featureNames(ALLModules),
hgu95av2ENTREZID)))
paramMY <- new("GeneralListHyperGParams", geneIds=entrez2,
universeGeneIds=universe2, drive=FALSE,
annotation=annotation(ALLModulesSmall),
categories=categories)
MY <- hyperGTest(paramMY)
MY
summary(MY)[[1]]
Run the code above in your browser using DataLab