YuLab-SMU/tidytree

where is the s3 method groupOTU.phylo

Opened this issue · 2 comments

where is the s3 method groupOTU.phylo

When I used the groupOTU , I found that the root node group was 0, so I looked at the code . I just found the groupOTU.tbl_tree and found that the method didn't group the root node. I'd like to see else such as groupOTU.phylo

I tried to group the root node, but failed

### add group for tree by info
    info <- split(group$id, group$Taxon)
    tree <- groupOTU(tree, info)
    group_name <- 'group'
    .data <- as_tibble(tree)
    rn <- rootnode(.data)$node
    tmp1 <- .data[.data['parent'] == rn,]
    tmp1 <- tmp1[tmp1['node'] != rn,group_name][[1]][1]
    .data[[group_name]][rn] <- tmp1
    .data[[group_name]] <- factor(.data[[group_name]])
    tree <- as.phylo(.data)