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 an 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] 35
# turn one into a phenotype object
obj <- as.phenotype(phens[3, "id"])
class(obj)
#> [1] "phenotype" "list"     
obj
#> Phenotype 'anterior margin and (part_of some basihyal bone) straight'
#> Linked to states:
#>                                                                           label
#> 1 anterior edge straight or slightly rounded, with a singular cartilaginous tip
#>   character.label         study.label
#> 1        Basihyal Britz et al. (2014)
#> 
#> Entities:
#>     anatomical structure <http://purl.obolibrary.org/obo/UBERON_0000061>
#> Qualities:
#>     straight <http://purl.obolibrary.org/obo/PATO_0002180>
#> No related entities.
#> 
#> No information about taxa exhibiting this phenotype.

# optionally include taxa exhibiting the phenotype
as.phenotype(phens[3,], withTaxa = TRUE)
#> Phenotype 'anterior margin and (part_of some basihyal bone) straight'
#> Linked to states:
#>                                                                           label
#> 1 anterior edge straight or slightly rounded, with a singular cartilaginous tip
#>   character.label         study.label
#> 1        Basihyal Britz et al. (2014)
#> 
#> Entities:
#>     anatomical structure <http://purl.obolibrary.org/obo/UBERON_0000061>
#> Qualities:
#>     straight <http://purl.obolibrary.org/obo/PATO_0002180>
#> No related entities.
#> Exhibited by taxa:
#>                                           id                        label
#> 1 http://purl.obolibrary.org/obo/VTO_0039086                Abramis brama
#> 2 http://purl.obolibrary.org/obo/VTO_0041012    Acantopsis choirorhynchos
#> 3 http://purl.obolibrary.org/obo/VTO_0062396              Annamia normani
#> 4 http://purl.obolibrary.org/obo/VTO_0039879 Balantiocheilos melanopterus
#> 5 http://purl.obolibrary.org/obo/VTO_0040636                Barbus barbus
#>  [ reached 'max' / getOption("max.print") -- omitted 50 rows ]
# full list of taxa:
as.phenotype(phens[3,], withTaxa = TRUE)$taxa
#>                                            id
#> 1  http://purl.obolibrary.org/obo/VTO_0039086
#> 2  http://purl.obolibrary.org/obo/VTO_0041012
#> 3  http://purl.obolibrary.org/obo/VTO_0062396
#> 4  http://purl.obolibrary.org/obo/VTO_0039879
#> 5  http://purl.obolibrary.org/obo/VTO_0040636
#> 6  http://purl.obolibrary.org/obo/VTO_0040726
#> 7  http://purl.obolibrary.org/obo/VTO_0040723
#> 8  http://purl.obolibrary.org/obo/VTO_0040722
#> 9  http://purl.obolibrary.org/obo/VTO_0064401
#> 10 http://purl.obolibrary.org/obo/VTO_0040725
#> 11 http://purl.obolibrary.org/obo/VTO_0041473
#> 12 http://purl.obolibrary.org/obo/VTO_0041458
#> 13 http://purl.obolibrary.org/obo/VTO_0041127
#> 14 http://purl.obolibrary.org/obo/VTO_0041084
#> 15 http://purl.obolibrary.org/obo/VTO_0039722
#> 16 http://purl.obolibrary.org/obo/VTO_0041429
#> 17 http://purl.obolibrary.org/obo/VTO_0039769
#> 18 http://purl.obolibrary.org/obo/VTO_0064153
#> 19 http://purl.obolibrary.org/obo/VTO_0039822
#> 20 http://purl.obolibrary.org/obo/VTO_0039818
#> 21 http://purl.obolibrary.org/obo/VTO_0040700
#> 22 http://purl.obolibrary.org/obo/VTO_0034769
#> 23 http://purl.obolibrary.org/obo/VTO_0038573
#> 24 http://purl.obolibrary.org/obo/VTO_0063939
#> 25 http://purl.obolibrary.org/obo/VTO_0039003
#> 26 http://purl.obolibrary.org/obo/VTO_0040888
#> 27 http://purl.obolibrary.org/obo/VTO_0040891
#> 28 http://purl.obolibrary.org/obo/VTO_0033674
#> 29 http://purl.obolibrary.org/obo/VTO_0062378
#> 30 http://purl.obolibrary.org/obo/VTO_0040706
#> 31 http://purl.obolibrary.org/obo/VTO_0040978
#> 32 http://purl.obolibrary.org/obo/VTO_0039546
#> 33 http://purl.obolibrary.org/obo/VTO_0041262
#> 34 http://purl.obolibrary.org/obo/VTO_0039669
#> 35 http://purl.obolibrary.org/obo/VTO_0040860
#> 36 http://purl.obolibrary.org/obo/VTO_0040861
#> 37 http://purl.obolibrary.org/obo/VTO_0040819
#> 38 http://purl.obolibrary.org/obo/VTO_0041410
#> 39 http://purl.obolibrary.org/obo/VTO_0040995
#> 40 http://purl.obolibrary.org/obo/VTO_0040430
#> 41 http://purl.obolibrary.org/obo/VTO_0063386
#> 42 http://purl.obolibrary.org/obo/VTO_0084440
#> 43 http://purl.obolibrary.org/obo/VTO_0040301
#> 44 http://purl.obolibrary.org/obo/VTO_0063055
#> 45 http://purl.obolibrary.org/obo/VTO_0038850
#> 46 http://purl.obolibrary.org/obo/VTO_0038848
#> 47 http://purl.obolibrary.org/obo/VTO_0038890
#> 48 http://purl.obolibrary.org/obo/VTO_0038832
#> 49 http://purl.obolibrary.org/obo/VTO_0039902
#> 50 http://purl.obolibrary.org/obo/VTO_0084386
#> 51 http://purl.obolibrary.org/obo/VTO_0039968
#> 52 http://purl.obolibrary.org/obo/VTO_0039075
#> 53 http://purl.obolibrary.org/obo/VTO_0063024
#> 54 http://purl.obolibrary.org/obo/VTO_0041117
#> 55 http://purl.obolibrary.org/obo/VTO_0041119
#>                                      label
#> 1                            Abramis brama
#> 2                Acantopsis choirorhynchos
#> 3                          Annamia normani
#> 4             Balantiocheilos melanopterus
#> 5                            Barbus barbus
#> 6                        Boraras brigittae
#> 7                        Boraras maculatus
#> 8                            Boraras merah
#> 9                           Boraras micros
#> 10                 Boraras urophthalmoides
#> 11                        Carpiodes carpio
#> 12                  Catostomus commersonii
#> 13                Chromobotia macracanthus
#> 14                        Cobitis pacifica
#> 15               Crossocheilus reticulatus
#> 16                     Cycleptus elongatus
#> 17                         Cyprinus carpio
#> 18                     Danio erythromicron
#> 19                      Danio margaritatus
#> 20                             Danio rerio
#> 21                      Danionella dracula
#> 22                    Denticeps clupeoides
#> 23                     Distichodus antonii
#> 24                        Garra dembeensis
#> 25                             Gobio gobio
#> 26                 Gyrinocheilus aymonieri
#> 27                  Gyrinocheilus pennocki
#> 28                        Hiodon alosoides
#> 29                 Homaloptera stephensoni
#> 30                    Horadandia atukorali
#> 31                    Iksookimia koreensis
#> 32                       Labeo longipinnis
#> 33                           Lefua costata
#> 34                          Lobocheilos bo
#> 35                    Microdevario kubotai
#> 36                       Microdevario nana
#> 37                  Microrasbora rubescens
#> 38                  Myxocyprinus asiaticus
#> 39                  Niwaella multifasciata
#> 40                 Notemigonus crysoleucas
#> 41                 Osteochilus vittatoides
#> 42 Paedocypris sp. (Britz and Conway 2009)
#> 43                       Phoxinus phoxinus
#> 44                  Psilorhynchus balitora
#> 45                   Rasbora cephalotaenia
#> 46                     Rasbora kalbarensis
#> 47                    Rasbora vaterifloris
#> 48                        Rhodeus sericeus
#> 49                      Sawbwa resplendens
#> 50                      Sundadanio echinus
#> 51                   Tanichthys micagemmae
#> 52                   Trigonostigma hengeli
#> 53                 Vaillantella euepiptera
#> 54                   Yasuhikotakia modesta
#> 55               Yasuhikotakia sidthimunki

# can also coerce entire list at once
objs <- as.phenotype(phens)
class(objs)
#> [1] "list"
length(objs)
#> [1] 35
all(sapply(objs, is.phenotype))
#> [1] TRUE
objs[[3]]
#> Phenotype 'anterior margin and (part_of some basihyal bone) straight'
#> Linked to states:
#>                                                                           label
#> 1 anterior edge straight or slightly rounded, with a singular cartilaginous tip
#>   character.label         study.label
#> 1        Basihyal Britz et al. (2014)
#> 
#> Entities:
#>     anatomical structure <http://purl.obolibrary.org/obo/UBERON_0000061>
#> Qualities:
#>     straight <http://purl.obolibrary.org/obo/PATO_0002180>
#> No related entities.
#> 
#> No information about taxa exhibiting this phenotype.

# extract character states and (non-redundant) characters
charstates(obj)
#>                                                                     id
#> 1 http://purl.org/phenoscape/uuid/ba9087d5-e51c-4477-8c55-76ca8f4d21d8
#>                                                                           label
#> 1 anterior edge straight or slightly rounded, with a singular cartilaginous tip
#>                                                           character.id
#> 1 http://purl.org/phenoscape/uuid/c6923323-64a4-4b22-97c9-3db01fa90269
#>   character.label                          study.id         study.label
#> 1        Basihyal https://doi.org/10.1111/zoj.12184 Britz et al. (2014)
chars(obj)
#>                                                           character.id
#> 1 http://purl.org/phenoscape/uuid/c6923323-64a4-4b22-97c9-3db01fa90269
#>   character.label                          study.id         study.label
#> 1        Basihyal https://doi.org/10.1111/zoj.12184 Britz et al. (2014)

# IDs that don't resolve still yield an object, but is not valid
suppressWarnings(obj <- as.phenotype("http://foo"))
is.phenotype(obj)
#> [1] TRUE
is_valid_phenotype(obj)
#> [1] FALSE