cateGOry {Category} | R Documentation |
The function constructs a category membership matrix, such as used by
applyByCategory
,
from a list of gene identifiers and their annotated GO categories.
For each of the GO categories stated in categ
,
all less specific terms (ancestors) are also included, thus one need
only obtain the most specific set of GO term mappings, which
can be obtained from Bioconductor annotation packages or via biomaRt.
The ancestor relationships are obtained from the GO package.
cateGOry(x, categ, sparse=TRUE)
x |
Character vector with (arbitrary) gene identifiers. They will be used for the column names of the resulting matrix. |
categ |
A character vector of the same length as x
with GO annotations for the genes in x . If a
gene has multiple GO annotations, it is expected to occur multiple
times in x , once for each different annotation. |
sparse |
Logical. If TRUE , the return value will be a
sparse matrix of class lgCMatrix-class , if FALSE ,
an ordinary matrix . |
Requires the GO
package.
For some subsequent analyses, it is useful to remove categories that have only a small number of members. Use the normal matrix subsetting syntax for this, see example.
The adjacency matrix of the bipartite category membership graph, rows are categories and columns genes.
W. Huber
g = cateGOry(c("CG2671", "CG2671", "CG2950"), c("GO:0000074", "GO:0001738", "GO:0003676")) g rownames(g) colnames(g) rowSums(g) ## number of genes in each category ## Filter out categories with less than minMem members. ## This is toy data, in real applications, a number higher ## than 2 will be more appropriate. minMemb = 2 g[rowSums(g)>=minMemb,,drop=FALSE ]