Skip to content

Commit d0f81a5

Browse files
authored
Release 3 12 candidate (#32)
* fix base=10 regardless of input (see #15) class constructor was always setting base to 10 instead of the input value * merge bug fix 1.01 into dev (#19) * bug fix issue #7 Correctly re-order the sample_meta column for colouring samples in the dendrogram plot * version bump bug fix issue #7 * fix for #18 (#20) correctly reorder the factor labels so that the control group always ends up in the denominator for the fold change calculation. * fix for #18 fixed incorrect length check on matching class labels. * Issue 17 ttest factor (#21) * convert to factor if not one already fix for issue #17 * update roxygen version * fix for issue #9 (#22) changed from lapply to vapply and used drop=FALSE to ensure compatibility with a single factor. * allow user to set lambda (#24) - lambda changed to input parameter. NULL = uses pmp optimisation - model_predict now uses the set value of lambda, or lambda_opt if used. - documentation updated * Feature non parametric fold change (#26) * add "median" method based on DOI: 10.1080/00949650212140 can now calcuate fold changes equivalent to using medians and corresponding confidence intervals * update documentation * update median method now correctly calculates ratio of medians * use wilcox for paired median intervals make use of wilcox.test to estimate intervals for the median when using median for paired samples * Issue 23 filter by name (#27) * fix for #23 moved all model_apply functionality to model_predict so that model_train and model_predict can be used as well as model_apply * update documentation * Update mean_of_medians.R (#29) fix for #28 - correctly loop over all levels in the named factor * Feature documentation 3 12 (#31) * update documentation Description and inputs now pulled from the object definitions for consistency. * fix definition of label_features allows NULL and description updated * replace non ascii characters * export mixed_effect object * use correct object name to generate documentation * export mixed_effect object * remove non ascii characters * update tests with new object name * add import for capture.output * add import for capture.output * use pca_biplot in tests chart was renamed * add utils import * update struct dependency version * update documentation * update news, version bump
1 parent 443bf79 commit d0f81a5

File tree

170 files changed

+3094
-2817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+3094
-2817
lines changed

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: structToolbox
22
Type: Package
33
Title: Data processing & analysis tools for Metabolomics and other omics
4-
Version: 1.1.1
4+
Version: 1.1.2
55
Authors@R: c(
66
person(
77
c("Gavin","Rhys"),
@@ -104,16 +104,17 @@ Collate:
104104
'vec_norm_class.R'
105105
'wilcox_test_class.R'
106106
'zzz.R'
107-
Depends: R (>= 4.0), struct (>= 0.99.10)
107+
Depends: R (>= 4.0), struct (>= 1.1.2)
108108
Imports: ggplot2,
109109
ggthemes,
110110
grid,
111111
gridExtra,
112112
methods,
113113
scales,
114114
sp,
115-
stats
116-
RoxygenNote: 7.1.0
115+
stats,
116+
utils
117+
RoxygenNote: 7.1.1
117118
Suggests: agricolae,
118119
BiocFileCache,
119120
BiocStyle,

NAMESPACE

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export(AUC)
55
export(DFA)
66
export(DatasetExperiment_boxplot)
77
export(DatasetExperiment_dist)
8-
export(DatasetExperiment_factor_barchart)
8+
export(DatasetExperiment_factor_boxplot)
99
export(DatasetExperiment_heatmap)
1010
export(HCA)
1111
export(HSD)
@@ -38,7 +38,7 @@ export(fisher_exact)
3838
export(fold_change)
3939
export(fold_change_int)
4040
export(fold_change_plot)
41-
export(forward_selection_byrank)
41+
export(forward_selection_by_rank)
4242
export(fs_line)
4343
export(glog_opt_plot)
4444
export(glog_transform)
@@ -65,7 +65,7 @@ export(mv_sample_filter_hist)
6565
export(nroot_transform)
6666
export(pairs_filter)
6767
export(pareto_scale)
68-
export(pca_biplot_plot)
68+
export(pca_biplot)
6969
export(pca_correlation_plot)
7070
export(pca_dstat_plot)
7171
export(pca_loadings_plot)
@@ -117,3 +117,4 @@ import(stats)
117117
import(struct)
118118
importFrom(scales,squish)
119119
importFrom(sp,point.in.polygon)
120+
importFrom(utils,capture.output)

NEWS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Changes 1.1.2
2+
+ Documentation updates
3+
+ Bug fixes
4+
5+
Changes 1.0.1
6+
+ Fix HCA bug
7+
8+
Changes 1.0.0
9+
+ Bioconductor 3.11 release
10+
111
Changes 0.99.10
212
+ add Metabolmics BiocView
313
+ fix missing sections at end of vignette

R/AUC_metric_class.R

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
#' Area under ROC
2-
#'
3-
#' Area under ROC calculated by approximating the curve as a series of trapeziums.
4-
#' Only suitable for 2 classes.
5-
#'
6-
#' @return A metric object with methods for calculating AUC
7-
#'
1+
#' @eval get_description('AUC')
82
#' @examples
93
#' D = iris_DatasetExperiment()
104
#' XCV = kfold_xval(folds=5,factor_name='Species') *
115
#' (mean_centre() + PLSDA(number_components=2,factor_name='Species'))
126
#' MET = AUC()
137
#' XCV = run(XCV,D,MET)
14-
#'
15-
#' @param ... additional slots and values passed to struct_class
16-
#' @return struct object
178
#' @export AUC
189
AUC = function(...) {
1910
out=struct::new_struct('AUC',...)
@@ -23,9 +14,12 @@ AUC = function(...) {
2314

2415
.AUC<-setClass(
2516
"AUC",
26-
contains='metric',
27-
prototype = list(name='Area under ROC',
28-
type="classification"
17+
contains=c('metric','stato'),
18+
prototype = list(name='Area under ROC curve',
19+
description=paste0("The area under the ROC curve of a classifier is ",
20+
"estimated using the trapezoid method."),
21+
type="classification",
22+
stato_id="STATO:0000209"
2923
)
3024
)
3125

R/DFA_class.R

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
#' Discriminant Factor Analysis (DFA)
2-
#'
3-
#' Applies Discriminant Factor Analysis to a dataset.
4-
#' @param factor_name The sample_meta column name containing group labels
5-
#' @param number_components The number of discriminant factors to calculate
6-
#' @param ... additional slots and values passed to struct_class
7-
#' @return struct object
1+
#' @eval get_description('DFA')
82
#' @export DFA
93
#' @include entity_objects.R
104
#' @examples
@@ -24,22 +18,42 @@ DFA = function(factor_name,number_components=2,...) {
2418
"DFA",
2519
contains = c('model'),
2620
slots=c(
27-
number_components='numeric',
21+
number_components='entity',
2822
factor_name='entity',
2923
scores='DatasetExperiment',
3024
loadings='data.frame',
3125
eigenvalues='data.frame',
3226
that='DatasetExperiment'
3327
),
34-
28+
3529
prototype=list(name = 'Discriminant Factor Analysis',
36-
description = 'Applies DFA to a data matrix.',
30+
description = paste0('Discriminant Factor Analysis (DFA) is a ',
31+
'supervised classification method. Using a linear combination of the ',
32+
'input variables, DFA finds new orthogonal axes (canonical values) ',
33+
'to minimize the variance within each given class and maximize ',
34+
'variance between classes.'),
3735
type = 'classification',
3836
predicted = 'that',
37+
citations=list(
38+
bibentry(
39+
bibtype='Book',
40+
title='Multivariate Statistical Methods: A Primer',
41+
author=as.person('B.F.J. Manly'),
42+
year='1986',
43+
publisher='Chapman and Hall',
44+
address='Boca Raton'
45+
)
46+
),
3947
.params=c('factor_name','number_components'),
4048
.outputs=c('scores','loadings','eigenvalues','that'),
41-
42-
factor_name=ents$factor_name
49+
50+
factor_name=ents$factor_name,
51+
52+
number_components=entity(value = 2,
53+
name = 'Number of components',
54+
description = 'The number of DFA components calculated.',
55+
type = c('numeric','integer')
56+
)
4357

4458
)
4559
)
@@ -84,11 +98,11 @@ setMethod(f="model_train",
8498

8599
# projection
86100
ev = eigen(P)
87-
101+
88102
# handle imaginary values (should be vv small)
89103
ev$values=Re(ev$values)
90104
ev$vectors=Re(ev$vectors)
91-
105+
92106
# reduce to number of desired components
93107
ev$values=ev$values[1:M$number_components]
94108
ev$vectors=ev$vectors[,1:M$number_components]
@@ -122,7 +136,7 @@ setMethod(f="model_train",
122136
setMethod(f="model_predict",
123137
signature=c("DFA","DatasetExperiment"),
124138
definition=function(M,D) {
125-
139+
126140
X=as.matrix(D$data)
127141
P=output_value(M,'loadings')
128142
that=X%*%as.matrix(P)
@@ -141,25 +155,8 @@ setMethod(f="model_predict",
141155
)
142156

143157

144-
#' dfa_scores_plot class
145-
#'
146-
#' 2d scatter plot of discriminant factor scores.
147-
#'
158+
#' @eval get_description('dfa_scores_plot')
148159
#' @import struct
149-
#' @param components The discriminant factors to plot (\code{numeric(2)})
150-
#' @param points_to_label "none", "all", or "outliers" will be labelled on the plot.
151-
#' @param factor_name The sample_meta column name to use for colouring the points.
152-
#' You can provide up to two factors for this plot.
153-
#' @param ellipse "all" will plot all ellipses, "group" will only plot group ellipses,
154-
#' "none" will not plot any ellipses and "sample" will plot ellipse for all samples (ignoring group).
155-
#' @param label_filter Only include labels for samples in the group specified by label_filter.
156-
#' If zero length then all labels will be included.
157-
#' @param label_factor The sample_meta column to use for labelling the samples.
158-
#' If 'rownames' then the rownames will be used.
159-
#' @param label_size The text size of the labels.NB ggplot units, not font size units.
160-
#' Default 3.88.
161-
#' @param ... additional slots and values passed to struct_class
162-
#' @return struct object
163160
#' @export dfa_scores_plot
164161
#' @include DFA_class.R
165162
#' @examples
@@ -206,54 +203,67 @@ dfa_scores_plot = function(
206203
),
207204

208205
prototype = list(name='DFA scores plot',
209-
description='Plots a 2d scatter plot of the selected components',
206+
description='A scatter plot of the selected DFA components.',
210207
type="scatter",
211-
.params=c('components','points_to_label','factor_name','ellipse','label_filter','label_factor','label_size'),
208+
libraries=c('scales','ggplot2'),
209+
.params=c('components','points_to_label','factor_name','ellipse',
210+
'label_filter','label_factor','label_size'),
212211

213212
components=entity(name='Components to plot',
214213
value=c(1,2),
215214
type='numeric',
216-
description='the components to be plotted e.g. c(1,2) plots component 1 on the x axis and component 2 on the y axis.',
215+
description=paste0('The components selected for plotting.'),
217216
max_length=2
218217
),
219218

220-
points_to_label=enum(name='points_to_label',
219+
points_to_label=enum(name='Points to label',
221220
value='none',
222221
type='character',
223-
description='("none"), "all", or "outliers" will be labelled on the plot.',
222+
description=c(
223+
'none' = 'No samples labels are displayed.',
224+
"all" = 'The labels for all samples are displayed.',
225+
"outliers" = 'Labels for for potential outlier samples are displayed.'
226+
),
224227
allowed=c('none','all','outliers')
225228
),
226-
factor_name=entity(name='Factor name',
227-
value='factor',
228-
type='character',
229-
description='The column name of sample meta to use for plotting. A second column can be included to plot using symbols.',
230-
max_length=2
231-
),
232-
ellipse=enum(name = 'Plot ellipses',description=c(
233-
'"all" will plot all ellipses',
234-
'"group" will only plot group ellipses',
235-
'"none" will not plot any ellipses',
236-
'"sample" will plot ellipse for all samples (ignoring group)'),
229+
factor_name=ents$factor_name,
230+
ellipse=enum(
231+
name = 'Plot ellipses',
232+
description=c(
233+
"all" = paste0('Hotelling T2 95\\% ellipses are plotted for all groups and all samples.'),
234+
"group" = 'Hotelling T2 95\\% ellipses are plotted for all groups.',
235+
"none" = 'Ellipses are not included on the plot.',
236+
"sample" = 'A Hotelling T2 95\\% ellipse is plotted for all samples (ignoring group)'),
237237
allowed=c('all','group','none','sample'),
238-
value='all'),
239-
label_filter=entity(name='Label filter',
238+
value='all'
239+
),
240+
label_filter=entity(
241+
name='Label filter',
240242
value=character(0),
241243
type='character',
242-
description='Only include the param.group labels included in label_filter. If zero length then all labels will be included.'
244+
description=paste0(
245+
'Labels are only plotted for the named groups. If ',
246+
'zero-length then all groups are included.'
247+
)
243248
),
244249
label_factor=entity(name='Factor for labels',
245-
description='The column name of sample_meta to use as labels. "rownames" will use the row names from sample_meta.',
250+
description=paste0('The column name of sample_meta to use for ',
251+
'labelling samples on the plot. "rownames" will use the row ',
252+
'names from sample_meta.'),
246253
type='character',
247-
value='rownames'),
254+
value='rownames',
255+
max_length=1),
248256
label_size=entity(name='Text size of labels',
249-
description='The text size of labels. Note this is not in Font Units. Default 3.88.',
257+
description='The text size of labels. Note this is not in Font Units.',
250258
type='numeric',
251-
value=3.88)
259+
value=3.88,
260+
max_length=1)
252261
)
253262
)
254263

255264

256265

266+
257267
#' @importFrom sp point.in.polygon
258268
#' @import ggplot2
259269
#' @importFrom scales squish
@@ -269,7 +279,7 @@ setMethod(f="chart_plot",
269279
}
270280
opt=param_list(obj)
271281
scores=output_value(dobj,'scores')$data
272-
282+
273283
if (length(obj$factor_name)==1) {
274284
shapes = 19 # filled circles for all samples
275285
} else {

0 commit comments

Comments
 (0)