I have a problem when I run DESeq2 with one variable with 8 levels, I can't find the contrast for any comparison with level 8
0
0
Entering edit mode
Edgar • 0
@2bba04fd
Last seen 2.1 years ago
Sweden

Hello,

I am doing a differential analysis in DESE2, I have the following tables:

countData = countD #an array of 11236 rows by 307 columns.

colData = colData_num #dataframe with one variable called GroupPregnancy with 8 levels

then the equation was perform as follow:


prev_dds <- DESeqDataSetFromMatrix(countData = countD,
                                    colData = colData_num,
                                    design= ~ GroupPregnancy )
dds_all_corrected <- DESeq(prev_dds)

if I code colData(prev_dds) I corroborate I have 8 levels

> colData(prev_dds)
DataFrame with 307 rows and 3 columns
                           GroupPregnancy sizeFactor replaceable
                                 <factor>  <numeric>   <logical>
NGS001-033-22-16752-4_S60               8   0.992220        TRUE
NGS001-033-22-16759-1_S72               8   0.992528        TRUE
NGS001-033-22-22100-11_S84              8   0.991939        TRUE
NGS001-033-22-23324-8_S96               8   0.991939        TRUE
NGS001-033-22-23327-13_S97              8   0.991939        TRUE
...                                   ...        ...         ...
NGS001-033-22-VL-2-89_S245              6   0.992220        TRUE
NGS001-033-22-VL-2-9_S155               6   0.992528        TRUE
NGS001-033-22-VL-2-91_S166              5   0.992220        TRUE
NGS001-033-22-VL-2-92_S178              6   0.991939        TRUE
NGS001-033-22-VL-2-96_S190              6   0.992528        TRUE

> dds_all_corrected$GroupPregnancy
  [1] 8 8 8 8 8 8 8 2 1 1 1 2 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 1 1 1 2 1 2 8 8 8 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 1 1 1 1 1 1
 [76] 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 2 8 8 2 8 8 8 1 8 8 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
[151] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 1 1 1 2 2 2 1 1 4 4 3 4 4 4 4 4 4 4 4 4 3 3 4 3 4 3 4 4 3 4 4 4 4 4 4 4 4
[226] 3 4 3 3 3 3 3 4 4 4 4 4 3 4 4 4 4 3 4 3 3 4 4 3 4 4 4 4 4 3 3 6 5 5 5 5 5 5 6 6 5 5 5 5 5 5 5 5 6 6 5 5 5 5 5 5 6 5 6 5 5 6 5 5 5 5 5 5 6 6 6 6 5 6 6
[301] 6 5 6 6 5 6 6
Levels: 1 2 3 4 5 6 7 8

But, when I run resultsNames(dds_all_corrected) there are only 7 levels:

> resultsNames(dds_all_corrected)
[1] "Intercept"             "GroupPregnancy1"       "GroupPregnancy_2_vs_1" "GroupPregnancy_3_vs_1" "GroupPregnancy_4_vs_1" "GroupPregnancy_5_vs_1"
[7] "GroupPregnancy_6_vs_1" "GroupPregnancy_7_vs_1"

and when I want to make a contrast with the level 8, it is not possible, I have the following error:

> results(dds_all_corrected, contrast = c("GroupPregnancy", "7","8"))
Error in cleanContrast(object, contrast, expanded = isExpanded, listValues = listValues,  : 
  7 and 8 should be levels of GroupPregnancy such that GroupPregnancy_7_vs_1 and GroupPregnancy_8_vs_1 are contained in 'resultsNames(object)'

It doesn't happen with other comparisons:
results(dds_all_corrected, contrast = c("GroupPregnancy", "1","2"))

results(dds_all_corrected, contrast = c("GroupPregnancy", "3","4"))

results(dds_all_corrected, contrast = c("GroupPregnancy", "5","6"))

e.g:

> results(dds_all_corrected, contrast = c("GroupPregnancy", "3","4"))
log2 fold change (MLE): GroupPregnancy 3 vs 4 
Wald test p-value: GroupPregnancy 3 vs 4 
DataFrame with 11236 rows and 6 columns
          baseMean log2FoldChange     lfcSE        stat      pvalue       padj
         <numeric>      <numeric> <numeric>   <numeric>   <numeric>  <numeric>
ASV2       3279.86      -0.793255  0.696330   -1.139193 2.54622e-01 0.99994670
ASV3       2793.68      -2.620075  0.571994   -4.580599 4.63646e-06 0.00045583
ASV4       2318.17      -0.419021  0.714229   -0.586675 5.57422e-01 0.99994670
ASV5       2219.83       0.121322  0.729653    0.166273 8.67942e-01 0.99994670
ASV6       1610.24      -1.227818  0.624983   -1.964561 4.94651e-02 0.61006903
...            ...            ...       ...         ...         ...        ...
ASV35572   1.01122    7.55841e-05  0.403488 0.000187327    0.999851         NA
ASV35573   1.01122    7.55841e-05  0.403488 0.000187327    0.999851         NA
ASV35575   1.01122    7.55844e-05  0.403488 0.000187327    0.999851         NA
ASV35576   1.01122    7.55844e-05  0.403488 0.000187327    0.999851         NA
ASV35577   1.01122    7.55844e-05  0.403488 0.000187327    0.999851         NA

All of these work well and I can make the contrast correctly. The problem is with level 8.

¿Could someone help me to find the mistake or the solution?

Thank you so much

Contrast factors levels • 1.0k views
ADD COMMENT
0
Entering edit mode

Start fresh. Remake the dds object, rerun DESeq on it. That's the first thing to try. And keep just one dds object, not one before and one after running DESeq. The simplest explanation is that you changed up the contents of the objects at some point, odd as that may seem.

ADD REPLY
0
Entering edit mode

I tried but dont find solution. I also tried by the way as follow:

> dds_all_corrected$GroupPregnancy <- factor(GroupPregnancy)
> design(dds_all_corrected) <- ~ GroupPregnancy
> dds_all_corrected <- DESeq(dds_all_corrected)
>
> resultsNames(dds_all_corrected)
[1] "Intercept"             "GroupPregnancy1"       "GroupPregnancy_2_vs_1" "GroupPregnancy_3_vs_1" "GroupPregnancy_4_vs_1" "GroupPregnancy_5_vs_1"
[7] "GroupPregnancy_6_vs_1" "GroupPregnancy_7_vs_1"

There still keep being only 7 levels (instead 8 of the original Data)

ADD REPLY
0
Entering edit mode

I was finally able to fix it. I restarted R and re-uploaded packages and the problem was fixed. It seems that there was some interference between packages.

ADD REPLY

Login before adding your answer.

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