Diff of /R/utils.R [000000] .. [efa494]

Switch to unified view

a b/R/utils.R
1
#' S4 class union data.frame_OR_EList
2
#'
3
#' @description Virtual class union containing members of \code{data.frame} and
4
#'  \code{limma::Elist}, used internally to handle situations when a returned
5
#'  object has a type that cannot be guessed from the function call.
6
#'
7
#' @return fusion of classes \code{data.frame} and \code{EList}, used within
8
#'  \code{.biotmle} by class \code{bioTMLE} to handle uncertainty in the object
9
#'  passed to slot "tmleOut".
10
#'
11
#' @importFrom methods setClassUnion new
12
#' @importClassesFrom methods data.frame
13
#' @importClassesFrom limma EList
14
#' @importClassesFrom S4Vectors Vector Annotated
15
#'
16
#' @export
17
setClassUnion(
18
  name = "data.frame_OR_EList",
19
  members = c("data.frame", "EList")
20
)
21
22
###############################################################################
23
24
#' Constructor for class bioTMLE
25
#'
26
#' @return class \code{biotmle} object, sub-classed from SummarizedExperiment.
27
#'
28
#' @import BiocGenerics
29
#' @importClassesFrom SummarizedExperiment SummarizedExperiment
30
#' @importFrom methods setClass
31
#'
32
#' @export .biotmle
33
#' @exportClass bioTMLE
34
#'
35
#' @rdname bioTMLE-class
36
#'
37
#' @examples
38
#' library(SummarizedExperiment)
39
#' library(biotmleData)
40
#' data(illuminaData)
41
#'
42
#' example_biotmle_class <- function(se) {
43
#'   call <- match.call(expand.dots = TRUE)
44
#'   biotmle <- .biotmle(
45
#'     SummarizedExperiment(
46
#'       assays = assay(se),
47
#'       rowData = rowData(se),
48
#'       colData = colData(se)
49
#'     ),
50
#'     call = call,
51
#'     ateOut = as.numeric(rep(NA, 10)),
52
#'     tmleOut = as.data.frame(matrix(NA, 10, 10)),
53
#'     topTable = as.data.frame(matrix(NA, 10, 10))
54
#'   )
55
#'   return(biotmle)
56
#' }
57
#'
58
#' example_class <- example_biotmle_class(se = illuminaData)
59
.biotmle <- methods::setClass(
60
  Class = "bioTMLE",
61
  slots = list(
62
    call = "call",
63
    ateOut = "vector",
64
    tmleOut = "data.frame_OR_EList",
65
    topTable = "data.frame"
66
  ),
67
  contains = "SummarizedExperiment"
68
)
69
70
###############################################################################
71
72
#' Accessor for Table of Raw Efficient Influence Function Values
73
#'
74
#' @param object S4 object of class \code{bioTMLE}.
75
#'
76
#' @importFrom methods is
77
#' @importFrom assertthat assert_that
78
#'
79
#' @return contents of \code{tmleOut} slot of object of class \code{biotmle}.
80
#'
81
#' @export
82
eif <- function(object) {
83
  assertthat::assert_that(is(object, "bioTMLE"))
84
  object@tmleOut
85
}
86
87
###############################################################################
88
89
#' Accessor for Results of Moderated Influence Function Hypothesis Testing
90
#'
91
#' @param object S4 object of class \code{bioTMLE}.
92
#'
93
#' @importFrom methods is
94
#' @importFrom assertthat assert_that
95
#'
96
#' @return contents of \code{topTable} slot of object of class \code{biotmle}.
97
#'
98
#' @export
99
toptable <- function(object) {
100
  assertthat::assert_that(is(object, "bioTMLE"))
101
  object@topTable
102
}