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.