Search
Question: The discrepancy between the mean of extracted fitted value and calculated mean and SE based on LFC.
0
gravatar for blastzone.heimerdinger
4 months ago by

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.

ADD COMMENTlink modified 4 months ago • written 4 months ago by blastzone.heimerdinger0
1
gravatar for Michael Love
4 months ago by
Michael Love20k
United States
Michael Love20k wrote:

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?

 

 

ADD COMMENTlink modified 4 months ago • written 4 months ago by Michael Love20k

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.

ADD REPLYlink written 4 months ago by blastzone.heimerdinger0
1

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.

ADD REPLYlink modified 4 months ago • written 4 months ago by Michael Love20k

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?

ADD REPLYlink written 4 months ago by blastzone.heimerdinger0
1

This is outside the scope of what DESeq2 provides.

ADD REPLYlink written 4 months ago by Michael Love20k

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...

ADD REPLYlink modified 4 months ago • written 4 months ago by blastzone.heimerdinger0

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.

ADD REPLYlink modified 4 months ago • written 4 months ago by Michael Love20k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 377 users visited in the last hour