Skip to contents

Filter a pf or pfc object by taking all descendents of the most recent common ancestor (mrca) of descendents

Usage

pf_filter_with_mrca(
  x,
  descendents,
  drop_null_edges = TRUE,
  drop_root_edges = TRUE,
  ...
)

Arguments

x

A pf or pfc object

descendents

An index into a pfc, using any way that you can index a pfc. filter_with_mrca will find the most recent common ancestor of everything in descendents and then it will return a filtered pf or pfc with all descendents of the mrca. If of length one, it will instead be assumed to be the node name or number representing the mrca itself.

drop_null_edges

If TRUE (the default), drop edges with no descendants after the filtering.

drop_root_edges

If TRUE (the default), drop all edges leading up to the mrca (e.g. when combined together these would make a root edge leading to the desired clade)

...

Other arguments for future extensions.

Value

A pf or pfc object

Examples

avonet %>% 
    pf_filter_with_mrca(label %in% c("Platalea_minor", "Pelecanus_occidentalis"))
#> # A tibble: 121 × 39
#>    label is_tip phlo            Species3 Family3 Order3 Total.individuals Female
#>    <chr> <lgl>  <pfc>           <chr>    <chr>   <chr>              <dbl>  <dbl>
#>  1 Ther… TRUE   ◎──  3.anopis  Therist… Thresk… Pelec…                 9      4
#>  2 Phim… TRUE   ◎──  3.scatus  Phimosu… Thresk… Pelec…                 6      2
#>  3 Plat… TRUE   ◎──  3._minor  Platale… Thresk… Pelec…                 4      3
#>  4 Plat… TRUE   ◎──  3.orodia  Platale… Thresk… Pelec…                 7      4
#>  5 Plat… TRUE   ◎──  3.a_alba  Platale… Thresk… Pelec…                 4      1
#>  6 Thre… TRUE   ◎──  3.opicus  Threski… Thresk… Pelec…                 5      2
#>  7 Thre… TRUE   ◎──  3.olucca  Threski… Thresk… Pelec…                 4      1
#>  8 Nipp… TRUE   ◎──  3.nippon  Nipponi… Thresk… Pelec…                 5      2
#>  9 Plat… TRUE   ◎──  3._ajaja  Platale… Thresk… Pelec…                 9      4
#> 10 Pleg… TRUE   ◎──  3.nellus  Plegadi… Thresk… Pelec…                 8      4
#> # ℹ 111 more rows
#> # ℹ 31 more variables: Male <dbl>, Unknown <dbl>, Complete.measures <dbl>,
#> #   Beak.Length_Culmen <dbl>, Beak.Length_Nares <dbl>, Beak.Width <dbl>,
#> #   Beak.Depth <dbl>, Tarsus.Length <dbl>, Wing.Length <dbl>,
#> #   Kipps.Distance <dbl>, Secondary1 <dbl>, `Hand-Wing.Index` <dbl>,
#> #   Tail.Length <dbl>, Mass <dbl>, Mass.Source <chr>, Mass.Refs.Other <chr>,
#> #   Inference <chr>, Traits.inferred <chr>, Reference.species <chr>, …