CVParam objects instantiate controlled vocabulary entries.

CVParam(label, name, accession, value, exact = TRUE)

Objects from the Class

Objects can be created with the CVParam constructor.

Arguments

label

A character with the ontology label. If missing, a user-defined parameter is created.

name

A character with the name of the CVParam to be constructed. This argument can be omitted if accession is used and label is not missing.

accession

A character with the accession of the CVParam to be constructed. This argument can be omitted if name is used. Ignored for user-defined instances.

value

A character with the value of the CVParam to be constructed. This argument is optional.

exact

A logical defining whether the query to retrieve the accession (when name is used) should be an exact match.

Slots

label:

Object of class "character" that defines the label of the instance, i.e the ontology abbreviation/prefix. See Ontologies to generate a list of available ontologies and olsPrefix for existing labels.

accession:

Object of class "character" with the parameter's valid label ontology accession number. See below for validity constrains.

name:

Object of class "character" with the instance's valid name, i.e matching with the accession. name and accession must follow term(accession, label) == name for the instance to be valid.

value:

Object of class "character" with the CVParams value, if applicable, of empty string ("") otherwise.

user:

Object of class "logical" defining if the instance is a user-defined parameter (also called User params).

.__classVersion__:

Object of class "Versions" describing the instance's class definition version. For development use.

Extends

Class "Versioned", directly.

Methods

charIsCVParam(x)

Checks if x, a character of the form "[ONTO, ACCESSION, NAME, VALUE]", is a valid (possibly user-defined) CVParam. "ONTO" is the ontology label (prefi), "ACCESSION" is the term accession number, "NAME" is the term's name and "VALUE" is the value. Note that only syntax validity is verified, not semantics. See example below.

Methods

coerce

signature(from = "CVParam", to = "character"): Coerces CVParam from to a character of the following form: [label, accession, name, value]. as.character is also defined.

coerce

signature(from = "character", to = "CVParam"): Coerces character from to a CVParam. as.CVParam is also defined. If a label is absent, the character is converted to a User param, else, the label and accession are used to query the Ontology Lookup Service (see OlsSearch)). If a name is provided and does not match the retrieved name, a warning is thrown.

This function is vectorised; if the from character is of length greater than 1, then a list of CVParam is returned. The queries to the OLS are processed one-by-one, though.

show

signature(object = "CVParam"): Prints the CVParam instance as text.

rep

signature(x = "CVParam", times = "numeric"): Replicates the CVParam x times times.

Author

Laurent Gatto <lg390@cam.ac.uk>

Examples

## a user param
CVParam(name = "A user param", value = "the value")
#> [, , A user param, the value] 
## a CVParam from PSI's Mass Spectrometry ontology
term("MS", "MS:1000073")
#> A Term from the MS ontology: MS:1000073 
#>  Label: electrospray ionization
#>   A process in which ionized species in the gas phase are produced from
#>   an analyte-containing solution via highly charged fine droplets, by
#>   means of spraying the solution from a narrow-bore needle tip at
#>   atmospheric pressure in the presence of a high electric field. When a
#>   pressurized gas is used to aid in the formation of a stable spray, the
#>   term pneumatically assisted electrospray ionization is used. The term
#>   ion spray is not recommended.
CVParam(label = "MS", accession = "MS:1000073")
#> [MS, MS:1000073, electrospray ionization, ] 

## From a CVParam object to a character
cv <- as(CVParam(label = "MS", accession = "MS:1000073"), "character")
cv
#> [1] "[MS, MS:1000073, electrospray ionization, ]"

## From a character object to a CVParam
as(cv, "CVParam")
#> [MS, MS:1000073, electrospray ionization, ] 
as("[MS, MS:1000073, , ]", "CVParam") ## no name
#> [MS, MS:1000073, electrospray ionization, ] 
as("[MS, MS:1000073, ESI, ]", "CVParam") ## name does not match
#> Warning: The CV names did not match:
#>   Yours: 'ESI' - OLS: 'electrospray ionization'.
#> [MS, MS:1000073, electrospray ionization, ] 
as(c(cv, cv), "CVParam") ## more than 1 character
#> [[1]]
#> [MS, MS:1000073, electrospray ionization, ] 
#> 
#> [[2]]
#> [MS, MS:1000073, electrospray ionization, ] 
#> 

x <- c("[MS, MS:1000073, , ]", ## valid CV param
       "[, , Hello, world]",   ## valid User param
       "[this, one is, not, valid]", ## not valid
       "[ , , , ]") ## not valid

stopifnot(charIsCVParam(x) == c(TRUE, TRUE, FALSE, FALSE))

## A list of expected valid and non-valid entries
rols:::validCVchars
#> [1] "[MS, MS:123 , , ]"      "[, , foo, bar]"         "[MS, MS:123, foo, bar]"
#> [4] "[MS, MS:123, , foo]"    "[MS, MS:123, foo, ]"   
rols:::notvalidCVchars
#>  [1] "[ , , , ]"         "[, , , ]"          "[ , , ,]"         
#>  [4] "[,,,]"             "[AB, MS:123 , , ]" "[, MS:123 , , ]"  
#>  [7] "[MS, AB:123, , ]"  "[, , foo, ]"       "[, , , bar]"      
#> [10] "[foo, , , ]"       "[, bar, , ]"       "[, foo, bar, ]"   
#> [13] "[MS, , , bar]"     "[MS, , foo, ]"