[BioC] medain global normalize - argument matrix

James W. MacDonald jmacdon at uw.edu
Thu Nov 1 18:16:50 CET 2012


Hi Mark,

On 10/27/2012 5:13 PM, Mark B wrote:
> Hi,
> I am trying to normalize a matrix of logged (base 2) cDNA expression
> intensity values (dimensions  4000, 4) from only the Cy5 channel derrived
> from an marrayraw object.  I would like to normalize the values
> using global median normalization where all arrays result having the same
> median value.  I would also like a matrix returned from the function.
>
> I have found how to use this normalize using an marrayraw object as
> argument ( e.g. maNorm(m, norm="median") ) but
>   I can't seem to find how to do this with a matrix as argument.
>
> I have also tried the following but while my argument is a matrix my output
> is a numeric vector that I can't seem to coerce
> back into a matrix with the same dimensions I started with.
>
>
> # median normalize all samples (columns)
>
> s.median<- apply(s, 2, median)
>
> class(s.median)
>
> [1] "numeric"

Right. You calculated the median for each column of your matrix, which 
is what the apply() function is for (e.g., you apply a function over the 
margins of a matrix - the columns in your case).

So what you really want here is the sweep() function, which is 
admittedly a bit cryptic (at least it was for me at one time). Anyway, 
the idea is that you will remove (sweep) a summary statistic over the 
margins of a matrix, based on a function you supply. The default is to 
subtract, which happens to be what you want to do.

norm.mat <- sweep(s, 2, s.median)

As an aside, single letter object names are fine for just playing around 
with data, but I would caution against using them for 'real' code. IMO 
it is advantageous to use a descriptive name for objects, so when you 
are looking back at your code in the future you don't have to go step by 
step to figure out what a and b and c  and d and f are.

Best,

Jim




>
>
>
> Any hints?
>
>
>
> Thanks in advance,
>
> MAB
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099



More information about the Bioconductor mailing list