DEGSet — DEGSet • DEGreport
Description: S4 class to store data from differentially expression analysis. It should be compatible with different package and stores the information in a way the methods will work with all of them.

# DEGSet

`DEGSet.Rd`

S4 class to store data from differentially expression analysis. It should be compatible with different package and stores the information in a way the methods will work with all of them.

    DEGSet(resList, default)

    DEGSet(resList, default)

    as.DEGSet(object, ...)

    # S4 method for TopTags
    as.DEGSet(object, default = "raw", extras = NULL)

    # S4 method for data.frame
    as.DEGSet(object, contrast, default = "raw",
      extras = NULL)

    # S4 method for DESeqResults
    as.DEGSet(object, default = "shrunken",
      extras = NULL)

## Arguments

resList | List with results as elements containing log2FoldChange, pvalues and padj as column. Rownames should be feature names. Elements should have names.
default | The name of the element to use by default.
object | Different objects to be transformed to DEGSet when using `as.DEGSet`.
... | Optional parameters of the generic.
extras | List of extra tables related to the same comparison when using `as.DEGSet`.
contrast | To name the comparison when using `as.DEGSet`.

## Details

For now supporting only `DESeq2::results()` output. Use constructor `degComps()` to create the object.

The list will contain one element for each comparison done. Each element has the following structure:

- DEG table

- Optional table with shrunk Fold Change when it has been done.

To access the raw table use `deg(dgs, "raw")`, to access the shrunken table use `deg(dgs, "shrunken")` or just `deg(dgs)`.

## Examples

    library(DESeq2)#> Loading required package: S4Vectors#> Loading required package: stats4#> Loading required package: BiocGenerics#> Loading required package: parallel#>
    #> Attaching package: ‘BiocGenerics’#> The following objects are masked from ‘package:parallel’:
    #>
    #>     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    #>     clusterExport, clusterMap, parApply, parCapply, parLapply,
    #>     parLapplyLB, parRapply, parSapply, parSapplyLB#> The following objects are masked from ‘package:stats’:
    #>
    #>     IQR, mad, sd, var, xtabs#> The following objects are masked from ‘package:base’:
    #>
    #>     anyDuplicated, append, as.data.frame, basename, cbind, colnames,
    #>     dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
    #>     grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
    #>     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    #>     rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    #>     union, unique, unsplit, which, which.max, which.min#>
    #> Attaching package: ‘S4Vectors’#> The following object is masked from ‘package:base’:
    #>
    #>     expand.grid#> Loading required package: IRanges#> Loading required package: GenomicRanges#> Loading required package: GenomeInfoDb#> Loading required package: SummarizedExperiment#> Loading required package: Biobase#> Welcome to Bioconductor
    #>
    #>     Vignettes contain introductory material; view with
    #>     'browseVignettes()'. To cite Bioconductor, see
    #>     'citation("Biobase")', and for packages 'citation("pkgname")'.#> Loading required package: DelayedArray#> Loading required package: matrixStats#>
    #> Attaching package: ‘matrixStats’#> The following objects are masked from ‘package:Biobase’:
    #>
    #>     anyMissing, rowMedians#> Loading required package: BiocParallel#>
    #> Attaching package: ‘DelayedArray’#> The following objects are masked from ‘package:matrixStats’:
    #>
    #>     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges#> The following objects are masked from ‘package:base’:
    #>
    #>     aperm, apply, rowsumlibrary(edgeR)#> Loading required package: limma#>
    #> Attaching package: ‘limma’#> The following object is masked from ‘package:DESeq2’:
    #>
    #>     plotMA#> The following object is masked from ‘package:BiocGenerics’:
    #>
    #>     plotMAlibrary(limma)
    dds <- makeExampleDESeqDataSet(betaSD = 1)
    colData(dds)[["treatment"]] <- sample(colData(dds)[["condition"]], 12)
    design(dds) <-  ~ condition + treatment
    dds <- DESeq(dds)#> estimating size factors#> estimating dispersions#> gene-wise dispersion estimates#> mean-dispersion relationship#> final dispersion estimates#> fitting model and testingres <- degComps(dds, combs = c("condition"))#> Doing 1 element(s).#> Doing results() for each element.#> Doing lcfSrink() for each element.#> using 'normal' for LFC shrinkage, the Normal prior from Love et al (2014).
    #>
    #> Note that type='apeglm' and type='ashr' have shown to have less bias than type='normal'.
    #> See ?lfcShrink for more details on shrinkage type, and the DESeq2 vignette.
    #> Reference: https://doi.org/10.1093/bioinformatics/bty895deg(res)#> log2 fold change (MAP): condition B vs A
    #> Wald test p-value: condition B vs A
    #> DataFrame with 1000 rows and 6 columns
    #>                  baseMean     log2FoldChange             lfcSE
    #>                 <numeric>          <numeric>         <numeric>
    #> gene202  595.738080502665   2.84842810352625 0.266347713336691
    #> gene710  117.423055944441   2.27457157814062 0.269412722270367
    #> gene365  62.4434899710059   2.58422310739862 0.312590047837112
    #> gene92   220.780204589055   2.34371133129609 0.293935357285173
    #> gene364  504.522116500683   2.02714357936619 0.261124625693044
    #> ...                   ...                ...               ...
    #> gene817  1.01863690444656  0.449433023322897 0.445454565205662
    #> gene843 0.337116176782868 -0.213542721980008 0.335419175582519
    #> gene896 0.641791262357825 -0.193113193147619 0.453528848117175
    #> gene929 0.400097105619871  0.148754379342596 0.336592062169539
    #> gene986  1.03912504596143  -0.08078789533133 0.501091699324092
    #>                       stat               pvalue                 padj
    #>                  <numeric>            <numeric>            <numeric>
    #> gene202   10.4242414625226 1.92186681865069e-25 1.84307027908601e-22
    #> gene710   8.19578166036082 2.48969903778264e-16 1.19381068861678e-13
    #> gene365   8.02865482517521 9.85471916802617e-16 3.15022522737903e-13
    #> gene92     7.7626720152767 8.31584691463868e-15 1.99372429778462e-12
    #> gene364   7.51756890822073 5.58041485417993e-14 1.07032356903171e-11
    #> ...                    ...                  ...                  ...
    #> gene817   1.05361747680227    0.292058084434074                   NA
    #> gene843 -0.406932816121088    0.684057332932902                   NA
    #> gene896 -0.612499137852159      0.5402075682426                   NA
    #> gene929  0.414219583248068    0.678713301164469                   NA
    #> gene986 0.0436335995171099    0.965196468651691                   NA#> <numeric>deg(res, tidy = "tibble")#> # A tibble: 1,000 x 7
    #>    gene    baseMean log2FoldChange lfcSE  stat   pvalue     padj
    #>    <chr>      <dbl>          <dbl> <dbl> <dbl>    <dbl>    <dbl>
    #>  1 gene202    596.            2.85 0.266 10.4  1.92e-25 1.84e-22
    #>  2 gene710    117.            2.27 0.269  8.20 2.49e-16 1.19e-13
    #>  3 gene365     62.4           2.58 0.313  8.03 9.85e-16 3.15e-13
    #>  4 gene92     221.            2.34 0.294  7.76 8.32e-15 1.99e-12
    #>  5 gene364    505.            2.03 0.261  7.52 5.58e-14 1.07e-11
    #>  6 gene968     69.4           2.62 0.345  7.11 1.17e-12 1.87e-10
    #>  7 gene836     49.2           2.41 0.335  7.05 1.78e-12 2.43e-10
    #>  8 gene77      32.5          -2.31 0.334 -6.75 1.50e-11 1.80e- 9
    #>  9 gene342    484.            1.45 0.225  6.50 7.90e-11 8.42e- 9
    #> 10 gene880     27.5           2.80 0.402  6.48 9.01e-11 8.64e- 9
    #> # … with 990 more rows# From edgeR
    dge <- DGEList(counts=counts(dds), group=colData(dds)[["treatment"]])
    dge <- estimateCommonDisp(dge)
    res <- as.DEGSet(topTags(exactTest(dge)))
    # From limma
    v <- voom(counts(dds), model.matrix(~treatment, colData(dds)), plot=FALSE)
    fit <- lmFit(v)
    fit <- eBayes(fit, robust=TRUE)
    res <- as.DEGSet(topTable(fit, n = "Inf"), "A_vs_B")#> Removing intercept from test coefficients