Skip to content

Commit 10eda8c

Browse files
committed
update news and description
+ version bump for Bioc + remove some unnecessary whitespace from some R files
1 parent fcb8b2d commit 10eda8c

File tree

5 files changed

+176
-162
lines changed

5 files changed

+176
-162
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: struct
22
Type: Package
33
Title: Statistics in R Using Class-based Templates
4-
Version: 1.15.1
4+
Version: 1.15.2
55
Authors@R: c(
66
person(
77
c("Gavin","Rhys"),

NEWS

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Changes 1.15.2
2+
+ add ellipsis to model methods
3+
4+
Changes 1.15.1
5+
+ remove duplicates when using param_ids for objects with inherited params
6+
+ set check.names = FALSE in DatasetExperiment
7+
18
Changes 1.7.1
29
+ fix as.code generic
310
+ improve as.code for all objects
@@ -11,6 +18,7 @@ Changes in 1.5.2
1118
Changes in 1.1.2
1219
+ improved 'show' output for objects
1320
+ allow ANY for entities
21+
1422
Changes in 1.1.1
1523
+ added citations slot to struct classes
1624
+ added corresponding citations method
@@ -27,7 +35,7 @@ Changes in 0.99.10
2735
+ add 'signature' input to struct_obj_method
2836

2937
Changes in 0.99.9
30-
+ subsetting of iterators with a single model now converts to a model sequence
38+
+ subsetting of iterators with a single model now converts to a model sequence
3139
with 1 step
3240

3341
Changes in 0.99.8

R/generics.R

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @rdname param_obj
2626
setGeneric("param_obj",function(obj,name)standardGeneric("param_obj"))
2727

28-
#' @rdname param_obj
28+
#' @rdname param_obj
2929
#' @export
3030
setGeneric("param_obj<-",function(obj,name,value)standardGeneric("param_obj<-"))
3131

@@ -77,14 +77,14 @@ setGeneric("param_name",function(obj,name)standardGeneric("param_name"))
7777
#' @examples
7878
#' M = example_model()
7979
#' L = param_list(M)
80-
#'
80+
#'
8181
#' M = example_model()
8282
#' param_list(M) = list('value_1' = 15,'value_2' = 20)
8383
#' @export
8484
#' @rdname param_list
8585
setGeneric("param_list",function(obj)standardGeneric("param_list"))
8686

87-
#' @rdname param_list
87+
#' @rdname param_list
8888
#' @export
8989
setGeneric("param_list<-",function(obj,value)standardGeneric("param_list<-"))
9090

@@ -98,15 +98,15 @@ setGeneric("param_list<-",function(obj,value)standardGeneric("param_list<-"))
9898
#' @examples
9999
#' M = example_model()
100100
#' param_value(M,'value_1')
101-
#'
101+
#'
102102
#' M = example_model()
103103
#' param_value(M,'value_1') = 0.95
104-
#'
104+
#'
105105
#' @export
106106
#' @rdname param_value
107107
setGeneric("param_value",function(obj,name)standardGeneric("param_value"))
108108

109-
#' @rdname param_value
109+
#' @rdname param_value
110110
#' @export
111111
setGeneric("param_value<-",
112112
function(obj,name,value)standardGeneric("param_value<-"))
@@ -234,7 +234,7 @@ setGeneric("output_list<-",function(obj,value)standardGeneric("output_list<-"))
234234
#' type as an input.
235235
#'
236236
#' @param obj An object derived from the struct_class object
237-
#' @param ret A string indicating whether a list of objects ('obj') or a list of chart
237+
#' @param ret A string indicating whether a list of objects ('obj') or a list of chart
238238
#' names ('char') is returned. 'char' is default.
239239
#' @return list of chart names, or a list of chart objects
240240
#' @examples
@@ -248,8 +248,8 @@ setGeneric("chart_names",function(obj,ret='char')standardGeneric("chart_names"))
248248
#' chart_plot
249249
#'
250250
#' Plots a chart object
251-
#'
252-
#' The optional optional inputs depend on the input object/chart, but might
251+
#'
252+
#' The optional optional inputs depend on the input object/chart, but might
253253
#' include an additional dataset object or a second model object, for example.
254254
#' @param obj A chart object
255255
#' @param dobj An object derived from struct_class
@@ -273,54 +273,58 @@ setGeneric("chart_plot",function(obj, dobj, ...)standardGeneric("chart_plot"))
273273
#' Applies a method to the input dataset
274274
#' @param M a `method` object
275275
#' @param D another object used by the first
276+
#' @param ... other optional inputs
276277
#' @return Returns a modified method object
277278
#' @rdname model_apply
278279
#' @examples
279280
#' M = example_model()
280281
#' M = model_apply(M,iris_DatasetExperiment())
281282
#' @export
282-
setGeneric("model_apply",function(M,D)standardGeneric("model_apply"))
283+
setGeneric("model_apply",function(M,D,...)standardGeneric("model_apply"))
283284

284285

285286
#' Train a model
286287
#'
287288
#' Trains a model using the input dataset
288289
#' @param M a model object
289290
#' @param D a dataset object
291+
#' @param ... other optional inputs
290292
#' @return Returns a modified model object
291293
#' @rdname train
292294
#' @examples
293295
#' M = example_model()
294296
#' M = model_train(M,iris_DatasetExperiment())
295297
#' @export
296-
setGeneric("model_train",function(M,D)standardGeneric("model_train"))
298+
setGeneric("model_train",function(M,D,...)standardGeneric("model_train"))
297299

298300
#' Model prediction
299301
#'
300302
#' Apply a model using the input dataset. Assumes the model is trained
301303
#' first.
302304
#' @param M a model object
303305
#' @param D a dataset object
306+
#' @param ... other optional inputs
304307
#' @return Returns a modified model object
305308
#' @rdname predict
306309
#' @examples
307310
#' M = example_model()
308311
#' M = model_predict(M,iris_DatasetExperiment())
309312
#' @export
310-
setGeneric("model_predict",function(M,D)standardGeneric("model_predict"))
313+
setGeneric("model_predict",function(M,D,...)standardGeneric("model_predict"))
311314

312315
#' Reverse preprocessing
313316
#'
314317
#' Reverse the effect of a preprocessing step on a dataset_
315318
#' @param M a model object
316319
#' @param D a dataset object
320+
#' @param ... other optional inputs
317321
#' @return Returns a modified dataset object
318322
#' @rdname model_reverse
319323
#' @examples
320324
#' M = example_model()
321325
#' D = model_reverse(M,iris_DatasetExperiment())
322326
#' @export
323-
setGeneric("model_reverse",function(M,D)standardGeneric("model_reverse"))
327+
setGeneric("model_reverse",function(M,D,...)standardGeneric("model_reverse"))
324328

325329
#' Predicted output name
326330
#'
@@ -347,16 +351,16 @@ setGeneric("predicted_name<-",
347351

348352
#' Sequence input
349353
#'
350-
#' get/set the input parameter replaced by the output of the previous model in
354+
#' get/set the input parameter replaced by the output of the previous model in
351355
#' a model sequence. Default is "data" which passes the output as the data input
352356
#' for methods such as \code{model_train} and \code{model_apply}.
353357
#' @param M a model object
354358
#' @param value name of an output for this model
355359
#' @return
356360
#' \describe{
357-
#' \item{\code{seq_in}}{returns the name of the input parameter replaced
361+
#' \item{\code{seq_in}}{returns the name of the input parameter replaced
358362
#' when used in a model sequence}
359-
#' \item{\code{seq_in<-}}{sets the name of the input parameter replaced
363+
#' \item{\code{seq_in<-}}{sets the name of the input parameter replaced
360364
#' when used in a model sequence}
361365
#' }
362366
#' @rdname seq_in
@@ -584,8 +588,8 @@ setGeneric("stato_definition",function(obj)standardGeneric("stato_definition"))
584588
setGeneric("stato_summary",function(obj)standardGeneric("stato_summary"))
585589

586590
#' Convert a DatasetExperiment to a SummarizedExperiment
587-
#'
588-
#' Converts a DatasetExperiment to SummarizedExperiment. The assay data is
591+
#'
592+
#' Converts a DatasetExperiment to SummarizedExperiment. The assay data is
589593
#' transposed, and colData and rowData switched to match. struct specific
590594
#' slots such as "name" and "description" are stored in the metaData.
591595
#' @param obj a DatasetExperiment object
@@ -594,8 +598,8 @@ setGeneric("stato_summary",function(obj)standardGeneric("stato_summary"))
594598
setGeneric("as.SummarizedExperiment",function(obj)standardGeneric("as.SummarizedExperiment"))
595599

596600
#' Convert a SummarizedExperiment to DatasetExperiment
597-
#'
598-
#' Converts a SummarizedExperiment to DatasetExperiment. The assay data is
601+
#'
602+
#' Converts a SummarizedExperiment to DatasetExperiment. The assay data is
599603
#' transposed, and colData and rowData switched to match. struct specific
600604
#' slots such as "name" and "description" are extracted from the metaData.
601605
#' @param obj a SummarizedExperiment object
@@ -604,9 +608,9 @@ setGeneric("as.SummarizedExperiment",function(obj)standardGeneric("as.Summarized
604608
setGeneric("as.DatasetExperiment",function(obj)standardGeneric("as.DatasetExperiment"))
605609

606610
#' Convert to code
607-
#'
611+
#'
608612
#' Prints a block of code that can be used to replicate the input object.
609-
#'
613+
#'
610614
#' @param M a struct model, model_seq or iterator object
611615
#' @param start text prepended to the code. Default is "M = "
612616
#' @param mode "compact" will use the least amount of lines, "expanded" will
@@ -616,15 +620,15 @@ setGeneric("as.DatasetExperiment",function(obj)standardGeneric("as.DatasetExperi
616620
#' @return A string of code to reproduce the input object.
617621
#' @export
618622
#' @rdname as.code
619-
#' @examples
623+
#' @examples
620624
#' M = example_model(value_1 = 10)
621625
#' as.code(M)
622626
setGeneric('as.code',function(M,start='M = ',mode='compact',quiet=FALSE)standardGeneric("as.code"))
623627

624628
#' convert to data.frame
625629
#'
626630
#' Most often used with univariate statistics to gather all the different outputs in a consistent format.
627-
#'
631+
#'
628632
#' @param M a struct object
629633
#' @param ... other inputs passed through this function
630634
#' @return a data.frame containing outputs from an object
@@ -633,14 +637,14 @@ setGeneric("as_data_frame",function(M,...)standardGeneric("as_data_frame"))
633637

634638

635639
#' Citations for an object
636-
#'
640+
#'
637641
#' All \code{struct} objects have a "citations" slot, which is a list of
638642
#' references in bibtex format. The \code{citations} method gathers
639643
#' citations from an object and all \code{struct} objects that it inherits to generate
640644
#' a complete list.
641645
#' @param obj a struct object
642646
#' @return a character array of citations
643-
#' @examples
647+
#' @examples
644648
#' D = iris_DatasetExperiment()
645649
#' D$citations # the list specifically defined for this object
646650
#' citations(D) # the list for this object and all inherited ones
@@ -649,30 +653,30 @@ setGeneric("as_data_frame",function(M,...)standardGeneric("as_data_frame"))
649653
setGeneric("citations",function(obj)standardGeneric("citations"))
650654

651655
#' Libraries for an object
652-
#'
656+
#'
653657
#' All \code{struct} objects have a "libraries" slot, which is a character array of
654658
#' libraries required to use the object. The \code{libraries} method gathers
655659
#' libraries from an object and all \code{struct} objects that it inherits to generate
656660
#' a complete list.
657661
#' @param obj a struct object
658662
#' @return a character array of R packages needed by the object
659-
#' @examples
663+
#' @examples
660664
#' M = example_model()
661665
#' libraries(M)
662666
#' @rdname libraries
663667
#' @export
664668
setGeneric("libraries",function(obj)standardGeneric("libraries"))
665669

666670
#' Ontology for an object
667-
#'
671+
#'
668672
#' All \code{struct} objects have an "ontology" slot, which is a list of
669673
#' ontology items for the object. The \code{ontology} method gathers
670674
#' ontology items from an object and all \code{struct} objects that it inherits to generate
671675
#' a complete list.
672676
#' @param obj a struct object
673-
#' @param cache a named list of ontology_terms for offline use. Terms from the cache are search
677+
#' @param cache a named list of ontology_terms for offline use. Terms from the cache are search
674678
#' based on the name of the list items matching the ontology id. If cache=NULL then the OLS API is used to lookup terms.
675-
#' @examples
679+
#' @examples
676680
#' M = example_model()
677681
#' ontology(M,cache=NULL)
678682
#' @rdname ontology

R/model_class.R

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
#' Also used for preprocessing steps that require application to test sets.
55
#' not intended to be called directly, this class should be inherited to provide
66
#' functionality for method-specific classes.
7-
#'
7+
#'
88
#' @section \code{predicted} slot:
99
#' The "predicted" slot is a slots for use by users to control the flow of model
1010
#' sequences. The \code{predicted()} function is used to return a default output and
1111
#' from a model. Typically it is a DatasetExperiment object that is passed directly
1212
#' into the next model in a sequence as the data for that model.
13-
#'
13+
#'
1414
#' @section \code{seq_in} slot:
15-
#' In a sequence of models (see model_seq) the "predicted" slot is connected to the
15+
#' In a sequence of models (see model_seq) the "predicted" slot is connected to the
1616
#' DatasetExperiment input of the next model. \code{seq_in} can be used to control
1717
#' flow and connect the "predicted" output to the input parameter of the next model.
18-
#' Default is the keyword 'data', and can otherwise be replaced by any input slot
19-
#' from the model. The slot \code{seq_fcn} can be used to apply a transformation to
18+
#' Default is the keyword 'data', and can otherwise be replaced by any input slot
19+
#' from the model. The slot \code{seq_fcn} can be used to apply a transformation to
2020
#' the output before it is used as an input. This allows you to e.g. convert between types,
2121
#' extract a single column from a data.frame etc.
22-
#'
23-
#'
22+
#'
23+
#'
2424
#' @export model
2525
#' @param M A struct model object
2626
#' @param D A DatasetExperiment object
27-
#' @param value The value to assign
27+
#' @param value The value to assign
2828
#' @param predicted The name of an output slot to return when using \code{predicted()} (see details)
29-
#' @param seq_in the name of an output slot to connect with the "predicted" output
29+
#' @param seq_in the name of an output slot to connect with the "predicted" output
3030
#' of another model (see details)
31-
#' @param seq_fcn a function to apply to seq_in before inputting into the next model.
31+
#' @param seq_fcn a function to apply to seq_in before inputting into the next model.
3232
#' Typically used to extract a single column, or convert from factor to char etc.
3333
#' @include generics.R parameter_class.R output_class.R
3434
#' @examples
@@ -144,12 +144,12 @@ setMethod(f = 'predicted',
144144
if (is.null(predicted_name(M))) {
145145
warning('"predicted" is set to NULL')
146146
return(NA)
147-
147+
148148
}
149149
# we can try to return the slot
150150
return(output_value(M,predicted_name(M)))
151151
}
152-
152+
153153
)
154154

155155
#' @rdname model
@@ -158,16 +158,16 @@ setMethod(f = 'predicted',
158158
#' D = DatasetExperiment()
159159
#' M = example_model()
160160
#' seq_in(M) = 'data'
161-
#' @return the id of the input parameter to be replaced by the \code{predicted}
162-
#' output of the previous model in a model sequence. Reserved keyword 'data'
163-
#' means that the input data used by \code{model_train}, \code{model_apply} etc is used.
164-
#' \code{seq_in = 'data'} is the default setting.
161+
#' @return the id of the input parameter to be replaced by the \code{predicted}
162+
#' output of the previous model in a model sequence. Reserved keyword 'data'
163+
#' means that the input data used by \code{model_train}, \code{model_apply} etc is used.
164+
#' \code{seq_in = 'data'} is the default setting.
165165
setMethod(f = 'seq_in',
166166
signature = c('model'),
167167
definition = function(M) {
168168
return(M@seq_in)
169169
}
170-
170+
171171
)
172172

173173
#' @rdname model
@@ -242,7 +242,7 @@ setMethod(f = "show",
242242
.DollarNames.struct_class(x,pattern)
243243
}
244244

245-
#' @export
245+
#' @export
246246
#' @rdname autocompletion
247247
setMethod('.DollarNames','model',.DollarNames.model)
248248

0 commit comments

Comments
 (0)