This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How MaxMean method works to collapse duplicated genes? (collapseRows function in WGCNA package)

Hi I used collapseRows function with MaxMean method to get rid of duplicated genes in my microarray expression profile. My understanding of MaxMean is that it will choose the row with the highest mean absolute value. I wanted to check how exactly it works. To this end, first I chose L1CAM which is repeated three times in my data.

exp_annot[exp_annot$Gene.Symbol=="L1CAM",]

ID Gene.Symbol SC01141A.CEL SC01151A.CEL SC01153A.CEL SC01154A.CEL SC01155A.CEL SC01156A.CEL SC01157A.CEL SC01158A.CEL
32565  ADXEC.30227.C1_at       L1CAM      7.50263      3.99462      6.84585      4.08020      7.83157      7.27309      3.69999      3.56850
91789  ADXECNTDJ.8091_at       L1CAM      4.68515      4.73158      4.60477      4.33120      5.07858      5.26125      4.81417      4.50915
104594 ADXECRS.7093_s_at       L1CAM      6.56999      6.36527      6.77033      6.09783      7.48488      7.04284      6.35463      6.15014

Then I calculate rowMeans for each 3 rows:

ADXEC.30227.C1_at       L1CAM             rowMeans : 5.599556 
ADXECNTDJ.8091_at       L1CAM             rowMeans: 4.751981
ADXECRS.7093_s_at       L1CAM             rowMeans: 1.836985

I expected that MaxMean method choose ADXEC.30227.C1_at that have the highest rowMeans, but it selected ADXECRS.7093_s_at .

this is my code to collapse data using collapseRows function with MaxMean method:

rowGroup <- as.vector(exp_annot[exp_annot$Gene.Symbol=="L1CAM",]$Gene.Symbol)
rowID <- as.vector(exp_annot[exp_annot$Gene.Symbol=="L1CAM",]$ID)
datET <- exp_annot[exp_annot$Gene.Symbol=="L1CAM",][,-c(1,2)]
rownames(datET) <- rowID
head(datET)
collapse.maxmean <- collapseRows(datET=datET, rowGroup=rowGroup, rowID=rowID, method = "MaxMean")
L1CAM_maxmean <- data.frame(collapse.maxmean$group2row, collapse.maxmean$datETcollapsed)

and this is the result:

group     selectedRowID SC01141A.CEL SC01151A.CEL SC01153A.CEL SC01154A.CEL SC01155A.CEL SC01156A.CEL SC01157A.CEL SC01158A.CEL
L1CAM L1CAM ADXECRS.7093_s_at      6.56999      6.36527      6.77033      6.09783      7.48488      7.04284      6.35463      6.15014

Sorry, if it became too long. I really appreciate any help!

maxmean collapserows wgcna

1 answer

Your calculation of row means is wrong. The function is doing what it’s supposed to do. ADXECRS.7093_s_at has highest mean.

Why is it wrong? I used rowMeans function to calculate mean for each row:

rowMeans(df["ADXEC.30227.C1_at",c(3:10)])
ADXEC.30227.C1_at 
         5.599556  

rowMeans(df["ADXECNTDJ.8091_at",c(3:10)])
ADXECNTDJ.8091_at 
         4.751981 

rowMeans(df["ADXECRS.7093_s_at",c(3:10)])
ADXECRS.7093_s_at 
         6.604489

Is 5.599556 is higher than 6.604489 ? Am I missing something ? BTW, mean function calculates (trimmed) arithmetic mean.

And why the rowMeans changed from your first post (5.599556, 4.751981, 1.836985) to this (5.599556, 4.751981, 6.604489) now ?

If you really want to believe 5.599556 is higher than 6.604489, thats a different matter.

Oh, sorry I guess I messed up completely.

Log in to answer this question.