Term-item associations

term_annotations(dag, terms, return = "list")

annotated_terms(dag, anno, return = "list")

Arguments

dag

An ontology_DAG object.

terms

A vector of term names.

return

Whether the returned object is a list or a matrix?

anno

A vector of annotated item names.

Value

A list or a binary matrix showing annotation relations between terms and items.

Details

If an item is annotated to a term, all this term's ancestor terms are also annotated.

Examples

parents  = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
annotation = list(
    "a" = c("t1", "t2", "t3"),
    "b" = c("t3", "t4"),
    "c" = "t5",
    "d" = "t7",
    "e" = c("t4", "t5", "t6", "t7"),
    "f" = "t8"
)
dag = create_ontology_DAG(parents, children, annotation = annotation)
term_annotations(dag, letters[1:6])
#> $a
#> [1] "t1" "t2" "t3" "t4" "t5" "t7" "t6" "t8"
#> 
#> $b
#> [1] "t3" "t4" "t5" "t7" "t6" "t8"
#> 
#> $c
#> [1] "t4" "t5" "t7" "t6"
#> 
#> $d
#> [1] "t7" "t8"
#> 
#> $e
#> [1] "t4" "t5" "t7" "t6"
#> 
#> $f
#> [1] "t8"
#> 
term_annotations(dag, letters[1:6], return = "matrix")
#>   t1 t2 t3 t4 t5 t7 t6 t8
#> a  1  1  1  1  1  1  1  1
#> b  0  0  1  1  1  1  1  1
#> c  0  0  0  1  1  1  1  0
#> d  0  0  0  0  0  1  0  1
#> e  0  0  0  1  1  1  1  0
#> f  0  0  0  0  0  0  0  1
annotated_terms(dag, c("t1", "t2", "t3"))
#> $t1
#> [1] "a"
#> 
#> $t2
#> [1] "a"
#> 
#> $t3
#> [1] "a" "b"
#> 
annotated_terms(dag, c("t1", "t2", "t3"), return = "matrix")
#>    a b c d e f
#> t1 1 0 0 0 0 0
#> t2 1 0 0 0 0 0
#> t3 1 1 0 0 0 0