[BioC] coerce aafTable object into dataframe (annaffy)

Georg Otto georg.otto at tuebingen.mpg.de
Thu Feb 23 18:15:17 CET 2006


Hi Jim and all others,


"James W. MacDonald" <jmacdon at med.umich.edu> writes:

>
> Georg Otto wrote:
>> 
>> 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 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.
>

That is a good point, that I haven't considered before.

>
> 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?
>


What I actually want to do is to put the annotation contained in the
"zebrafish" package (class aafTable) together with annotation from
TIGR's Resourcerer (class: matrix) and EnsEMBL's biomart (class
data.frame) in one big table. My idea was to convert all datasets
into a dataframe and use merge() to merge them together. You are right
that this might not be a valid strategy for the aafTable, so I
meanwhile used saveText() to output the aafTable in a temporary text
file and read.delim() to read it in a data frame. This works, but I
personally dislike the idea of writing to and reading from temporary
files, and with biomart data I run again into the problem of having
variable numbers of annotations per probeset.

An alternative strategy would be to write all the data in aafTables
and then use merge() to merge them. However, merge.aafTable leaves
only those probesets that occur in both tables (in contrast to the
generic merge for data frames, which has an option x.all=TRUE to
retain data that only ocur in the first table and in such a case
insert NA in columns from the second table). So the question arises:
Is there a way to merge aafTables of different sizes? Or are there
smarter ways to put the aforementioned annotation data together?

Best,

Georg



More information about the Bioconductor mailing list