[BioC] coerce aafTable object into dataframe (annaffy)
James W. MacDonald
jmacdon at med.umich.edu
Wed Feb 22 21:18:16 CET 2006
Hi Georg,
Georg Otto wrote:
> Hi,
>
> I have a question concerning an aafTable object generated using the
> package annaffy: I would like to coerce it into a data frame, but the
> way I am trying to do it does not work. Here is my code:
>
>
>>probeids<-geneNames(Data)
>>anntable<-aafTableAnn(probeids, "package", anncols)
>>slotNames(anntable)
>
> [1] "probeids" "table"
>
>
>>data.frame<-as.data.frame(anntable at table)
>
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
> cannot coerce class "aafList" into a data.frame
>
> I was supposing that this is the way to coerce a list inot a data
> frame, but apparently it is not working with this kind of object. Could
> somebody out there help me?
I don't think you will be able to do this for two reasons. First, the
table slot of an anntable is an S4 object, so I believe you need to have
a method defined for that class in order to convert from an aafList to a
data.frame.
Second, an aafList is a list of lists, which allows annaffy to build an
HTML table with equal numbers of cells per column, but with variable
numbers of elements in each cell. A data.frame is a special type of list
that requires each list element to be of the same length. Since this is
not necessarily true for an aafList, even if you were able to circumvent
the S4 system there is no guarantee that you would be able to convert
your aafList into a data.frame.
For instance, if I build an anntable using the first 10 probe ids in an
hgu133plus2 chip I get this:
> probids <- ls(hgu133plus2SYMBOL)[1:10]
> tmp <- aafTableAnn(probids, "hgu133plus2", aaf.handler()[1:6])
> sapply(tmp at table, function(x) lapply(x, length))
Probe Symbol Description Function Chromosome Chromosome Location
[1,] 1 1 1 0 1 1
[2,] 1 1 1 0 1 1
[3,] 1 1 1 0 1 1
[4,] 1 1 1 0 1 1
[5,] 1 1 1 0 1 1
[6,] 1 1 1 0 1 1
[7,] 1 1 1 0 1 2
[8,] 1 1 1 0 1 1
[9,] 1 1 1 0 1 1
[10,] 1 1 1 0 1 1
Note that the Chromosome Location has one element of length two, so even
if you could coerce to a data.frame, it wouldn't work because this
particular column would be too long.
I am curious why you want this in a data.frame. Can you not accomplish
what you want to do by either outputting your anntable in HTML or text form?
Best,
Jim
>
> I am using R 2.2.1 and annaffy 1.3.0
>
> Best,
>
> Georg
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
--
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623
More information about the Bioconductor
mailing list