-
Notifications
You must be signed in to change notification settings - Fork 0
/
allClasses.R
136 lines (123 loc) · 4.03 KB
/
allClasses.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#' AnalysisData S4 class
#' @rdname AnalysisData-class
#' @description An S4 class for metabolomic data and sample meta information.
#' @slot data sample metabolomic data
#' @slot info sample meta information
#' @export
setClass('AnalysisData',
slots = list(
data = 'tbl_df',
info = 'tbl_df'
),
prototype = list(data = tibble(),info = tibble())
)
setValidity('AnalysisData',function(object){
data <- dat(object)
info <- sinfo(object)
if (nrow(data) != nrow(info)) {
'Number of rows in data should match number of rows in sample information!'
} else {
TRUE
}
})
#' AnalysisParameters S4 class
#' @rdname AnalysisParameters-class
#' @description An S4 class to store analysis parameters.
#' @slot pre-treatment list containing parameters for data pre-treatment
#' @slot modelling list containing parameters for modelling
#' @slot correlations list containing parameters for correlations
#'@export
setClass('AnalysisParameters',
slots = list(
`pre-treatment` = 'list',
modelling = 'list',
correlations = 'list'
),
prototype = list(
`pre-treatment` = list(),
modelling = list(),
correlations = list()
))
#' Analysis S4 class
#' @rdname Analysis-class
#' @description An S4 class to store analysis results.
#' @slot log list containing analysis dates and time
#' @slot parameters class AnalysisParameters containing the analysis parameters
#' @slot raw list containing info and raw data
#' @slot pre-treated list containing preTreated info and raw data
#' @slot modelling list containing modelling results
#' @slot correlations tibble containing weighted edgelist of correlations
#'@export
setClass('Analysis',
slots = list(
log = 'list',
parameters = 'AnalysisParameters',
raw = 'AnalysisData',
`pre-treated` = 'AnalysisData',
modelling = 'list',
correlations = 'tbl_df'
),
prototype = list(
log = list(packageVersion = packageVersion('metabolyseR') %>%
as.character(),
analysis = date(),
verbose = TRUE)
)
)
#' RandomForest S4 class
#' @rdname RandomForest-class
#' @description An S4 class for random forest results and models.
#' @slot type random forest type
#' @slot response response variable name
#' @slot results list of measure and importance results tables
#' @slot predictions tibble of model observation predictions
#' @slot permutations list of permutations measure and importance results tables
#' @slot importances tibble of model feature importances
#' @slot proximities tibble of model observation proximities
#' @slot models list of random forest models
#' @export
setClass('RandomForest',
contains = 'AnalysisData',
slots = list(
type = 'character',
response = 'character',
results = 'list',
predictions = 'tbl_df',
permutations = 'list',
importances = 'tbl_df',
proximities = 'tbl_df',
models = 'list'
)
)
#' Univariate S4 class
#' @rdname Univariate-class
#' @description An S4 class for univariate test models and results.
#' @slot type univariate test type
#' @slot models list of model objects
#' @slot results tibble containing test results
#' @export
setClass('Univariate',
contains = 'AnalysisData',
slots = list(
type = 'character',
models = 'list',
results = 'tbl_df'
))
setClass('LDA',
contains = 'AnalysisData',
slots = list(
stats = 'tbl_df',
Tw = 'numeric',
rankmat = 'numeric',
means = 'numeric',
loadings = 'tbl_df',
x = 'tbl_df',
xmeans = 'tbl_df',
pred = 'factor',
cl = 'factor',
prior = 'numeric',
conf = 'table',
acc = 'numeric',
lev = 'character',
call = 'call'
))