matrix row/column displayed as a list
5
0
Entering edit mode
Daniel Brewer ★ 1.9k
@daniel-brewer-1791
Last seen 7.1 years ago
Sorry it has taken so long for me to reply, I have been away. I enclose a cut down version of my expression matrix. Here is an example of my session: > matrixExample2 GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 > matrixExample2[,1] $IMAGE:1031489 [1] -0.828$IMAGE:1031497 [1] -0.426 $IMAGE:1031509 [1] -0.301$IMAGE:1031510 [1] -0.976 $IMAGE:1031516 [1] -2.066 [1] -0.754 > class(matrixExample2[,1]) [1] "list" > matrixExample2[1,]$GSM89679 [1] -0.828 $GSM89681 [1] -0.618$GSM89683 [1] -1.154 $GSM89684 [1] -0.975$GSM89685 [1] -0.59 > class(matrixExample2[1,]) [1] "list" > save(matrixExample2,file="matrixExample.rdata") As you can see the single rows and columns are lists whereas when I constructed a matrix (see previous email + below) the rows and column were of class numeric. I have had no success in converting the matrix away from being a list. Any help with this would be gratefully received. It is clear I am missing something. Dan PS Example from before > togo <- matrix(c(1,2,3,4),ncol=2, nrow=2) > togo [,1] [,2] [1,] 1 3 [2,] 2 4 > togo[,1] [1] 1 2 > class(togo[,1]) [1] "numeric" Seth Falcon wrote: > Daniel Brewer <daniel.brewer at="" icr.ac.uk=""> writes: > >> Yes I have already tried that, class(expression) is matrix. But >> class(expression[1,]) is list as is class(expression[,1]). Whereas the >> class of my simple constructed matrix when looking at a single row or >> column is numeric i.e. class(togo[,2]). >> >> Thanks for the suggestion anyway. > > Then you need to provide a lot more detailed information / > reproducible example. > > + seth > -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis MUCRC 15 Cotswold Road Sutton, Surrey SM2 5NG United Kingdom Tel: +44 (0) 20 8722 4109 Fax: +44 (0) 20 8722 4141 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}}
Cancer Cancer • 730 views
0
Entering edit mode
@sean-davis-490
Last seen 6 weeks ago
United States
On Monday 02 April 2007 12:43, Daniel Brewer wrote: > Sorry it has taken so long for me to reply, I have been away. I enclose > a cut down version of my expression matrix. Here is an example of my > > session: > > matrixExample2 > > GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 > IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 > IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 > IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 > IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 > IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 > IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 Hi, Dan. What does: class(matrixExample2) show? What happens if you do: matrixExample3 <- as.matrix(matrixExample2) class(matrixExample3) matrixExample3[,1] class(matrixExample3[,1]) Finally, what is the output of sessionInfo()? Sean
0
Entering edit mode
@sean-davis-490
Last seen 6 weeks ago
United States
On Tuesday 03 April 2007 06:04, Daniel Brewer wrote: > Sean Davis wrote: > > On Monday 02 April 2007 12:43, Daniel Brewer wrote: > >> Sorry it has taken so long for me to reply, I have been away. I enclose > >> a cut down version of my expression matrix. Here is an example of my > >> > >> session: > >>> matrixExample2 > >> > >> GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 > >> IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 > >> IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 > >> IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 > >> IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 > >> IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 > >> IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 > > > > Hi, Dan. > > > > What does: > > > > class(matrixExample2) show? > > > > What happens if you do: > > > > matrixExample3 <- as.matrix(matrixExample2) > > class(matrixExample3) > > matrixExample3[,1] > > class(matrixExample3[,1]) > > > > Finally, what is the output of sessionInfo()? > > > > Sean > > Hi Sean, > > Here are the results of the commands you suggested. > > > load("matrixExample.rdata") > > class(matrixExample2) > > [1] "matrix" > > > matrixExample3 <- as.matrix(matrixExample2) > > class(matrixExample3) > > [1] "matrix" > > > matrixExample3[,1] > > $IMAGE:1031489 > [1] -0.828 > >$IMAGE:1031497 > [1] -0.426 > > $IMAGE:1031509 > [1] -0.301 > >$IMAGE:1031510 > [1] -0.976 > > $IMAGE:1031516 > [1] -2.066 > >$IMAGE:1031532 > [1] -0.754 > > > class(matrixExample3[,1]) > > [1] "list" > > > sessionInfo() > > R version 2.4.1 (2006-12-18) > x86_64-unknown-linux-gnu > > locale: > LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_ GB.UTF- >8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF- 8;LC_NA >ME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTI FICATIO >N=C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > So that does not provide much insight. Have you got any other suggestions? Well, you've got me stumped, but that isn't too hard to do. Sean
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 7.1 years ago
Sean Davis <sdavis2 at="" mail.nih.gov=""> writes: > On Tuesday 03 April 2007 06:04, Daniel Brewer wrote: >> Sean Davis wrote: >> > On Monday 02 April 2007 12:43, Daniel Brewer wrote: >> >> Sorry it has taken so long for me to reply, I have been away. I enclose >> >> a cut down version of my expression matrix. Here is an example of my >> >> >> >> session: >> >>> matrixExample2 >> >> >> >> GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 >> >> IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 >> >> IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 >> >> IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 >> >> IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 >> >> IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 >> >> IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 >> > >> > Hi, Dan. >> > >> > What does: >> > >> > class(matrixExample2) show? >> > >> > What happens if you do: >> > >> > matrixExample3 <- as.matrix(matrixExample2) >> > class(matrixExample3) >> > matrixExample3[,1] >> > class(matrixExample3[,1]) >> > >> > Finally, what is the output of sessionInfo()? >> > >> > Sean >> >> Hi Sean, >> >> Here are the results of the commands you suggested. >> >> > load("matrixExample.rdata") >> > class(matrixExample2) >> >> [1] "matrix" >> >> > matrixExample3 <- as.matrix(matrixExample2) >> > class(matrixExample3) >> >> [1] "matrix" >> >> > matrixExample3[,1] >> >> $IMAGE:1031489 >> [1] -0.828 >> >>$IMAGE:1031497 >> [1] -0.426 >> >> $IMAGE:1031509 >> [1] -0.301 >> >>$IMAGE:1031510 >> [1] -0.976 >> >> $IMAGE:1031516 >> [1] -2.066 >> >>$IMAGE:1031532 >> [1] -0.754 >> >> > class(matrixExample3[,1]) >> >> [1] "list" >> >> > sessionInfo() >> >> R version 2.4.1 (2006-12-18) >> x86_64-unknown-linux-gnu >> >> locale: >> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en _GB.UTF- >>8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF -8;LC_NA >>ME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENT IFICATIO >>N=C >> >> attached base packages: >> [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" >> [7] "base" >> >> So that does not provide much insight. Have you got any other suggestions? > > Well, you've got me stumped, but that isn't too hard to do. This is very strange. Daniel, can you post the matrixExample.rdata file somewhere I could download it? + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org
0
Entering edit mode
Seth Falcon wrote: > Sean Davis <sdavis2 at="" mail.nih.gov=""> writes: > >> On Tuesday 03 April 2007 06:04, Daniel Brewer wrote: >>> Sean Davis wrote: >>>> On Monday 02 April 2007 12:43, Daniel Brewer wrote: >>>>> Sorry it has taken so long for me to reply, I have been away. I enclose >>>>> a cut down version of my expression matrix. Here is an example of my >>>>> >>>>> session: >>>>>> matrixExample2 >>>>> GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 >>>>> IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 >>>>> IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 >>>>> IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 >>>>> IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 >>>>> IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 >>>>> IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 >>>> Hi, Dan. >>>> >>>> What does: >>>> >>>> class(matrixExample2) show? >>>> >>>> What happens if you do: >>>> >>>> matrixExample3 <- as.matrix(matrixExample2) >>>> class(matrixExample3) >>>> matrixExample3[,1] >>>> class(matrixExample3[,1]) >>>> >>>> Finally, what is the output of sessionInfo()? >>>> >>>> Sean >>> Hi Sean, >>> >>> Here are the results of the commands you suggested. >>> >>>> load("matrixExample.rdata") >>>> class(matrixExample2) >>> [1] "matrix" >>> >>>> matrixExample3 <- as.matrix(matrixExample2) >>>> class(matrixExample3) >>> [1] "matrix" >>> >>>> matrixExample3[,1] >>> $IMAGE:1031489 >>> [1] -0.828 >>> >>>$IMAGE:1031497 >>> [1] -0.426 >>> >>> $IMAGE:1031509 >>> [1] -0.301 >>> >>>$IMAGE:1031510 >>> [1] -0.976 >>> >>> $IMAGE:1031516 >>> [1] -2.066 >>> >>>$IMAGE:1031532 >>> [1] -0.754 >>> >>>> class(matrixExample3[,1]) >>> [1] "list" >>> >>>> sessionInfo() >>> R version 2.4.1 (2006-12-18) >>> x86_64-unknown-linux-gnu >>> >>> locale: >>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=e n_GB.UTF- >>> 8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.U TF-8;LC_NA >>> ME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDE NTIFICATIO >>> N=C >>> >>> attached base packages: >>> [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" >>> [7] "base" >>> >>> So that does not provide much insight. Have you got any other suggestions? >> Well, you've got me stumped, but that isn't too hard to do. > > This is very strange. Daniel, can you post the matrixExample.rdata > file somewhere I could download it? > > + seth > 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. 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}}
0
Entering edit mode
On Tuesday 10 April 2007 05:15, Daniel Brewer wrote: > Seth Falcon wrote: > > Sean Davis <sdavis2 at="" mail.nih.gov=""> writes: > >> On Tuesday 03 April 2007 06:04, Daniel Brewer wrote: > >>> Sean Davis wrote: > >>>> On Monday 02 April 2007 12:43, Daniel Brewer wrote: > >>>>> Sorry it has taken so long for me to reply, I have been away. I > >>>>> enclose a cut down version of my expression matrix. Here is an > >>>>> example of my > >>>>> > >>>>> session: > >>>>>> matrixExample2 > >>>>> > >>>>> GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 > >>>>> IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 > >>>>> IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 > >>>>> IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 > >>>>> IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 > >>>>> IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 > >>>>> IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 > >>>> > >>>> Hi, Dan. > >>>> > >>>> What does: > >>>> > >>>> class(matrixExample2) show? > >>>> > >>>> What happens if you do: > >>>> > >>>> matrixExample3 <- as.matrix(matrixExample2) > >>>> class(matrixExample3) > >>>> matrixExample3[,1] > >>>> class(matrixExample3[,1]) > >>>> > >>>> Finally, what is the output of sessionInfo()? > >>>> > >>>> Sean > >>> > >>> Hi Sean, > >>> > >>> Here are the results of the commands you suggested. > >>> > >>>> load("matrixExample.rdata") > >>>> class(matrixExample2) > >>> > >>> [1] "matrix" > >>> > >>>> matrixExample3 <- as.matrix(matrixExample2) > >>>> class(matrixExample3) > >>> > >>> [1] "matrix" > >>> > >>>> matrixExample3[,1] > >>> > >>> $IMAGE:1031489 > >>> [1] -0.828 > >>> > >>>$IMAGE:1031497 > >>> [1] -0.426 > >>> > >>> $IMAGE:1031509 > >>> [1] -0.301 > >>> > >>>$IMAGE:1031510 > >>> [1] -0.976 > >>> > >>> $IMAGE:1031516 > >>> [1] -2.066 > >>> > >>>$IMAGE:1031532 > >>> [1] -0.754 > >>> > >>>> class(matrixExample3[,1]) > >>> > >>> [1] "list" > >>> > >>>> sessionInfo() > >>> > >>> R version 2.4.1 (2006-12-18) > >>> x86_64-unknown-linux-gnu > >>> > >>> locale: > >>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE =en_GB. > >>>UTF- > >>> 8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB .UTF-8; > >>>LC_NA > >>> ME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_I DENTIFI > >>>CATIO N=C > >>> > >>> attached base packages: > >>> [1] "stats" "graphics" "grDevices" "utils" "datasets" > >>> "methods" [7] "base" > >>> > >>> So that does not provide much insight. Have you got any other > >>> suggestions? > >> > >> Well, you've got me stumped, but that isn't too hard to do. > > > > This is very strange. Daniel, can you post the matrixExample.rdata > > file somewhere I could download it? > > > > + seth > > 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. Dan, I see the same thing you see (sessionInfo() below). I have no idea why this is the way it is (any ideas, Seth?), but to fix the problem, it looks like you can simply do something like: newMatrix <- matrix(matrixExample2,ncol=ncol(matrixExample2)) sessionInfo(): R version 2.5.0 alpha (2007-03-26 r40902) 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=en_US.UTF-8;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] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" Sean
0
Entering edit mode
Sean Davis wrote: > On Tuesday 10 April 2007 05:15, Daniel Brewer wrote: >> Seth Falcon wrote: >>> Sean Davis <sdavis2 at="" mail.nih.gov=""> writes: >>>> On Tuesday 03 April 2007 06:04, Daniel Brewer wrote: >>>>> Sean Davis wrote: >>>>>> On Monday 02 April 2007 12:43, Daniel Brewer wrote: >>>>>>> Sorry it has taken so long for me to reply, I have been away. I >>>>>>> enclose a cut down version of my expression matrix. Here is an >>>>>>> example of my >>>>>>> >>>>>>> session: >>>>>>>> matrixExample2 >>>>>>> GSM89679 GSM89681 GSM89683 GSM89684 GSM89685 >>>>>>> IMAGE:1031489 -0.828 -0.618 -1.154 -0.975 -0.59 >>>>>>> IMAGE:1031497 -0.426 -0.515 -0.765 -0.443 -0.713 >>>>>>> IMAGE:1031509 -0.301 -0.923 1.437 -0.836 0.461 >>>>>>> IMAGE:1031510 -0.976 -0.814 0.268 -1.331 0.913 >>>>>>> IMAGE:1031516 -2.066 0.134 0.332 -2.018 1.489 >>>>>>> IMAGE:1031532 -0.754 -2.202 -1.438 -2.054 -0.836 >>>>>> Hi, Dan. >>>>>> >>>>>> What does: >>>>>> >>>>>> class(matrixExample2) show? >>>>>> >>>>>> What happens if you do: >>>>>> >>>>>> matrixExample3 <- as.matrix(matrixExample2) >>>>>> class(matrixExample3) >>>>>> matrixExample3[,1] >>>>>> class(matrixExample3[,1]) >>>>>> >>>>>> Finally, what is the output of sessionInfo()? >>>>>> >>>>>> Sean >>>>> Hi Sean, >>>>> >>>>> Here are the results of the commands you suggested. >>>>> >>>>>> load("matrixExample.rdata") >>>>>> class(matrixExample2) >>>>> [1] "matrix" >>>>> >>>>>> matrixExample3 <- as.matrix(matrixExample2) >>>>>> class(matrixExample3) >>>>> [1] "matrix" >>>>> >>>>>> matrixExample3[,1] >>>>> $IMAGE:1031489 >>>>> [1] -0.828 >>>>> >>>>>$IMAGE:1031497 >>>>> [1] -0.426 >>>>> >>>>> $IMAGE:1031509 >>>>> [1] -0.301 >>>>> >>>>>$IMAGE:1031510 >>>>> [1] -0.976 >>>>> >>>>> $IMAGE:1031516 >>>>> [1] -2.066 >>>>> >>>>>$IMAGE:1031532 >>>>> [1] -0.754 >>>>> >>>>>> class(matrixExample3[,1]) >>>>> [1] "list" >>>>> >>>>>> sessionInfo() >>>>> R version 2.4.1 (2006-12-18) >>>>> x86_64-unknown-linux-gnu >>>>> >>>>> locale: >>>>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE =en_GB. >>>>> UTF- >>>>> 8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB .UTF-8; >>>>> LC_NA >>>>> ME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_I DENTIFI >>>>> CATIO N=C >>>>> >>>>> attached base packages: >>>>> [1] "stats" "graphics" "grDevices" "utils" "datasets" >>>>> "methods" [7] "base" >>>>> >>>>> So that does not provide much insight. Have you got any other >>>>> suggestions? >>>> Well, you've got me stumped, but that isn't too hard to do. >>> This is very strange. Daniel, can you post the matrixExample.rdata >>> file somewhere I could download it? >>> >>> + seth >> 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. > > Dan, > > I see the same thing you see (sessionInfo() below). I have no idea why this > is the way it is (any ideas, Seth?), but to fix the problem, it looks like > you can simply do something like: > > newMatrix <- matrix(matrixExample2,ncol=ncol(matrixExample2)) > > sessionInfo(): > R version 2.5.0 alpha (2007-03-26 r40902) > 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=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_U S.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF -8;LC_IDENTIFICATION=C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > > Sean Thanks Sean, Unfortunately though, the matrix command that you provided did not work for me. The matrix behaved exactly the same way as previously. What did work though was this: > newMatrix <- cbind(apply(matrixExample2,2,function(x){as.numeric(x)})) > rownames(newMatrix) <- rownames(matrixExample2) This might be a bit of a long winded way to do it, but it seemed to work. Very curious Thanks 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}}
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 7.1 years ago
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 -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org
0
Entering edit mode
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}}
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 7.1 years ago
Daniel Brewer <daniel.brewer at="" icr.ac.uk=""> writes: > Here is a reproducible list of commands to produce such a matrix. It is > probably very inefficient but I am new at this. So cbind is documented to create these list-based matrices if given lists as arguments instead of atomic vectors. I certainly don't blame you for not knowing this, it is a rather subtle detail. I'm pretty sure the problem slips in here: > #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)) > })) Here lapply on listo returns a list and matrix of a list gives you the weird list-based matrix object. So you could try using sapply or instead of calling matrix (not sure what the benefit of that is) you could unlist. Here's an untested idea: tempo2 <- do.call("cbind", lapply(1:ncol(exprGPL1283), function(i) { listo <- split(exprGPL1283[ , i], GPL1283Annot[["REPORTER"]]) sapply(listo, function(x) { median(unlist(x), na.rm=T) }) })) There is also something to be said here about debugging your own code and process. You could have likely solved your own problem had you broken down your transformation into smaller steps and verified the pieces as you went. + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org