Skip to contents

Trim lineages until the shallowest common rank.

Usage

trim_common(lineage, remove_void = TRUE, only_tail = TRUE)

Arguments

lineage

string. Vector of lineages.

remove_void

Should void ranks be removed? Default to TRUE.

only_tail

Logical to be passed to trim_void(). Used only if remove_void is set to TRUE.

Value

The trimmed lineages, with same depth.

Examples

lineage1 <- "k__Bacteria|p__Verrucomicrobia|c__Verrucomicrobiae"
lineage2 <- "k__Bacteria|p__Firmicutes"
lineage3 <- "k__Bacteria|p__|c__Clostridia"
trim_common(c(lineage1, lineage2, lineage3), remove_void = FALSE)
#> [1] "k__Bacteria|p__Verrucomicrobia" "k__Bacteria|p__Firmicutes"     
#> [3] "k__Bacteria|p__"               
trim_common(c(lineage1, lineage2, lineage3), only_tail = FALSE)
#> [1] "k__Bacteria" "k__Bacteria" "k__Bacteria"