[BioC] how can I apply a function to each element of a GeneSetCollection (GSEABase)

Martin Morgan mtmorgan at fhcrc.org
Wed Jan 7 22:50:58 CET 2009


Hi burak --

burak kutlu <burak_kutlu at yahoo.com> writes:

> Hello

> I am trying to apply a function to each element of a
> GeneSetCollection object. I have a problem preserving the data
> class, if I use lapply(). Is using a for loop my only option?

I think what you want to do is put the result (a list of gene sets)
back into a gene set collection

> example(GeneSetCollection)
[snip]
> gsc
GeneSetCollection
  names: GO:0000187, GO:0000398, ..., GO:0046872 (156 total)
  unique identifiers: 31445_at, 31463_s_at, ..., 31441_at (40 total)
  types in collection:
    geneIdType: AnnotationIdentifier (1 total)
    collectionType: GOCollection (1 total)
> GeneSetCollection(lapply(gsc, function(f) { geneIds(f) <- "burak"; f }))
GeneSetCollection
  names: GO:0000187, GO:0000398, ..., GO:0046872 (156 total)
  unique identifiers: burak (1 total)
  types in collection:
    geneIdType: AnnotationIdentifier (1 total)
    collectionType: GOCollection (1 total)

In some special cases GeneSetCollection 'knows' how to do some things,
see the results of

> showMethods(class="GeneSetCollection", where=getNamespace("GSEABase"))

and

> ?"GeneSetCollection-class"

for instance,

> mapIdentifiers(gsc, EntrezIdentifier())
GeneSetCollection
  names: GO:0000187, GO:0000398, ..., GO:0046872 (156 total)
  unique identifiers: 6464, 3178, ..., 643332 (35 total)
  types in collection:
    geneIdType: EntrezIdentifier (1 total)
    collectionType: GOCollection (1 total)

Martin

> Thanks for any help
> -burak
>
> Here's what I do:
>
>> gsc
> GeneSetCollection
>   names: chr16q, chr5q23, ..., INOSITOL_OR_PHOSPHATIDYLINOSITOL_KINASE_ACTIVITY (5452 total)
>   unique identifiers: CMAR, USP10, ..., UCHL5IP (39655 total)
>   types in collection:
>     geneIdType: SymbolIdentifier (1 total)
>     collectionType: BroadCollection (1 total)
>
>> test1 = GeneSetCollection(gsc[[1]],gsc[[2]])
>> test1
> GeneSetCollection
>   names: chr16q, chr5q23 (2 total)
>   unique identifiers: CMAR, USP10, ..., LOC728586 (91 total)
>   types in collection:
>     geneIdType: SymbolIdentifier (1 total)
>     collectionType: BroadCollection (1 total)
>
>> lapply(test1,function(f) {geneIds(f) = "burak";return(f)})
> [[1]]
> setName: chr16q
> geneIds: burak (total: 1)
> geneIdType: Symbol
> collectionType: Broad
>   bcCategory: c1 (Positional)
>   bcSubCategory:  NA
> details: use 'details(object)'
>
> [[2]]
> setName: chr5q23
> geneIds: burak (total: 1)
> geneIdType: Symbol
> collectionType: Broad
>   bcCategory: c1 (Positional)
>   bcSubCategory:  NA
> details: use 'details(object)'
>
> ## returns a list
>
>> sessionInfo()
> R version 2.8.0 (2008-10-20)
> x86_64-unknown-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grDevices datasets  splines   graphics  stats     utils     tools
> [8] methods   base
>
> other attached packages:
>  [1] org.Hs.eg.db_2.2.6  RSQLite_0.7-1       GSEABase_1.4.0
>  [4] graph_1.20.0        annotate_1.20.0     xtable_1.5-4
>  [7] AnnotationDbi_1.4.1 RMySQL_0.6-1        DBI_0.2-4
> [10] simpleaffy_2.18.0   gcrma_2.14.1        matchprobes_1.14.0
> [13] genefilter_1.22.0   survival_2.34-1     affy_1.20.0
> [16] Biobase_2.2.0
>
> loaded via a namespace (and not attached):
> [1] affyio_1.10.1        cluster_1.11.11      preprocessCore_1.4.0
> [4] XML_1.98-1
>
>
>       
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793



More information about the Bioconductor mailing list