[BioC] average replicate columns in a matrix

Gordon K Smyth smyth at wehi.EDU.AU
Wed Mar 30 00:14:41 CEST 2011


Dear Julie,

Do you mean computing the sum of the replicate columns rather than the 
mean?  You can essentially do that with a call to rowsum() on the 
transposed matrix.

Best wishes
Gordon


On Tue, 29 Mar 2011, Zhu, Lihua (Julie) wrote:

> Dear Gordon,
>
> Is there a corresponding method for sum over replicate arrays? Thank you so
> much for your help!
>
> Best regards,
>
> Julie
>
>
> On 3/28/11 6:08 PM, "Gordon K Smyth" <smyth at wehi.EDU.AU> wrote:
>
>> Dear Wendy,
>>
>> The function avearrays() in the limma package does exactly this:
>>
>>> library(limma)
>>> avearrays(test)
>>           A  B
>>    [1,] 2.5 10
>>    [2,] 3.5 11
>>    [3,] 4.5 12
>>
>> Best wishes
>> Gordon
>>
>>> Date: Sun, 27 Mar 2011 19:25:29 -0400
>>> From: Wendy Qiao <wendy2.qiao at gmail.com>
>>> To: bioconductor at r-project.org
>>> Subject: [BioC] average replicate columns in a matrix
>>> Message-ID:
>>>
>>> I have a matrix like following
>>>
>>>> test=matrix(c(1:15),nrow=3,ncol=5)
>>>> colnames(test)=c("A","A","B","B","B")
>>>> test
>>>     A A B  B  B
>>> [1,] 1 4 7 10 13
>>> [2,] 2 5 8 11 14
>>> [3,] 3 6 9 12 15
>>>
>>> I want to calculate the average of each replicates, ie. I want the output to
>>> be
>>>     A B
>>> [1,] 2.5 10
>>> [2,] 3.5 11
>>> [3,] 4.5 12
>>>
>>> I can do this by looping through each level of the column name, but I was
>>> wondering if there is a function for calculating the average of replicates
>>> in one step.
>>>
>>> Thank you in advance.
>>> Wendy

______________________________________________________________________
The information in this email is confidential and intend...{{dropped:4}}



More information about the Bioconductor mailing list