[R] How to log-2 transform a matrix

(Ted Harding) Ted.Harding at manchester.ac.uk
Sat Nov 10 18:23:08 CET 2007


On 10-Nov-07 16:43:28, Ben Bolker wrote:
> affy snp wrote:
>> Hi Ted,
>> My matrix looks like:
>> 
>>> dim(CGH)
>> [1] 238304    243
>>> CGH[1:30,1:4]
>>               WM806SignalA WM1716SignalA WM1862SignalA WM1963SignalA
>> SNP_A-1909444         1.59          1.48          1.78          2.59
>> SNP_A-2237149         2.24          1.87          1.95          2.04
>> SNP_A-4303947         2.02          1.70          1.90          2.36
>> SNP_A-2236359         2.58          2.06          1.87          2.15
>> SNP_A-2205441         1.87          1.46          1.86          2.40
> 
>    As others have commented, the problem seems to be with CGH
> and not with log2().  str(CGH) should give you more information 
> about what R thinks CGH is. 
> 
>   Did you forget to set header=TRUE when reading the data in?
> 
>   Ben Bolker

I guess that's possible, now that I think of it. I'd originally
read the above as the first few rows of 4 columns of a dataframe
with numerical values, with appropriate column-names, and the
row-names on the left. Hence it looked correct, and I was puzzled
by the error.

But, if read in (e.g. with read.csv() or read.table()) with
header=FALSE *and* with a comma preceding the first column-name
"WM806SignalA", then of course the "row names" would in fact
be a column of string data -- but with a column-name "X". This could
happen if the CSV was exported from a spreadsheet in which column A
was the row-names (starting at A.2) and row 1 was the column-names
(starting at B.1). So this scenario doesn't quite agree with the
above excerpt.

I'm also still puzzled that in the error message all the
column names come out strung together as one single string
(and with no spaces). This doesn't happen when I experiment
with log2(M) myself -- I only get the name of the earliest
offending column, which in this case would be "X", no?

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Nov-07                                       Time: 17:23:05
------------------------------ XFMail ------------------------------



More information about the R-help mailing list