setNamespace.Rd
Set the namespace field in each gene-set within a GmtList
setNamespace(x, namespace)
x | A |
---|---|
namespace | It can be either a function that applies to a Note that using vectors as |
myGmtList <- GmtList(list(list(name="GeneSet1", desc="Namespace1", genes=LETTERS[1:3]),
list(name="GeneSet2", desc="Namespace1", genes=rep(LETTERS[4:6],2)),
list(name="GeneSet1", desc="Namespace1", genes=LETTERS[4:6]),
list(name="GeneSet3", desc="Namespace2", genes=LETTERS[1:5])))
hasNamespace(myGmtList)
#> [1] FALSE
myGmtList2 <- setNamespace(myGmtList, namespace=function(x) x$desc)
gsNamespace(myGmtList2)
#> [1] "Namespace1" "Namespace1" "Namespace1" "Namespace2"
## the function can provide flexible ways to encode the gene-set namespace
myGmtList3 <- setNamespace(myGmtList, namespace=function(x) gsub("Namespace", "C", x$desc))
gsNamespace(myGmtList3)
#> [1] "C1" "C1" "C1" "C2"
## using vectors
myGmtList4 <- setNamespace(myGmtList, namespace=c("C1", "C1", "C1", "C2"))
gsNamespace(myGmtList4)
#> [1] "C1" "C1" "C1" "C2"
myGmtList2null <- setNamespace(myGmtList2, namespace=NULL)
hasNamespace(myGmtList2null)
#> [1] FALSE