lfcShrink contrast
1
0
Entering edit mode
LHA_trash • 0
@92b31510
Last seen 23 months ago
Germany

Hey,

I am currently analyzing some data with DSEq and I want to use the lfcShrink function on 2 different comparisons. However, one of them can only be retrieved from the results using contrast. I am now hesitant to use lfcShrink on this comparison, as I cannot use the coef() argument. Is it valid, to just use the contrast argument as I did it in the results? Here is the code

design2 <- as.formula(~cell_group)
modelMatrix2 <- model.matrix(design2, data = metadata6)
modelMatrix2
Show in New Window
               (Intercept) cell_groupDC2_TLR cell_groupDC3_ctrl cell_groupDC3_TLR
DC2-CD5pos-d1            1                 0                  0                 0
DC2-CD5pos-d2            1                 0                  0                 0
DC2-CD5pos-d3            1                 0                  0                 0
DC2-CD5pos-d4            1                 0                  0                 0
DC3-d1                   1                 0                  1                 0
DC3-d2                   1                 0                  1                 0
DC3-d3                   1                 0                  1                 0
DC3-d4                   1                 0                  1                 0
DC2-BTLA-S-d1            1                 1                  0                 0
DC2-BTLA-S-d3            1                 1                  0                 0
DC2-BTLA-S-d4            1                 1                  0                 0
DC3-CD163-S-d1           1                 0                  0                 1
DC3-CD163-S-d3           1                 0                  0                 1
DC3-CD163-S-d4           1                 0                  0                 1
attr(,"assign")
[1] 0 1 1 1
attr(,"contrasts")
attr(,"contrasts")$cell_group
[1] "contr.treatment"


ddsObj.raw2 <- DESeqDataSetFromMatrix(countData = countdata,
                                     colData = metadata6,
                                     design = design2)
ddsObj2 <- DESeq(ddsObj.raw2)
resultsNames(ddsObj2)
[1] "Intercept"                       "cell_group_DC2_TLR_vs_DC2_ctrl"  "cell_group_DC3_ctrl_vs_DC2_ctrl" "cell_group_DC3_TLR_vs_DC2_ctrl" 

#These are my two desired comparisons
rDC3vDC2_c<-results(ddsObj2,
                    name="cell_group_DC3_ctrl_vs_DC2_ctrl",
                    alpha=0.05)
rDC3vDC2_t<-results(ddsObj2,
                    contrast=c("cell_group","DC3_TLR","DC2_TLR"),
                    alpha=0.05)

So for rDC3vDC2_c i can easily use lfcShrink, as it is one of the resultsNames. However, rDC3vDC2_t cannot be used from ne resultsNames. Are the following lines of Code correct? I am getting an error

ddsShrink_c <- lfcShrink(ddsObj2, coef="cell_group_DC3_ctrl_vs_DC2_ctrl")
ddsShrink_t <- lfcShrink(ddsObj2, contras=c("cell_group","DC3_TLR","DC2_TLR"))

Fehler in lfcShrink(ddsObj2, contrast = c("cell_group", "DC3_TLR", "DC2_TLR")) : 
type='apeglm' shrinkage only for use with 'coef'

People have discussed this issue here: DESeq2 lfcShrink() usage of coef vs. usage of contrast I am however not sure, what to do. I am pretty new to bioinformatics (I am a physician), so hopefully someone can give me an advice. Cheers!

EDIT: I also tried to relevel, however it did not change my resultsNames output:

relevel(ddsObj2$cell_group, ref="DC2_TLR")
ddsObj3 <-DESeq(ddsObj2)
resultsNames(ddsObj3)

 [1] DC2_ctrl DC2_ctrl DC2_ctrl DC2_ctrl DC3_ctrl DC3_ctrl DC3_ctrl DC3_ctrl DC2_TLR  DC2_TLR  DC2_TLR  DC3_TLR  DC3_TLR  DC3_TLR 
Levels: DC2_TLR DC2_ctrl DC3_ctrl DC3_TLR
using pre-existing size factors
estimating dispersions
found already estimated dispersions, replacing these
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
[1] "Intercept"                       "cell_group_DC2_TLR_vs_DC2_ctrl"  "cell_group_DC3_ctrl_vs_DC2_ctrl" "cell_group_DC3_TLR_vs_DC2_ctrl"

Edit":

ddsShrink_t <- lfcShrink(ddsObj2, contras=c("cell_group","DC3_TLR","DC2_TLR"), type="ashr")

It now worked with ashr. But is this correct?

lfcshrink R DESeq2 • 918 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 4 hours ago
United States

You can

1) just use 'ashr' for shrinkage, it's also a good method 2) use the technique in the vignette in the shrinkage section, which directly addresses this case. it's one step and provides other contrasts as coefficients

ADD COMMENT
0
Entering edit mode

Thanks for your help!

ADD REPLY
0
Entering edit mode

Here is a code suggestion for making apeglm shrinking any contrast: https://www.biostars.org/p/448959/#484944

ADD REPLY

Login before adding your answer.

Traffic: 535 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