as.phenotype creates an object (or a list of objects) of type "phenotype". The object to be coerced can be a character vector (of IRIs), or a data.frame. In the latter case, there must be a column "id" with the IRIs of phenotypes. If the object is already of type "phenotype", it is passed through unchanged.

is.phenotype tests whether an object is of type "phenotype"

is_valid_phenotype tests which of the objects in the list are valid phenotype objects, and returns a logical vector of the same length as x. An object is a valid phenotype object if it is of type "phenotype" and its ID has been found in the database.

charstates extracts the character states from the phenotype object (or an object coercible to phenotype)

chars extracts the (non-redundant) characters from the phenotype object (or an object coercible to phenotype).

print pretty-prints objects of type "phenotype"

as.phenotype(x, withTaxa = FALSE, ...)

# S3 method for data.frame
as.phenotype(x, ...)

is.phenotype(x)

is_valid_phenotype(x)

charstates(x)

chars(x)

# S3 method for phenotype
print(x, ...)

Arguments

x

an object of type "phenotype" or coercible to it, or to be tested for being of type "phenotype"

withTaxa

logical. If TRUE taxa exhibiting the phenotype will be available through the phenotype object at key "taxa". Default is FALSE, because obtaining taxa requires an additional query per object.

...

additional parameters where applicable; ignored for printing

Value

as.phenotype returns and object of type "phenotype", or a list of such objects if the object to be coerced had multiple elements (if a vector) or rows (if a data.frame). A phenotype object has properties "id" (ID, i.e., IRI of the phenotype), "label" (label of the phenotype if one exists), "states" (a data.frame of the character states to which the phenotype is linked, see value for charstates), and "eqs" (the EQ expression components as a list with keys "entities", "qualities", and "related_entities"). If withTaxa is TRUE, there will also be a key "taxa" (a data.frame with columns "id" and "label").

is.phenotype returns TRUE if the object is of type "phenotype" and FALSE otherwise.

is_valid_phenotype returns a logical vector of the same length as the input array of objects, with TRUE for those objects in the list that are of type "phenotype" and correspond to a phenotype in the database.

charstates returns a data.frame. If called with a single phenotype object (or an object that coerces to one), the data.frame has columns "id" and "label" (for the character state), "character.id" and "character.label" (IRI and label of the character), and "study.id" and "study.label" (IRI and short label for the study to which the character and state belong). If called with a list of phenotype objects (or objects that coerce to such a list), the data.frame will include the character states from all phenotypes in the list. In this case, the character state columns will be "state.id" and "state.label", respectively, and there will be two additional columns, "phenotype.id" and "phenotype.label".

chars returns a data.frame with collumns "character.id" and "character.label" (IRI and label of the character), and "study.id" and "study.label" (IRI and short label for the study to which the character and state belong).

Details

Create and test objects of type "phenotype", and extract properties from them.

Examples

# query for a set of phenotypes (IDs and their labels) phens <- get_phenotypes(entity = "basihyal bone") nrow(phens)
#> [1] 20
# turn one into a phenotype object obj <- as.phenotype(phens[3, "id"]) class(obj)
#> [1] "phenotype" "list"
obj
#> Phenotype 'basihyal bone absent' #> Linked to states: #> label character.label study.label #> 1 states 0, 1 and 2 Basihyal Imamura et al. (2005) #> 2 absent (unordered) Basihyal Imamura et al. (2005) #> 3 Absent Basihyal bone Mabee et al. (2011) #> 4 basihyal absent Basihyal De Pinna (1993) #> #> Entities: #> multicellular organism <http://purl.obolibrary.org/obo/UBERON_0000468> #> Qualities: #> lacks all parts of type <http://purl.obolibrary.org/obo/PATO_0002000> #> Towards: #> basihyal bone <http://purl.obolibrary.org/obo/UBERON_0011618> #> #> No information about taxa exhibiting this phenotype.
# optionally include taxa exhibiting the phenotype as.phenotype(phens[3,], withTaxa = TRUE)
#> Phenotype 'basihyal bone absent' #> Linked to states: #> label character.label study.label #> 1 states 0, 1 and 2 Basihyal Imamura et al. (2005) #> 2 absent (unordered) Basihyal Imamura et al. (2005) #> 3 Absent Basihyal bone Mabee et al. (2011) #> 4 basihyal absent Basihyal De Pinna (1993) #> #> Entities: #> multicellular organism <http://purl.obolibrary.org/obo/UBERON_0000468> #> Qualities: #> lacks all parts of type <http://purl.obolibrary.org/obo/PATO_0002000> #> Towards: #> basihyal bone <http://purl.obolibrary.org/obo/UBERON_0011618> #> Exhibited by taxa: #> id label #> 1 http://purl.obolibrary.org/obo/VTO_0035423 Corydoras rabauti #> 2 http://purl.obolibrary.org/obo/VTO_0052870 Enophrys diceraus #> 3 http://purl.obolibrary.org/obo/VTO_0071753 Eumicrotremus asperrimus #> 4 http://purl.obolibrary.org/obo/VTO_0052740 Hemitripterus villosus #> 5 http://purl.obolibrary.org/obo/VTO_0052539 Liparis agassizii #> [ reached 'max' / getOption("max.print") -- omitted 6 rows ]
# full list of taxa: as.phenotype(phens[3,], withTaxa = TRUE)$taxa
#> id label #> 1 http://purl.obolibrary.org/obo/VTO_0035423 Corydoras rabauti #> 2 http://purl.obolibrary.org/obo/VTO_0052870 Enophrys diceraus #> 3 http://purl.obolibrary.org/obo/VTO_0071753 Eumicrotremus asperrimus #> 4 http://purl.obolibrary.org/obo/VTO_0052740 Hemitripterus villosus #> 5 http://purl.obolibrary.org/obo/VTO_0052539 Liparis agassizii #> 6 http://purl.obolibrary.org/obo/VTO_0052645 Malacocottus zonurus #> 7 http://purl.obolibrary.org/obo/VTO_0052708 Marukawichthys ambulator #> 8 http://purl.obolibrary.org/obo/VTO_0035095 Pseudobagrus tokiensis #> 9 http://purl.obolibrary.org/obo/VTO_0052614 Rhamphocottus richardsonii #> 10 http://purl.obolibrary.org/obo/VTO_0034991 Siluriformes #> 11 http://purl.obolibrary.org/obo/VTO_0036124 Silurus glanis
# can also coerce entire list at once objs <- as.phenotype(phens) class(objs)
#> [1] "list"
length(objs)
#> [1] 20
all(sapply(objs, is.phenotype))
#> [1] TRUE
objs[[3]]
#> Phenotype 'basihyal bone absent' #> Linked to states: #> label character.label study.label #> 1 states 0, 1 and 2 Basihyal Imamura et al. (2005) #> 2 absent (unordered) Basihyal Imamura et al. (2005) #> 3 Absent Basihyal bone Mabee et al. (2011) #> 4 basihyal absent Basihyal De Pinna (1993) #> #> Entities: #> multicellular organism <http://purl.obolibrary.org/obo/UBERON_0000468> #> Qualities: #> lacks all parts of type <http://purl.obolibrary.org/obo/PATO_0002000> #> Towards: #> basihyal bone <http://purl.obolibrary.org/obo/UBERON_0011618> #> #> No information about taxa exhibiting this phenotype.
# extract character states and (non-redundant) characters charstates(obj)
#> id #> 1 http://purl.org/phenoscape/uuid/62b5a920-8b49-42be-86f9-baab28a601fc #> 2 http://purl.org/phenoscape/uuid/eb9a3385-bd7f-46a8-ac8f-ac109e8e0e3c #> 3 http://purl.org/phenoscape/uuid/78fa240f-904b-4018-89e9-07c1550539fc #> 4 http://purl.org/phenoscape/uuid/5b7b3d47-890a-4bf7-be90-61417c3d1bf3 #> label #> 1 states 0, 1 and 2 #> 2 absent (unordered) #> 3 Absent #> 4 basihyal absent #> character.id #> 1 http://purl.org/phenoscape/uuid/44a9193e-4da7-45ba-9eae-6ca060579da2 #> 2 http://purl.org/phenoscape/uuid/44a9193e-4da7-45ba-9eae-6ca060579da2 #> 3 http://purl.org/phenoscape/uuid/46cd66db-2454-4304-bf12-9a63aa7421ba #> 4 http://purl.org/phenoscape/uuid/cedb8568-c69e-45b1-907c-d9a0bc677f6e #> character.label study.id #> 1 Basihyal http://dx.doi.org/10.1007/s10228-005-0282-6 #> 2 Basihyal http://dx.doi.org/10.1007/s10228-005-0282-6 #> 3 Basihyal bone http://dx.doi.org/10.11646/zootaxa.2877.1.1 #> 4 Basihyal https://ci.nii.ac.jp/naid/10012505149/ #> study.label #> 1 Imamura et al. (2005) #> 2 Imamura et al. (2005) #> 3 Mabee et al. (2011) #> 4 De Pinna (1993)
chars(obj)
#> character.id #> 1 http://purl.org/phenoscape/uuid/44a9193e-4da7-45ba-9eae-6ca060579da2 #> 3 http://purl.org/phenoscape/uuid/46cd66db-2454-4304-bf12-9a63aa7421ba #> 4 http://purl.org/phenoscape/uuid/cedb8568-c69e-45b1-907c-d9a0bc677f6e #> character.label study.id #> 1 Basihyal http://dx.doi.org/10.1007/s10228-005-0282-6 #> 3 Basihyal bone http://dx.doi.org/10.11646/zootaxa.2877.1.1 #> 4 Basihyal https://ci.nii.ac.jp/naid/10012505149/ #> study.label #> 1 Imamura et al. (2005) #> 3 Mabee et al. (2011) #> 4 De Pinna (1993)
if (FALSE) { # IDs that don't resolve still yield an object, but is not valid obj <- as.phenotype("http://foo") is.phenotype(obj) is_valid_phenotype(obj) }