Skip to content

Commit bef6505

Browse files
authored
updated ontology (#38)
- stato now deprecated in favour of ontology - ontology slots added for all struct objects - ontology term and list objects added - can use the rols package and ols api - updated autocomplete for all objects
1 parent 1735f0d commit bef6505

34 files changed

+823
-126
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ LICENSE
1010
^\README.md
1111
.travis.yml
1212
README.rst
13+
^\.github$

DESCRIPTION

Lines changed: 4 additions & 4 deletions
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.5.0
4+
Version: 1.5.1
55
Authors@R: c(
66
person(
77
c("Gavin","Rhys"),
@@ -26,9 +26,9 @@ Description: Defines and includes a set of class-based templates for developing
2626
using the class-based templates.
2727
License: GPL-3
2828
Encoding: UTF-8
29-
LazyData: true
3029
Collate:
3130
'generics.R'
31+
'ontology_term_class.R'
3232
'struct_class.R'
3333
'parameter_class.R'
3434
'chart_class.R'
@@ -61,7 +61,7 @@ Suggests:
6161
ggplot2,
6262
magick
6363
VignetteBuilder: knitr
64-
Imports: methods, ontologyIndex,
64+
Imports: methods,ontologyIndex,
6565
datasets, graphics, stats, utils, knitr,
66-
SummarizedExperiment, S4Vectors
66+
SummarizedExperiment, S4Vectors, rols
6767
biocViews: WorkflowStep

NAMESPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(.DollarNames,chart)
4+
S3method(.DollarNames,model)
5+
S3method(.DollarNames,optimiser)
6+
S3method(.DollarNames,preprocess)
7+
S3method(.DollarNames,resampler)
8+
S3method(.DollarNames,struct_class)
39
export("output_list<-")
410
export("output_value<-")
511
export("param_list<-")
@@ -37,6 +43,9 @@ export(model_seq)
3743
export(model_train)
3844
export(models)
3945
export(new_struct)
46+
export(ontology)
47+
export(ontology_list)
48+
export(ontology_term)
4049
export(optimiser)
4150
export(output_ids)
4251
export(output_list)
@@ -87,6 +96,7 @@ exportMethods("predicted_name<-")
8796
exportMethods("result_name<-")
8897
exportMethods("seq_in<-")
8998
exportMethods("value<-")
99+
exportMethods(.DollarNames)
90100
exportMethods(as.DatasetExperiment)
91101
exportMethods(as.SummarizedExperiment)
92102
exportMethods(as.code)
@@ -106,6 +116,7 @@ exportMethods(model_predict)
106116
exportMethods(model_reverse)
107117
exportMethods(model_train)
108118
exportMethods(models)
119+
exportMethods(ontology)
109120
exportMethods(output_ids)
110121
exportMethods(output_list)
111122
exportMethods(output_name)

R/DatasetExperiment_class.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,4 @@ setMethod(f = "export_xlsx",
226226
openxlsx::write.xlsx(OUT,file = outfile,rowNames = TRUE,colNames = TRUE)
227227
}
228228
)
229+

R/chart_class.R

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ chart = function(...) {
4040
setMethod(f = "chart_plot",
4141
signature = "chart",
4242
definition = function(obj,dobj) {
43-
warning(paste0('no chart defined for "',class(dobj),'"'))
43+
warning('no chart defined for "',class(dobj),'"')
4444
return(obj)
4545
}
4646
)
@@ -52,3 +52,15 @@ setMethod(f = "show",
5252
callNextMethod()
5353
}
5454
)
55+
56+
# autocompletion, return sample_meta column names
57+
#' @export
58+
#' @rdname autocompletion
59+
#' @method .DollarNames chart
60+
.DollarNames.chart <- function(x, pattern = "") {
61+
.DollarNames.struct_class(x,pattern)
62+
}
63+
64+
#' @export
65+
#' @rdname autocompletion
66+
setMethod('.DollarNames','chart',.DollarNames.chart)

R/entity_class.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#' @param obj An entity object
1515
#' @param max_length Maximum length of value vector (default 1)
1616
#' @param value The value of the parameter/outputs
17+
#' @param ... additional inputs to the struct_class object
1718
#' @include generics.R struct_class.R
1819
#' @return An entity object
1920
#' @examples
@@ -29,8 +30,13 @@
2930
#' value(E)
3031
#' value(E) = 10
3132
#' @rdname entity
32-
entity = function(name, description=character(0), type='character',
33-
value=NULL,max_length=Inf) {
33+
entity = function(
34+
name,
35+
description=character(0),
36+
type='character',
37+
value=NULL,
38+
max_length=Inf,
39+
...) {
3440

3541
value=check_init_val(value,type)
3642

@@ -40,7 +46,8 @@ entity = function(name, description=character(0), type='character',
4046
description=description,
4147
type=type,
4248
value=value,
43-
max_length=max_length
49+
max_length=max_length,
50+
...
4451
)
4552
return(out)
4653
}
@@ -54,7 +61,8 @@ entity = function(name, description=character(0), type='character',
5461
description = 'no description provided',
5562
value = character(0),
5663
type = 'character',
57-
max_length = Inf
64+
max_length = Inf,
65+
ontology=character()
5866
),
5967
validity = function(object) {
6068
check_length = length(value(object)) <= max_length(object)

R/enum_class.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#' @inheritParams entity
2929
#' @rdname enum
3030
enum = function(name, description=character(0), type='character',
31-
value=character(0),max_length=1,allowed) {
31+
value=character(0),max_length=1,allowed,...) {
3232

3333
# new object
3434
out = .enum(
@@ -37,7 +37,8 @@ enum = function(name, description=character(0), type='character',
3737
type=type,
3838
value=value,
3939
max_length=max_length,
40-
allowed=allowed
40+
allowed=allowed,
41+
...
4142
)
4243
return(out)
4344
}
@@ -72,7 +73,7 @@ setMethod(f = "value<-",
7273
if (value %in% obj@allowed) {
7374
obj@value = value
7475
} else {
75-
stop(paste0(value,' is not a valid choice for this enum.'))
76+
stop(value,' is not a valid choice for this enum.')
7677
}
7778
return(obj)
7879
}

R/generics.R

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#####################################
23
###### parameter class generics #####
34
#####################################
@@ -632,8 +633,8 @@ setGeneric("as_data_frame",function(M,...)standardGeneric("as_data_frame"))
632633

633634
#' Citations for an object
634635
#'
635-
#' All \code{struct} objects have a "citations" slot, which is a character array of
636-
#' references relevant to the object. The \code{citations} method gathers
636+
#' All \code{struct} objects have a "citations" slot, which is a list of
637+
#' references in bibtex format. The \code{citations} method gathers
637638
#' citations from an object and all \code{struct} objects that it inherits to generate
638639
#' a complete list.
639640
#' @param obj a struct object
@@ -661,3 +662,18 @@ setGeneric("citations",function(obj)standardGeneric("citations"))
661662
#' @export
662663
setGeneric("libraries",function(obj)standardGeneric("libraries"))
663664

665+
#' Ontology for an object
666+
#'
667+
#' All \code{struct} objects have an "ontology" slot, which is a list of
668+
#' ontology items for the object. The \code{ontology} method gathers
669+
#' ontology items from an object and all \code{struct} objects that it inherits to generate
670+
#' a complete list.
671+
#' @param obj a struct object
672+
#' @param cache a named list of ontology_terms for offline use. Terms from the cache are search
673+
#' based on the name of the list items matching the ontology id. If cache=NULL then the OLS API is used to lookup terms.
674+
#' @examples
675+
#' M = example_model()
676+
#' ontology(M,cache=NULL)
677+
#' @rdname ontology
678+
#' @export
679+
setGeneric("ontology",function(obj,cache=NULL)standardGeneric("ontology"))

R/iterator_class.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,5 +276,15 @@ setMethod(f = 'as.code',
276276

277277

278278

279+
# autocompletion, return sample_meta column names
280+
#' @export
281+
#' @method .DollarNames chart
282+
#' @rdname autocompletion
283+
.DollarNames.iterator<- function(x, pattern = "") {
284+
.DollarNames.struct_class(x,pattern)
285+
}
279286

287+
#' @export
288+
#' @rdname autocompletion
289+
setMethod('.DollarNames','iterator',.DollarNames.iterator)
280290

R/metric_class.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,15 @@ setMethod(f = "show",
110110
cat('\n')
111111
}
112112
)
113+
114+
# autocompletion, return sample_meta column names
115+
#' @export
116+
#' @rdname autocompletion
117+
#' @method .DollarNames chart
118+
.DollarNames.metric<- function(x, pattern = "") {
119+
.DollarNames.struct_class(x,pattern)
120+
}
121+
122+
#' @export
123+
#' @rdname autocompletion
124+
setMethod('.DollarNames','metric',.DollarNames.metric)

0 commit comments

Comments
 (0)