YuLab-SMU/tidytree

Something not quite right with most recent "offspring" function

Closed this issue · 3 comments

Hi, first thanks for providing such a great package! I recently updated tidytree from 0.2.4 to 0.2.8 and noticed some of my previous code that call "ggtree::flip" shows inconsistent result. Further investigation showed that when calling the offspring, exactly the "offspring.tbl_tree" function, with argument self_incude=T, the version in 0.2.4 will include self but the version in 0.2.8 return a tbl_tree without any row. Can you check it there's any change you recently made to the function that might cause this?

Thanks,
Qin

> set.seed(123)
> x = rtree(30)
> d = as_tibble(x)
> offspring(d, 35, self_include=T)
# A tibble: 23 x 4
   parent  node branch.length label
    <int> <int>         <dbl> <chr>
 1     37     4      0.794    t3   
 2     37     5      0.440    t8   
 3     36     6      0.754    t7   
 4     39     7      0.000625 t10  
 5     39     8      0.475    t30  
 6     42     9      0.352    t19  
 7     43    10      0.244    t4   
 8     43    11      0.668    t14  
 9     45    12      0.103    t17  
10     45    13      0.435    t11  
# … with 13 more rows
> offspring(d, 35)
# A tibble: 22 x 4
   parent  node branch.length label
    <int> <int>         <dbl> <chr>
 1     37     4      0.794    t3   
 2     37     5      0.440    t8   
 3     36     6      0.754    t7   
 4     39     7      0.000625 t10  
 5     39     8      0.475    t30  
 6     42     9      0.352    t19  
 7     43    10      0.244    t4   
 8     43    11      0.668    t14  
 9     45    12      0.103    t17  
10     45    13      0.435    t11  
# … with 12 more rows

It seems fine.

If you want to report an issue, you need to provide a reproducible example.

Please see this example:

lin_tree_tbl <- readRDS("lin_tree_tbl.rds")
> offspring(lin_tree_tbl, 90, self_include = T)
# A tibble: 1 x 17
  parent  node branch.length label br_time d_time lifetime level lineage Cell  Description lin_cell isTip     x     y branch
   <int> <int>         <dbl> <chr>   <int>  <int>    <dbl> <dbl> <chr>   <chr> <chr>       <chr>    <lgl> <dbl> <dbl>  <dbl>
1    764    90            50 ABal…     302     NA       50    10 NA      NA    NA          ABalpap… TRUE    351    90    326
# … with 1 more variable: angle <dbl>

However with latest version:

> offspring(lin_tree_tbl, 90, self_include = T)
# A tibble: 0 x 17
# … with 17 variables: parent <int>, node <int>, branch.length <dbl>, label <chr>, br_time <int>, d_time <int>,
#   lifetime <dbl>, level <dbl>, lineage <chr>, Cell <chr>, Description <chr>, lin_cell <chr>, isTip <lgl>, x <dbl>,
#   y <dbl>, branch <dbl>, angle <dbl>

lin_tree_tbl.rds.zip

fixed in v >= 0.2.9.