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.



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


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.


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.


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


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



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.


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


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.


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


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


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


Class "Versioned", directly.



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.



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


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.


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


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


Laurent Gatto <>


## 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")
#> [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
#> [1] "[MS, MS:123 , , ]"      "[, , foo, bar]"         "[MS, MS:123, foo, bar]"
#> [4] "[MS, MS:123, , foo]"    "[MS, MS:123, foo, ]"   
#>  [1] "[ , , , ]"         "[, , , ]"          "[ , , ,]"         
#>  [4] "[,,,]"             "[AB, MS:123 , , ]" "[, MS:123 , , ]"  
#>  [7] "[MS, AB:123, , ]"  "[, , foo, ]"       "[, , , bar]"      
#> [10] "[foo, , , ]"       "[, bar, , ]"       "[, foo, bar, ]"   
#> [13] "[MS, , , bar]"     "[MS, , foo, ]"