Question: How to get DESeq2 sizefactors from data imported using tximport
0
23 months ago by
stan0
South Africa/Pretoria
stan0 wrote:

Hi,

How can i get sizeFactors from sailfish output imported into DESeq2 using tximport. I got NULL after doing the following:

> txi <- tximport(files, type="sailfish", tx2gene=tx2gene, dropInfReps=TRUE)
> ddsTxi <- DESeqDataSetFromTximport(txi, colData = samples, design = ~ condition)
> estimateSizeFactors(ddsTxi)
using 'avgTxLength' from assays(dds), correcting for library size
class: DESeqDataSet
dim: 39045 5
assays(3): counts avgTxLength normalizationFactors
rownames(39045): ENSG00000000003 ENSG00000000419 ... ENSG00000283698 ENSG00000283699
rowData names(0):
colnames(5): sample1 sample2 sample3 sample4 sample5
colData names(1): condition
> sizeFactors(ddsTxi)
NULL

Thanks for the help.

Stan

deseq2 sailfish tximport • 941 views
modified 22 months ago by Michael Love23k • written 23 months ago by stan0
Answer: How to get DESeq2 sizefactors from data imported using tximport
3
22 months ago by
Michael Love23k
United States
Michael Love23k wrote:

hi,

DESeq2 uses normalizationFactors when avgTxLength offset is imported with DESeqDataSetFromTximport. This combines size factor normalization with average transcript length normalization. So it's a matrix accessible via:

normalizationFactors(dds)

if you want to see the size factors that were calculated and incorporated with the average transcript lengths, they are these :

nm <- assays(dds)[["avgTxLength"]]
sf <- estimateSizeFactorsForMatrix(counts(dds), normMatrix=nm)

Thanks a lot Michael,

I noticed normMatrix argument is not used for the estimateSizeFactorsForMatrix function, so instead would it make sense to calculate the geometric mean of each sample (column) from normalizationFactors(dds), and use that as the size factor for each sample?

Or should I just get size factors using:

sf <- estimateSizeFactorsForMatrix(counts(dds)) # without the normMatrix argument

Alternatively does it make sense to get size factors using this:

sf  <- estimateSizeFactorsForMatrix(normalizationFactors(dds))
# since normalizationFactors(dds) "combines size factor normalization with average transcript length normalization" quoting from you above

Sorry, you are correct. I have a separate function estimateNormFactors(). The code inside this function is:

sf <- estimateSizeFactorsForMatrix(counts(dds) / nm)

Thanks again Michael, it's working fine now.

Hi, Michael,

I'm confused...as in my case,

sf1 <- estimateSizeFactorsForMatrix(counts(dds))
sf2  <- estimateSizeFactorsForMatrix(normalizationFactors(dds))
sf3 <- estimateSizeFactorsForMatrix(counts(dds) / nm)

Gives me three different results... If I only want to check the size factor, which one should I choose?

The last one, this is the one I indicated above. The others are not correct for finding the size factors that were calculated and incorporated into normalization factors. The second has no interpretation. The first is the size factors that would be calculated if we ignored the extra information from tximport.