Coerce an object to a given class.
Supported coercion methods will extract any of these internal objects:
DESeqResults. Extracts the first results slotted.
Note that this corresponds to results containing log2 fold change (LFC)
values that have not been shrunken using
returns the version of this object coerced to be the given
Class. When used in the replacement form on the left of
an assignment, the portion of the object corresponding to
Class is replaced by
The operation of
as() in either form depends on the
definition of coerce methods. Methods are defined automatically
when the two classes are related by inheritance; that is, when
one of the classes is a subclass of the other.
Coerce methods are also predefined for basic classes (including all the types of vectors, functions and a few others).
Beyond these two sources of methods, further methods are defined
by calls to the
setAs function. See that
documentation also for details of how coerce methods work. Use
showMethods(coerce) for a list of all currently defined methods, as in the
Methods are pre-defined for coercing any object to one of the basic
datatypes. For example,
as(x, "numeric") uses the existing
as.numeric function. These and all other existing methods
can be listed as shown in the example.
Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)
If you think of using
try(as(x, cl)), consider
canCoerce(x, cl) instead.
#> class: DESeqDataSet #> dim: 500 12 #> metadata(3): version date interestingGroups #> assays(4): counts mu H cooks #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(27): geneID geneName ... deviance maxCooks #> colnames(12): sample01 sample02 ... sample11 sample12 #> colData names(2): condition sizeFactordt <- as(deseq, "DESeqTransform") print(dt)#> class: DESeqTransform #> dim: 500 12 #> metadata(3): version date interestingGroups #> assays(1): '' #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(28): geneID geneName ... dispGeneIter.1 dispFit #> colnames(12): sample01 sample02 ... sample11 sample12 #> colData names(2): condition sizeFactor## Pulls the first results slotted. res <- as(deseq, "DESeqResults") contrastName(res)#>  "condition_B_vs_A"summary(res)#> #> out of 499 with nonzero total read count #> adjusted p-value < 0.1 #> LFC > 0 (up) : 84, 17% #> LFC < 0 (down) : 87, 17% #> outliers  : 2, 0.4% #> low counts  : 0, 0% #> (mean count < 0) #>  see 'cooksCutoff' argument of ?results #>  see 'independentFiltering' argument of ?results #>