Load from Cache, Update if New Lineages Found or Create Cache if Missing
- Cache is written to a basic ‘rda’ file in the user’s local AppData directory
- Will not overwrite cache if update has no new lineages compared to cache
- The force argument forcibly returns the lineages in the file specified regardless of how it compares to the cache
- Can supply either
lineages_url
oraliases_url
to target specific files withupdateHierarchies()
- checkCache returns a table of lineage hierarchies by default or a
data.tree network with
network = TRUE
Table
library(CCT)
# Grab an older version
cachedat <- checkCache(lineages_url = "https://raw.githubusercontent.com/cov-lineages/pango-designation/4b5957e151c10e92cb49e9df904c0b2ea841f3eb/lineage_notes.txt")
## Getting new cache file data and preparing to write ~/.local/share/CCT/cct_cache.rda
## Writing ~/.local/share/CCT/cct_cache.rda with lineage hierarchy table
## Returning lineage hierarchies as...
## Table
head(cachedat)
## lineage parent children
## 1 A <NA> A
## 35 A.1 A A.1
## 3 A <NA> A.1
## 41 A.2 A A.2
## 5 A <NA> A.2
## 44 A.2.2 A.2 A.2.2
# how many lineages?
nrow(cachedat)
## [1] 11087
# Grab latest version
cachedat <- checkCache()
## Loading and checking cache file: ~/.local/share/CCT/cct_cache.rda
## Check current status of remote files
## Joining with `by = join_by(lineage, parent, children)`
## Lineages list differs from cached, updating lineage hierarchies
## 14178
## Overwriting ~/.local/share/CCT/cct_cache.rda with new lineage hierarchies
## Returning lineage hierarchies as...
## Table
# how many lineages?
nrow(cachedat)
## [1] 25245
Network
cachedatNET <- checkCache(network = TRUE)
## Loading and checking cache file: ~/.local/share/CCT/cct_cache.rda
## Check current status of remote files
## Joining with `by = join_by(lineage, parent, children)`
## Returning lineage hierarchies as...
## Network
## Joining with `by = join_by(lineage, parent)`
Run All in One Line
# In case newest version breaks use: lineages_url = "https://raw.githubusercontent.com/TheZetner/pango-designation/master/lineage_notes.txt"
hierarchy <-
CCT::updateHierarchies() %>% CCT::fromDFtoNetwork()
## Joining with `by = join_by(lineage, parent)`
hierarchy
## $network
## levelName
## 1 MRCA
## 2 ¦--A
## 3 ¦ ¦--A.1
## 4 ¦ ¦--A.2
## 5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--B.1.1.5
## 90 ¦ ¦ ¦ ¦--B.1.1.7
## 91 ¦ ¦ ¦ ¦ ¦--Q.1
## 92 ¦ ¦ ¦ ¦ ¦--Q.2
## 93 ¦ ¦ ¦ ¦ ¦--Q.3
## 94 ¦ ¦ ¦ ¦ ¦--Q.4
## 95 ¦ ¦ ¦ ¦ ¦--Q.5
## 96 ¦ ¦ ¦ ¦ ¦--Q.6
## 97 ¦ ¦ ¦ ¦ ¦--Q.7
## 98 ¦ ¦ ¦ ¦ °--Q.8
## 99 ¦ ¦ ¦ ¦--B.1.1.8
## 100 ¦ ¦ ¦ °--... 402 nodes w/ 1467 sub
## 101 ¦ ¦ °--... 455 nodes w/ 2363 sub
## 102 ¦ °--... 46 nodes w/ 2833 sub
## 103 °--... 117 nodes w/ 3917 sub
##
## $orphans
## [1] lineage parent
## <0 rows> (or 0-length row.names)
Update Hierarchies
- Lineages: https://github.com/cov-lineages/pango-designation/blob/master/lineage_notes.txt
- Aliases: https://github.com/cov-lineages/pango-designation/blob/master/pango_designation/alias_key.json
- Can supply a specific local file or version of the files above
- Reports which file failed if one does
- Returns a table of Parent/Lineage/Children
l <- CCT::updateHierarchies(lineages_url = "https://raw.githubusercontent.com/TheZetner/pango-designation/master/lineage_notes.txt")
head(l)
## lineage parent children
## 1 A <NA> A
## 35 A.1 A A.1
## 3 A <NA> A.1
## 41 A.2 A A.2
## 5 A <NA> A.2
## 44 A.2.2 A.2 A.2.2
From Dataframe to Network
- Take the dataframe from
updateHierarchies()
orcheckCache(network = FALSE)
and build a node network using data.tree - Defines the parent-child relationship between each node (lineage)
- Also returns a table of “orphan” lineages that are missing parents in the table as these break the network and are removed
- Can replace
ll$network
withcachedatNET
from above
ll <- fromDFtoNetwork(l)
## Joining with `by = join_by(lineage, parent)`
ll
## $network
## levelName
## 1 MRCA
## 2 ¦--A
## 3 ¦ ¦--A.1
## 4 ¦ ¦--A.2
## 5 ¦ ¦ ¦--A.2.2
## 6 ¦ ¦ ¦--A.2.3
## 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 ¦ ¦ ¦ ¦--Q.1
## 92 ¦ ¦ ¦ ¦ ¦--Q.2
## 93 ¦ ¦ ¦ ¦ ¦--Q.3
## 94 ¦ ¦ ¦ ¦ ¦--Q.4
## 95 ¦ ¦ ¦ ¦ ¦--Q.5
## 96 ¦ ¦ ¦ ¦ ¦--Q.6
## 97 ¦ ¦ ¦ ¦ ¦--Q.7
## 98 ¦ ¦ ¦ ¦ °--Q.8
## 99 ¦ ¦ ¦ ¦--B.1.1.8
## 100 ¦ ¦ ¦ °--... 402 nodes w/ 1087 sub
## 101 ¦ ¦ °--... 455 nodes w/ 1984 sub
## 102 ¦ °--... 46 nodes w/ 2454 sub
## 103 °--... 76 nodes w/ 3089 sub
##
## $orphans
## [1] lineage parent
## <0 rows> (or 0-length row.names)
Pull all the Ancestors of a Node
Network
ancestors <- pullAncestors(ll$network, "BA.5.2", table = FALSE)
# ancestors <- pullAncestors(cachedatNET, "BA.5.2", table = FALSE)
ancestors
## levelName
## 1 MRCA
## 2 °--B
## 3 °--B.1
## 4 °--B.1.1
## 5 °--B.1.1.529
## 6 °--BA.5
## 7 °--BA.5.2
Table
ancestors <- pullAncestors(ll$network, "BA.5.2", table = TRUE)
ancestors
## levelName level lineage
## 1 MRCA 1 NA
## 2 °--B 2 NA
## 3 °--B.1 3 NA
## 4 °--B.1.1 4 NA
## 5 °--B.1.1.529 5 NA
## 6 °--BA.5 6 NA
## 7 °--BA.5.2 7 NA
Vector
# vector supersedes table param
ancestors <- pullAncestors(ll$network, "BA.5.2", table = TRUE, vector = TRUE)
ancestors
## [1] "MRCA" "B" "B.1" "B.1.1" "B.1.1.529" "BA.5"
## [7] "BA.5.2"
Get all the Descendants of a Node
Network
getDescendants(ll$network, "BF.7", table = FALSE) %>% plot()
Table
getDescendants(ll$network, "BF.7", table = TRUE)
## levelName level lineage
## 1 BF.7 1 BF.7
## 2 ¦--BF.7.1 2 BF.7.1
## 3 ¦--BF.7.2 2 BF.7.2
## 4 ¦--BF.7.3 2 BF.7.3
## 5 ¦--BF.7.4 2 BF.7.4
## 6 ¦ ¦--BF.7.4.1 3 BF.7.4.1
## 7 ¦ ¦--BF.7.4.2 3 BF.7.4.2
## 8 ¦ °--BF.7.4.3 3 BF.7.4.3
## 9 ¦--BF.7.5 2 BF.7.5
## 10 ¦ °--BF.7.5.1 3 BF.7.5.1
## 11 ¦--BF.7.6 2 BF.7.6
## 12 ¦--BF.7.7 2 BF.7.7
## 13 ¦--BF.7.8 2 BF.7.8
## 14 ¦--BF.7.9 2 BF.7.9
## 15 ¦--BF.7.10 2 BF.7.10
## 16 ¦--BF.7.11 2 BF.7.11
## 17 ¦--BF.7.12 2 BF.7.12
## 18 ¦--BF.7.13 2 BF.7.13
## 19 ¦ ¦--BF.7.13.1 3 BF.7.13.1
## 20 ¦ °--BF.7.13.2 3 BF.7.13.2
## 21 ¦--BF.7.14 2 BF.7.14
## 22 ¦ ¦--BF.7.14.1 3 BF.7.14.1
## 23 ¦ ¦--BF.7.14.2 3 BF.7.14.2
## 24 ¦ ¦--BF.7.14.3 3 BF.7.14.3
## 25 ¦ ¦--BF.7.14.4 3 BF.7.14.4
## 26 ¦ ¦--BF.7.14.5 3 BF.7.14.5
## 27 ¦ ¦--BF.7.14.6 3 BF.7.14.6
## 28 ¦ °--BF.7.14.7 3 BF.7.14.7
## 29 ¦--BF.7.15 2 BF.7.15
## 30 ¦--BF.7.16 2 BF.7.16
## 31 ¦ °--BF.7.16.1 3 BF.7.16.1
## 32 ¦--BF.7.17 2 BF.7.17
## 33 ¦--BF.7.18 2 BF.7.18
## 34 ¦--BF.7.19 2 BF.7.19
## 35 ¦ °--BF.7.19.1 3 BF.7.19.1
## 36 ¦--BF.7.20 2 BF.7.20
## 37 ¦--BF.7.21 2 BF.7.21
## 38 ¦--BF.7.22 2 BF.7.22
## 39 ¦--BF.7.23 2 BF.7.23
## 40 ¦--BF.7.24 2 BF.7.24
## 41 ¦--BF.7.26 2 BF.7.26
## 42 °--BF.7.27 2 BF.7.27
Vector
# vector supersedes table param
getDescendants(ll$network, "BF.7", table = TRUE, vector = TRUE)
## [1] "BF.7" "BF.7.1" "BF.7.2" "BF.7.3" "BF.7.4" "BF.7.4.1"
## [7] "BF.7.4.2" "BF.7.4.3" "BF.7.5" "BF.7.5.1" "BF.7.6" "BF.7.7"
## [13] "BF.7.8" "BF.7.9" "BF.7.10" "BF.7.11" "BF.7.12" "BF.7.13"
## [19] "BF.7.13.1" "BF.7.13.2" "BF.7.14" "BF.7.14.1" "BF.7.14.2" "BF.7.14.3"
## [25] "BF.7.14.4" "BF.7.14.5" "BF.7.14.6" "BF.7.14.7" "BF.7.15" "BF.7.16"
## [31] "BF.7.16.1" "BF.7.17" "BF.7.18" "BF.7.19" "BF.7.19.1" "BF.7.20"
## [37] "BF.7.21" "BF.7.22" "BF.7.23" "BF.7.24" "BF.7.26" "BF.7.27"
Make YAML Watchlist (for Augur)
getDescendants(ll$network, "BF.7", vector = TRUE) %>% makeWatchlist()
## [1] "[ 'BF.7', 'BF.7.1', 'BF.7.2', 'BF.7.3', 'BF.7.4', 'BF.7.4.1', 'BF.7.4.2', 'BF.7.4.3', 'BF.7.5', 'BF.7.5.1', 'BF.7.6', 'BF.7.7', 'BF.7.8', 'BF.7.9', 'BF.7.10', 'BF.7.11', 'BF.7.12', 'BF.7.13', 'BF.7.13.1', 'BF.7.13.2', 'BF.7.14', 'BF.7.14.1', 'BF.7.14.2', 'BF.7.14.3', 'BF.7.14.4', 'BF.7.14.5', 'BF.7.14.6', 'BF.7.14.7', 'BF.7.15', 'BF.7.16', 'BF.7.16.1', 'BF.7.17', 'BF.7.18', 'BF.7.19', 'BF.7.19.1', 'BF.7.20', 'BF.7.21', 'BF.7.22', 'BF.7.23', 'BF.7.24', 'BF.7.26', 'BF.7.27' ]"
Download Variants table from CoVariants
vars <- getVariants()
vars
## # A tibble: 37 × 3
## lineage clade who
## <chr> <chr> <chr>
## 1 B.1.1.7 20I (Alpha, V1) Alpha
## 2 B.1.351 20H (Beta, V2) Beta
## 3 P.1 20J (Gamma, V3) Gamma
## 4 B.1.617.2 21A (Delta) Delta
## 5 B.1.617.1 21B (Kappa) Kappa
## 6 B.1.427 21C (Epsilon) Epsilon
## 7 B.1.429 21C (Epsilon) Epsilon
## 8 B.1.525 21D (Eta) Eta
## 9 B.1.526 21F (Iota) Iota
## 10 C.37 21G (Lambda) Lambda
## # ℹ 27 more rows
Expand Variants Table to Include all Children
expandChildren(head(vars), ll$network)
## Joining with `by = join_by(lineage)`
## lineage child clade who
## 1 B.1.1.7 B.1.1.7 20I (Alpha, V1) Alpha
## 2 B.1.1.7 Q.1 20I (Alpha, V1) Alpha
## 3 B.1.1.7 Q.2 20I (Alpha, V1) Alpha
## 4 B.1.1.7 Q.3 20I (Alpha, V1) Alpha
## 5 B.1.1.7 Q.4 20I (Alpha, V1) Alpha
## 6 B.1.1.7 Q.5 20I (Alpha, V1) Alpha
## 7 B.1.1.7 Q.6 20I (Alpha, V1) Alpha
## 8 B.1.1.7 Q.7 20I (Alpha, V1) Alpha
## 9 B.1.1.7 Q.8 20I (Alpha, V1) Alpha
## 10 B.1.351 B.1.351 20H (Beta, V2) Beta
## 11 B.1.351 B.1.351.1 20H (Beta, V2) Beta
## 12 B.1.351 B.1.351.2 20H (Beta, V2) Beta
## 13 B.1.351 B.1.351.3 20H (Beta, V2) Beta
## 14 B.1.351 B.1.351.5 20H (Beta, V2) Beta
## 15 P.1 P.1 20J (Gamma, V3) Gamma
## 16 P.1 P.1.1 20J (Gamma, V3) Gamma
## 17 P.1 P.1.2 20J (Gamma, V3) Gamma
## 18 P.1 P.1.3 20J (Gamma, V3) Gamma
## 19 P.1 P.1.4 20J (Gamma, V3) Gamma
## 20 P.1 P.1.5 20J (Gamma, V3) Gamma
## 21 P.1 P.1.6 20J (Gamma, V3) Gamma
## 22 P.1 P.1.7 20J (Gamma, V3) Gamma
## 23 P.1 P.1.7.1 20J (Gamma, V3) Gamma
## 24 P.1 P.1.8 20J (Gamma, V3) Gamma
## 25 P.1 P.1.9 20J (Gamma, V3) Gamma
## 26 P.1 P.1.10 20J (Gamma, V3) Gamma
## 27 P.1 P.1.10.1 20J (Gamma, V3) Gamma
## 28 P.1 P.1.10.2 20J (Gamma, V3) Gamma
## 29 P.1 P.1.11 20J (Gamma, V3) Gamma
## 30 P.1 P.1.12 20J (Gamma, V3) Gamma
## 31 P.1 P.1.12.1 20J (Gamma, V3) Gamma
## 32 P.1 P.1.13 20J (Gamma, V3) Gamma
## 33 P.1 P.1.14 20J (Gamma, V3) Gamma
## 34 P.1 P.1.15 20J (Gamma, V3) Gamma
## 35 P.1 P.1.16 20J (Gamma, V3) Gamma
## 36 P.1 P.1.17 20J (Gamma, V3) Gamma
## 37 P.1 P.1.17.1 20J (Gamma, V3) Gamma
## 38 B.1.617.2 B.1.617.2 21A (Delta) Delta
## 39 B.1.617.2 AY.1 21A (Delta) Delta
## 40 B.1.617.2 AY.2 21A (Delta) Delta
## 41 B.1.617.2 AY.3 21A (Delta) Delta
## 42 B.1.617.2 AY.3.1 21A (Delta) Delta
## 43 B.1.617.2 AY.3.2 21A (Delta) Delta
## 44 B.1.617.2 AY.3.3 21A (Delta) Delta
## 45 B.1.617.2 AY.3.4 21A (Delta) Delta
## 46 B.1.617.2 AY.3.5 21A (Delta) Delta
## 47 B.1.617.2 AY.4 21A (Delta) Delta
## 48 B.1.617.2 AY.4.1 21A (Delta) Delta
## 49 B.1.617.2 AY.4.2 21A (Delta) Delta
## 50 B.1.617.2 AY.4.2.1 21A (Delta) Delta
## 51 B.1.617.2 AY.4.2.2 21A (Delta) Delta
## 52 B.1.617.2 AY.4.2.3 21A (Delta) Delta
## 53 B.1.617.2 AY.4.2.4 21A (Delta) Delta
## 54 B.1.617.2 AY.4.2.5 21A (Delta) Delta
## 55 B.1.617.2 AY.4.3 21A (Delta) Delta
## 56 B.1.617.2 AY.4.4 21A (Delta) Delta
## 57 B.1.617.2 AY.4.5 21A (Delta) Delta
## 58 B.1.617.2 AY.4.6 21A (Delta) Delta
## 59 B.1.617.2 AY.4.7 21A (Delta) Delta
## 60 B.1.617.2 AY.4.8 21A (Delta) Delta
## 61 B.1.617.2 AY.4.9 21A (Delta) Delta
## 62 B.1.617.2 AY.4.10 21A (Delta) Delta
## 63 B.1.617.2 AY.4.11 21A (Delta) Delta
## 64 B.1.617.2 AY.4.12 21A (Delta) Delta
## 65 B.1.617.2 AY.4.13 21A (Delta) Delta
## 66 B.1.617.2 AY.4.14 21A (Delta) Delta
## 67 B.1.617.2 AY.4.15 21A (Delta) Delta
## 68 B.1.617.2 AY.4.16 21A (Delta) Delta
## 69 B.1.617.2 AY.4.17 21A (Delta) Delta
## 70 B.1.617.2 AY.5 21A (Delta) Delta
## 71 B.1.617.2 AY.5.1 21A (Delta) Delta
## 72 B.1.617.2 AY.5.2 21A (Delta) Delta
## 73 B.1.617.2 AY.5.3 21A (Delta) Delta
## 74 B.1.617.2 AY.5.4 21A (Delta) Delta
## 75 B.1.617.2 AY.5.5 21A (Delta) Delta
## 76 B.1.617.2 AY.5.6 21A (Delta) Delta
## 77 B.1.617.2 AY.5.7 21A (Delta) Delta
## 78 B.1.617.2 AY.6 21A (Delta) Delta
## 79 B.1.617.2 AY.7 21A (Delta) Delta
## 80 B.1.617.2 AY.7.1 21A (Delta) Delta
## 81 B.1.617.2 AY.7.2 21A (Delta) Delta
## 82 B.1.617.2 AY.8 21A (Delta) Delta
## 83 B.1.617.2 AY.9 21A (Delta) Delta
## 84 B.1.617.2 AY.9.2 21A (Delta) Delta
## 85 B.1.617.2 AY.9.2.1 21A (Delta) Delta
## 86 B.1.617.2 AY.9.2.2 21A (Delta) Delta
## 87 B.1.617.2 AY.10 21A (Delta) Delta
## 88 B.1.617.2 AY.11 21A (Delta) Delta
## 89 B.1.617.2 AY.13 21A (Delta) Delta
## 90 B.1.617.2 AY.14 21A (Delta) Delta
## 91 B.1.617.2 AY.15 21A (Delta) Delta
## 92 B.1.617.2 AY.16 21A (Delta) Delta
## 93 B.1.617.2 AY.16.1 21A (Delta) Delta
## 94 B.1.617.2 AY.17 21A (Delta) Delta
## 95 B.1.617.2 AY.18 21A (Delta) Delta
## 96 B.1.617.2 AY.19 21A (Delta) Delta
## 97 B.1.617.2 AY.20 21A (Delta) Delta
## 98 B.1.617.2 AY.20.1 21A (Delta) Delta
## 99 B.1.617.2 AY.21 21A (Delta) Delta
## 100 B.1.617.2 AY.22 21A (Delta) Delta
## 101 B.1.617.2 AY.23 21A (Delta) Delta
## 102 B.1.617.2 AY.23.1 21A (Delta) Delta
## 103 B.1.617.2 AY.23.2 21A (Delta) Delta
## 104 B.1.617.2 AY.24 21A (Delta) Delta
## 105 B.1.617.2 AY.24.1 21A (Delta) Delta
## 106 B.1.617.2 AY.25 21A (Delta) Delta
## 107 B.1.617.2 AY.25.1 21A (Delta) Delta
## 108 B.1.617.2 AY.25.1.1 21A (Delta) Delta
## 109 B.1.617.2 AY.25.1.2 21A (Delta) Delta
## 110 B.1.617.2 AY.25.2 21A (Delta) Delta
## 111 B.1.617.2 AY.25.3 21A (Delta) Delta
## 112 B.1.617.2 AY.26 21A (Delta) Delta
## 113 B.1.617.2 AY.26.1 21A (Delta) Delta
## 114 B.1.617.2 AY.27 21A (Delta) Delta
## 115 B.1.617.2 AY.28 21A (Delta) Delta
## 116 B.1.617.2 AY.29 21A (Delta) Delta
## 117 B.1.617.2 AY.29.1 21A (Delta) Delta
## 118 B.1.617.2 AY.29.2 21A (Delta) Delta
## 119 B.1.617.2 AY.30 21A (Delta) Delta
## 120 B.1.617.2 AY.31 21A (Delta) Delta
## 121 B.1.617.2 AY.32 21A (Delta) Delta
## 122 B.1.617.2 AY.33 21A (Delta) Delta
## 123 B.1.617.2 AY.33.1 21A (Delta) Delta
## 124 B.1.617.2 AY.33.2 21A (Delta) Delta
## 125 B.1.617.2 AY.34 21A (Delta) Delta
## 126 B.1.617.2 AY.34.1 21A (Delta) Delta
## 127 B.1.617.2 AY.34.1.1 21A (Delta) Delta
## 128 B.1.617.2 AY.34.2 21A (Delta) Delta
## 129 B.1.617.2 AY.35 21A (Delta) Delta
## 130 B.1.617.2 AY.36 21A (Delta) Delta
## 131 B.1.617.2 AY.36.1 21A (Delta) Delta
## 132 B.1.617.2 AY.37 21A (Delta) Delta
## 133 B.1.617.2 AY.38 21A (Delta) Delta
## 134 B.1.617.2 AY.39 21A (Delta) Delta
## 135 B.1.617.2 AY.39.1 21A (Delta) Delta
## 136 B.1.617.2 AY.39.1.1 21A (Delta) Delta
## 137 B.1.617.2 AY.39.1.2 21A (Delta) Delta
## 138 B.1.617.2 AY.39.1.3 21A (Delta) Delta
## 139 B.1.617.2 AY.39.1.4 21A (Delta) Delta
## 140 B.1.617.2 AY.39.2 21A (Delta) Delta
## 141 B.1.617.2 AY.39.3 21A (Delta) Delta
## 142 B.1.617.2 AY.40 21A (Delta) Delta
## 143 B.1.617.2 AY.41 21A (Delta) Delta
## 144 B.1.617.2 AY.42 21A (Delta) Delta
## 145 B.1.617.2 AY.42.1 21A (Delta) Delta
## 146 B.1.617.2 AY.43 21A (Delta) Delta
## 147 B.1.617.2 AY.43.1 21A (Delta) Delta
## 148 B.1.617.2 AY.43.2 21A (Delta) Delta
## 149 B.1.617.2 AY.43.3 21A (Delta) Delta
## 150 B.1.617.2 AY.43.4 21A (Delta) Delta
## 151 B.1.617.2 AY.43.5 21A (Delta) Delta
## 152 B.1.617.2 AY.43.6 21A (Delta) Delta
## 153 B.1.617.2 AY.43.7 21A (Delta) Delta
## 154 B.1.617.2 AY.43.8 21A (Delta) Delta
## 155 B.1.617.2 AY.43.9 21A (Delta) Delta
## 156 B.1.617.2 AY.44 21A (Delta) Delta
## 157 B.1.617.2 AY.45 21A (Delta) Delta
## 158 B.1.617.2 AY.46 21A (Delta) Delta
## 159 B.1.617.2 AY.46.1 21A (Delta) Delta
## 160 B.1.617.2 AY.46.2 21A (Delta) Delta
## 161 B.1.617.2 AY.46.3 21A (Delta) Delta
## 162 B.1.617.2 AY.46.4 21A (Delta) Delta
## 163 B.1.617.2 AY.46.5 21A (Delta) Delta
## 164 B.1.617.2 AY.46.6 21A (Delta) Delta
## 165 B.1.617.2 AY.46.6.1 21A (Delta) Delta
## 166 B.1.617.2 AY.47 21A (Delta) Delta
## 167 B.1.617.2 AY.48 21A (Delta) Delta
## 168 B.1.617.2 AY.49 21A (Delta) Delta
## 169 B.1.617.2 AY.50 21A (Delta) Delta
## 170 B.1.617.2 AY.51 21A (Delta) Delta
## 171 B.1.617.2 AY.52 21A (Delta) Delta
## 172 B.1.617.2 AY.53 21A (Delta) Delta
## 173 B.1.617.2 AY.54 21A (Delta) Delta
## 174 B.1.617.2 AY.55 21A (Delta) Delta
## 175 B.1.617.2 AY.56 21A (Delta) Delta
## 176 B.1.617.2 AY.57 21A (Delta) Delta
## 177 B.1.617.2 AY.58 21A (Delta) Delta
## 178 B.1.617.2 AY.59 21A (Delta) Delta
## 179 B.1.617.2 AY.60 21A (Delta) Delta
## 180 B.1.617.2 AY.61 21A (Delta) Delta
## 181 B.1.617.2 AY.62 21A (Delta) Delta
## 182 B.1.617.2 AY.63 21A (Delta) Delta
## 183 B.1.617.2 AY.64 21A (Delta) Delta
## 184 B.1.617.2 AY.65 21A (Delta) Delta
## 185 B.1.617.2 AY.66 21A (Delta) Delta
## 186 B.1.617.2 AY.67 21A (Delta) Delta
## 187 B.1.617.2 AY.68 21A (Delta) Delta
## 188 B.1.617.2 AY.69 21A (Delta) Delta
## 189 B.1.617.2 AY.70 21A (Delta) Delta
## 190 B.1.617.2 AY.71 21A (Delta) Delta
## 191 B.1.617.2 AY.72 21A (Delta) Delta
## 192 B.1.617.2 AY.73 21A (Delta) Delta
## 193 B.1.617.2 AY.74 21A (Delta) Delta
## 194 B.1.617.2 AY.75 21A (Delta) Delta
## 195 B.1.617.2 AY.75.2 21A (Delta) Delta
## 196 B.1.617.2 AY.75.3 21A (Delta) Delta
## 197 B.1.617.2 AY.76 21A (Delta) Delta
## 198 B.1.617.2 AY.77 21A (Delta) Delta
## 199 B.1.617.2 AY.78 21A (Delta) Delta
## 200 B.1.617.2 AY.79 21A (Delta) Delta
## 201 B.1.617.2 AY.80 21A (Delta) Delta
## 202 B.1.617.2 AY.81 21A (Delta) Delta
## 203 B.1.617.2 AY.82 21A (Delta) Delta
## 204 B.1.617.2 AY.83 21A (Delta) Delta
## 205 B.1.617.2 AY.84 21A (Delta) Delta
## 206 B.1.617.2 AY.85 21A (Delta) Delta
## 207 B.1.617.2 AY.86 21A (Delta) Delta
## 208 B.1.617.2 AY.87 21A (Delta) Delta
## 209 B.1.617.2 AY.88 21A (Delta) Delta
## 210 B.1.617.2 AY.90 21A (Delta) Delta
## 211 B.1.617.2 AY.91 21A (Delta) Delta
## 212 B.1.617.2 AY.91.1 21A (Delta) Delta
## 213 B.1.617.2 AY.92 21A (Delta) Delta
## 214 B.1.617.2 AY.93 21A (Delta) Delta
## 215 B.1.617.2 AY.94 21A (Delta) Delta
## 216 B.1.617.2 AY.95 21A (Delta) Delta
## 217 B.1.617.2 AY.98 21A (Delta) Delta
## 218 B.1.617.2 AY.98.1 21A (Delta) Delta
## 219 B.1.617.2 AY.98.1.1 21A (Delta) Delta
## 220 B.1.617.2 AY.99 21A (Delta) Delta
## 221 B.1.617.2 AY.99.1 21A (Delta) Delta
## 222 B.1.617.2 AY.99.2 21A (Delta) Delta
## 223 B.1.617.2 AY.100 21A (Delta) Delta
## 224 B.1.617.2 AY.101 21A (Delta) Delta
## 225 B.1.617.2 AY.102 21A (Delta) Delta
## 226 B.1.617.2 AY.102.1 21A (Delta) Delta
## 227 B.1.617.2 AY.102.2 21A (Delta) Delta
## 228 B.1.617.2 AY.103 21A (Delta) Delta
## 229 B.1.617.2 AY.103.1 21A (Delta) Delta
## 230 B.1.617.2 AY.103.2 21A (Delta) Delta
## 231 B.1.617.2 AY.104 21A (Delta) Delta
## 232 B.1.617.2 AY.105 21A (Delta) Delta
## 233 B.1.617.2 AY.106 21A (Delta) Delta
## 234 B.1.617.2 AY.107 21A (Delta) Delta
## 235 B.1.617.2 AY.108 21A (Delta) Delta
## 236 B.1.617.2 AY.109 21A (Delta) Delta
## 237 B.1.617.2 AY.110 21A (Delta) Delta
## 238 B.1.617.2 AY.111 21A (Delta) Delta
## 239 B.1.617.2 AY.112 21A (Delta) Delta
## 240 B.1.617.2 AY.112.1 21A (Delta) Delta
## 241 B.1.617.2 AY.112.2 21A (Delta) Delta
## 242 B.1.617.2 AY.112.3 21A (Delta) Delta
## 243 B.1.617.2 AY.113 21A (Delta) Delta
## 244 B.1.617.2 AY.114 21A (Delta) Delta
## 245 B.1.617.2 AY.116 21A (Delta) Delta
## 246 B.1.617.2 AY.116.1 21A (Delta) Delta
## 247 B.1.617.2 AY.117 21A (Delta) Delta
## 248 B.1.617.2 AY.118 21A (Delta) Delta
## 249 B.1.617.2 AY.119 21A (Delta) Delta
## 250 B.1.617.2 AY.119.1 21A (Delta) Delta
## 251 B.1.617.2 AY.119.2 21A (Delta) Delta
## 252 B.1.617.2 AY.120 21A (Delta) Delta
## 253 B.1.617.2 AY.120.1 21A (Delta) Delta
## 254 B.1.617.2 AY.120.2 21A (Delta) Delta
## 255 B.1.617.2 AY.120.2.1 21A (Delta) Delta
## 256 B.1.617.2 AY.121 21A (Delta) Delta
## 257 B.1.617.2 AY.121.1 21A (Delta) Delta
## 258 B.1.617.2 AY.122 21A (Delta) Delta
## 259 B.1.617.2 AY.122.1 21A (Delta) Delta
## 260 B.1.617.2 AY.122.2 21A (Delta) Delta
## 261 B.1.617.2 AY.122.3 21A (Delta) Delta
## 262 B.1.617.2 AY.122.4 21A (Delta) Delta
## 263 B.1.617.2 AY.122.5 21A (Delta) Delta
## 264 B.1.617.2 AY.122.6 21A (Delta) Delta
## 265 B.1.617.2 AY.123 21A (Delta) Delta
## 266 B.1.617.2 AY.123.1 21A (Delta) Delta
## 267 B.1.617.2 AY.124 21A (Delta) Delta
## 268 B.1.617.2 AY.124.1 21A (Delta) Delta
## 269 B.1.617.2 AY.124.1.1 21A (Delta) Delta
## 270 B.1.617.2 AY.125 21A (Delta) Delta
## 271 B.1.617.2 AY.125.1 21A (Delta) Delta
## 272 B.1.617.2 AY.126 21A (Delta) Delta
## 273 B.1.617.2 AY.127 21A (Delta) Delta
## 274 B.1.617.2 AY.127.1 21A (Delta) Delta
## 275 B.1.617.2 AY.127.2 21A (Delta) Delta
## 276 B.1.617.2 AY.127.3 21A (Delta) Delta
## 277 B.1.617.2 AY.128 21A (Delta) Delta
## 278 B.1.617.2 AY.129 21A (Delta) Delta
## 279 B.1.617.2 AY.130 21A (Delta) Delta
## 280 B.1.617.2 AY.131 21A (Delta) Delta
## 281 B.1.617.2 AY.132 21A (Delta) Delta
## 282 B.1.617.2 AY.133 21A (Delta) Delta
## 283 B.1.617.2 AY.134 21A (Delta) Delta
## 284 B.1.617.1 B.1.617.1 21B (Kappa) Kappa
## 285 B.1.427 B.1.427 21C (Epsilon) Epsilon
Custom Hierarchies
- CCT can also examine custom hierarchies for descendants and ancestors
- This capacity is limited at the moment but can easily provide the same functionality as above to work with yaml-defined hierarchies.
Create a Randomly Nested YAML
# Random YAML
yaml <- "fruit:\n"
depth <- ""
maxdepth <- 1
deepest <- stringr::fruit[1]
for(i in stringr::fruit){
flip <- round(runif(1, 0, 1))
if(flip == 1){
flip <- round(runif(1, 0, 1))
if(flip == 1){
depth <- paste0(depth, " ")
if(stringr::str_count(depth, " ") > maxdepth){
maxdepth <- stringr::str_count(depth, " ")
deepest <- i
}
}
}else{
depth <- " "
}
yaml <- paste0(yaml,
paste0(depth, i, ":\n"))
}
cat(yaml)
## fruit:
## apple:
## apricot:
## avocado:
## banana:
## bell pepper:
## bilberry:
## blackberry:
## blackcurrant:
## blood orange:
## blueberry:
## boysenberry:
## breadfruit:
## canary melon:
## cantaloupe:
## cherimoya:
## cherry:
## chili pepper:
## clementine:
## cloudberry:
## coconut:
## cranberry:
## cucumber:
## currant:
## damson:
## date:
## dragonfruit:
## durian:
## eggplant:
## elderberry:
## feijoa:
## fig:
## goji berry:
## gooseberry:
## grape:
## grapefruit:
## guava:
## honeydew:
## huckleberry:
## jackfruit:
## jambul:
## jujube:
## kiwi fruit:
## kumquat:
## lemon:
## lime:
## loquat:
## lychee:
## mandarine:
## mango:
## mulberry:
## nectarine:
## nut:
## olive:
## orange:
## pamelo:
## papaya:
## passionfruit:
## peach:
## pear:
## persimmon:
## physalis:
## pineapple:
## plum:
## pomegranate:
## pomelo:
## purple mangosteen:
## quince:
## raisin:
## rambutan:
## raspberry:
## redcurrant:
## rock melon:
## salal berry:
## satsuma:
## star fruit:
## strawberry:
## tamarillo:
## tangerine:
## ugli fruit:
## watermelon:
Now that the hierarchy is defined in the above yaml text we can load it and convert it into a data.tree node network. A YAML file can also be supplied using the commented text.
# To load a file
# yaml::read_yaml(yaml) %>%
# data.tree::as.Node(interpretNullAsList = TRUE)
hier <- yaml::yaml.load(yaml) %>%
data.tree::as.Node(interpretNullAsList = TRUE)
str(hier)
## Classes 'Node', 'R6' <Node>
## Public:
## AddChild: function (name, check = c("check", "no-warn", "no-check"), ...)
## AddChildNode: function (child)
## AddSibling: function (name, check = c("check", "no-warn", "no-check"), ...)
## AddSiblingNode: function (sibling)
## attributes: active binding
## attributesAll: active binding
## averageBranchingFactor: active binding
## children: active binding
## Climb: function (...)
## clone: function (deep = FALSE)
## count: active binding
## Do: function (fun, ..., traversal = c("pre-order", "post-order",
## fields: active binding
## fieldsAll: active binding
## fruit: Node, R6
## Get: function (attribute, ..., traversal = c("pre-order", "post-order",
## height: active binding
## initialize: function (name, check = c("check", "no-warn", "no-check"), ...)
## isBinary: active binding
## isLeaf: active binding
## isRoot: active binding
## leafCount: active binding
## leaves: active binding
## level: active binding
## levelName: active binding
## name: active binding
## Navigate: function (path)
## parent: active binding
## path: active binding
## pathString: active binding
## position: active binding
## printFormatters: active binding
## Prune: function (pruneFun)
## RemoveAttribute: function (name, stopIfNotAvailable = TRUE)
## RemoveChild: function (name)
## Revert: function (recursive = TRUE)
## root: active binding
## Set: function (..., traversal = c("pre-order", "post-order", "in-order",
## siblings: active binding
## Sort: function (attribute, ..., decreasing = FALSE, recursive = TRUE)
## totalCount: active binding
## Private:
## p_children: list
## p_name: Root
## p_parent: NULL
The deepest element of that fake yaml is tamarillo let’s use that as an example.
Examining the Custom Hierarchy
Pull ancestors of deepest and return a node.
y <- pullAncestors(x = hier,
node_name = deepest)
str(y)
## Classes 'Node', 'R6' <Node>
## Public:
## AddChild: function (name, check = c("check", "no-warn", "no-check"), ...)
## AddChildNode: function (child)
## AddSibling: function (name, check = c("check", "no-warn", "no-check"), ...)
## AddSiblingNode: function (sibling)
## attributes: active binding
## attributesAll: active binding
## averageBranchingFactor: active binding
## children: active binding
## Climb: function (...)
## clone: function (deep = FALSE)
## count: active binding
## Do: function (fun, ..., traversal = c("pre-order", "post-order",
## fields: active binding
## fieldsAll: active binding
## fruit: Node, R6
## Get: function (attribute, ..., traversal = c("pre-order", "post-order",
## height: active binding
## initialize: function (name, check = c("check", "no-warn", "no-check"), ...)
## isBinary: active binding
## isLeaf: active binding
## isRoot: active binding
## leafCount: active binding
## leaves: active binding
## level: active binding
## levelName: active binding
## name: active binding
## Navigate: function (path)
## parent: active binding
## path: active binding
## pathString: active binding
## position: active binding
## printFormatters: active binding
## Prune: function (pruneFun)
## RemoveAttribute: function (name, stopIfNotAvailable = TRUE)
## RemoveChild: function (name)
## Revert: function (recursive = TRUE)
## root: active binding
## Set: function (..., traversal = c("pre-order", "post-order", "in-order",
## siblings: active binding
## Sort: function (attribute, ..., decreasing = FALSE, recursive = TRUE)
## totalCount: active binding
## Private:
## p_children: list
## p_name: Root
## p_parent: NULL
Print it (looks like a table)
y
## levelName
## 1 Root
## 2 °--fruit
## 3 °--quince
## 4 °--raisin
## 5 °--rambutan
## 6 °--redcurrant
## 7 °--salal berry
## 8 °--satsuma
## 9 °--strawberry
## 10 °--tamarillo
Return an actual table. Note the lineage column of
NA
.
y <- pullAncestors(x = hier,
node_name = deepest,
table = T)
y
## levelName level lineage
## 1 Root 1 NA
## 2 °--fruit 2 NA
## 3 °--quince 3 NA
## 4 °--raisin 4 NA
## 5 °--rambutan 5 NA
## 6 °--redcurrant 6 NA
## 7 °--salal berry 7 NA
## 8 °--satsuma 8 NA
## 9 °--strawberry 9 NA
## 10 °--tamarillo 10 NA
The attribute parameter is used to query the data in
pullAncestors
and can refer to any built in attributes of
the data.tree
node network or custom metadata.
y <- pullAncestors(x = hier,
node_name = deepest,
table = T,
attribute = "name")
y
## levelName level name
## 1 Root 1 Root
## 2 °--fruit 2 fruit
## 3 °--quince 3 quince
## 4 °--raisin 4 raisin
## 5 °--rambutan 5 rambutan
## 6 °--redcurrant 6 redcurrant
## 7 °--salal berry 7 salal berry
## 8 °--satsuma 8 satsuma
## 9 °--strawberry 9 strawberry
## 10 °--tamarillo 10 tamarillo
v <- pullAncestors(x = hier,
node_name = deepest,
vector = T,
attribute = "name")
v
## [1] "Root" "fruit" "quince" "raisin" "rambutan"
## [6] "redcurrant" "salal berry" "satsuma" "strawberry" "tamarillo"
Get descendants in a similar way as above.
getDescendants(hier, v[3], attribute = "name")
## levelName
## 1 quince
## 2 °--raisin
## 3 °--rambutan
## 4 ¦--raspberry
## 5 °--redcurrant
## 6 ¦--rock melon
## 7 °--salal berry
## 8 °--satsuma
## 9 ¦--star fruit
## 10 °--strawberry
## 11 °--tamarillo