[BioC] matrix row/column displayed as a list

Daniel Brewer daniel.brewer at icr.ac.uk
Tue Apr 10 18:16:39 CEST 2007



Seth Falcon wrote:
> Daniel Brewer <daniel.brewer at icr.ac.uk> writes:
>>> This is very strange.  Daniel, can you post the matrixExample.rdata
>>> file somewhere I could download it?
> 
>> Hi,
>> Here is a URL where you can download the file from:
>> http://www.crukdmf.icr.ac.uk/matrixExample.rdata
>>
>> Also, to give a bit of background.  This matrix is a cut down version of
>> a matrix I constructed from a GSE object using the GEOquery package.
>>
>> Many thanks for looking into this.
> 
> The matrixExample2 object in the .rdata file is actually a list with
> dimension attributes stuck on it.  I get:
> 
>> typeof(matrixExample2)
> [1] "list"
> 
> I'm find it hard to see how this could be desired behavior and is
> something that probably needs a fix at the R level.  I suspect that
> the class() function needs to not return "matrix" for lists with dim
> and only for atomic vectors with dim.
> 
> It would be helpful to track down the code that is generating this
> list/matrix.  Almost certainly there is an easy fix that will create a
> proper matrix.
> 
> + seth
> 

Here is a reproducible list of commands to produce such a matrix.  It is
probably very inefficient but I am new at this.

library(GEOquery)
gse <- getGEO("GSE3921",destdir=".")

#Get Expression matrix for a particular platform
gsmplatforms <- lapply(GSMList(gse), function(x) {
Meta(x)$platform
})
gsmplat <- as.matrix(unlist(gsmplatforms))
temp <- gsmplat[gsmplat[,1]=="GPL1283",]
names <- names(temp)
probesets <- Table(GPLList(gse)$GPL1283)$ID
expr.matrix <- do.call("cbind",lapply(names,function(x) {
tab <- Table(GSMList(gse)[[x]])
mymatch <- match(probesets, tab$ID_REF)
return(as.numeric(as.vector(tab$VALUE[mymatch])))
}))
rownames(expr.matrix) <- probesets
colnames(expr.matrix) <- names
exprGPL1283<-expr.matrix

#Construct Annotation
GPL1283Annot <-Table(GPLList(gse)$GPL1283)

#Average over those probes that share clone IDs for each platform
tempo2 <- do.call("cbind",lapply(1:ncol(exprGPL1283),function(i)
{
listo <- split(exprGPL1283[,i],GPL1283Annot$REPORTER)
tempo <- lapply(listo,function(x) {
median(unlist(x),na.rm=T)
})
return(matrix(tempo))
}))
colnames(tempo2) <- colnames(exprGPL1283)
rownames(tempo2) <- names(split(exprGPL1283[,1],GPL1283Annot$REPORTER))
exprGPL1283complete <- tempo2

#exprGPL1283complete is the desired matrix

Hope that helps.  Warning the file GEOquery downloads is very large.

Dan

-- 
**************************************************************
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: daniel.brewer at icr.ac.uk
**************************************************************

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addre...{{dropped}}



More information about the Bioconductor mailing list