CPM function in EDGER
1
3
Entering edit mode
3.7 years ago
francesca3 ▴ 140

Hi, I have some doubts on cpm function in edgeR package. Given this initial part of the code:

> library(edgeR)
> data_clean<- read.table("unito.txt", header = TRUE)
> group<-factor(c("A", "A", B","B"))
> y <- DGEList(counts=data_clean,group=group)
> y <- calcNormFactors(y)

I obtain different values if I calculate cpm in this way

> cpm <- cpm(y, log = FALSE, normalized.lib.sizes=TRUE)

Or in this one

> cpm <- cpm(y$counts, log = FALSE, normalized.lib.sizes=TRUE)

Why are them different? What does it change? What is the correct way to calculate them? I noticed that if I calculate them with the standard formula "by hand", I obtain the same values as the second formula (y$counts). In the edge manual it seems just to use the y argument.

Thank you, Francesca

edgerR RNA-Seq CPM • 8.2k views
ADD COMMENT
0
Entering edit mode

Please use the formatting bar in edit mode (especially the code option) to present your post better. I've done it for you this time.
code_formatting

Thank you!

ADD REPLY
0
Entering edit mode

Sorry. Thank you a lot!!

ADD REPLY
0
Entering edit mode

Hello francesca3!

It appears that your post has been cross-posted to another site: https://support.bioconductor.org/p/133466/

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLY
12
Entering edit mode
3.7 years ago
ATpoint 81k

This is normal and expected. If you use the first chunk the function will use the norm.factors from calcNormFactors to correct the counts for both library size and composition, see this video for the theory of library normalization.

With the second chunk of code you are providing only the count matrix so the function has no norm.factors therefore only correct per-million so for library size. That is why this matches with your by hand calculation.

The first method is the one you should use.

ADD COMMENT
0
Entering edit mode

Thank you! Very clear!

ADD REPLY
0
Entering edit mode

Glad to help!

ADD REPLY

Login before adding your answer.

Traffic: 1640 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6