Comparing factor levels in deseq2 I have sample information (sampleinfo) in this format:

SampleID    condition   type
MP_1    A_1 Paired-End
MP_2    A_1 Paired-End
MP_3    A_1 Paired-End
MN_1    A_2 Paired-End
MN_2    A_2 Paired-End
MN_3    A_2 Paired-End
WP_1    B_1 Paired-End
WP_2    B_1 Paired-End
WP_3    B_1 Paired-End
WN_1    B_2 Paired-End
WN_2    B_2 Paired-End
WN_3    B_2 Paired-End


I want to compare A_1 with A_2, B_1 with B_2 ans also want to compare (A_1+A_2) with (B_1+B_2).

This is how I used DESeqDataSetFromMatrix

ddsMat &lt;- DESeqDataSetFromMatrix(countData = seqdata[,rownames(sampleinfo)], colData =  sampleinfo, design = ~ condition)
ddsMat &lt;- DESeq(ddsMat)

res.05_FC0&lt;-results(ddsMat,contrast = c("condition","A_1","A_2"),alpha=0.05,lfcThreshold = 0)
res.05_FC0&lt;-results(ddsMat,contrast = c("condition","B_1","B_2"),alpha=0.05,lfcThreshold = 0)


How can I compare (A_1+A_2) with (B_1+B_2) using the contrast argument in results function?

Of course I can make a new sampleinfo table, but I want to use the same sampleinfo as above. I tried to read about numeric contrast, but I am unable to use it correctly.
You can use contrast = c(0.5, 0.5, -0.5, -0.5), which means "the average of the first two coefficients minus the average of the second two.