The discrepancy between the mean of extracted fitted value and calculated mean and SE based on LFC.
1
0
Entering edit mode
@blastzoneheimerdinger-15116
Last seen 5.3 years ago

Hello, I have a question regarding the discrepancy between the mean of extracted fitted value and calculated mean based on LFC.

First, I want to plot some of our fitted results in barplot, and I tried below code to extract fitted value and plot.

fittedval <- t( t( assays(results)[["mu"]] ) / sizeFactors(results) )

fittedval[gene1,group1]

fittedval[gene1,group2]

Next, I plotted mean and standard error based on the log2foldchange and lfcse from result table, like below.

normalized.count <- counts(results, normalized=T)
std <- function(x) sd(x)/sqrt(length(x))

# Mean, SE of reference level.
m1 <- mean(normalized.count[gene1, group1])
s1 <- std(normalized.count[gene1, group1])
upper.limit <- m1+s1
lower.limit <- m1-s1

# Mean, SE of compared level, based on LFC and LFC-SE.
m2 <- m1 * 1/2^results[i,"log2FoldChange"]
upper.limit2 <- m1 * 1/2^(results[i,"log2FoldChange"]-results[i,"lfcSE"])
lower.limit2 <- m1 * 1/2^(results[i,"log2FoldChange"]+results[i,"lfcSE"])

Now I got mean, upper limit, lower limit of reference level, and group1.
However, when I plotted, the barplot represents different results between those based on fitted value and those based on log2FoldChange. How can this happen? Thank you very much in advance.

deseq2 deseq • 1.0k views
1
Entering edit mode
@mikelove
Last seen 14 hours ago
United States

Is this a simple two group comparison or do you have other covariates? Are you using LFC shrinkage? What does it say at the top when you print the DESeqResults object?

The LFC should be close to the log ratio of mean of normalized counts. Are you saying it is not? Can you give the actual values of these?

0
Entering edit mode

Hello, Thank you very much for the prompt help! I'm sorry now I can't show you the actual values of these, as I'm away from my workstation, but I have many other covariates like six, and I do not use LFC shrinkage.

1
Entering edit mode

If you have more than a simple single factor design then the LFC is not necessarily equal to the log ratio of the means, because it takes into account the other factors.

0
Entering edit mode

I understand, thank you very much!

Could you please tell me are there any way to extract fitted full model including other factors for the gene, so I can predict expression values considering other factors to reproduce LFC change?

1
Entering edit mode

This is outside the scope of what DESeq2 provides.

0
Entering edit mode

fittedval <- t( t( assays(results)[["mu"]] ) / sizeFactors(results) )

Thank you for the reply, and I'm sorry for the late response. I understand. If I somehow model (like linear model) the above fittedval data with my six independent variables, can I possibly reproduce the similar LFC? I wonder if there is a hint as LFC got promising results and i want to extract matrix that reproduce these, and when I digged in the code, I got lost in fitBeta function...

0
Entering edit mode

You can’t get the same GLM LFC for an arbitrary design with simple operations on the above data. For example, the GLM uses information about the count and the offset which is missing from the above data.