R/phylo__getMRCAdates.R

Defines functions getMRCAdates

Documented in getMRCAdates

#' @title Getting the date of the most-recent common ancestor (MRCA) from a Bactdating tree
#' @description Extracting the MRCA date from function bactdate's output.
#' @param tr_dated A dated tree generated by function bactdate of package Bactdating (https://github.com/xavierdidelot/BactDating).
#' @return The MRCA's date in a named vector (lower and upper bounds and the mean date).
#' @export
# (C) Copyright 2022 Yu Wan <wanyuac@126.com>
# Licensed under the Apache License, Version 2.0
# Release: 26 Aug 2022; last update: 26 Aug 2022

getMRCAdates <- function(tr_dated) {
    r <- tr_dated$CI[which.min(tr_dated$CI[, 1]), ]
    return(c("min" = r[1], "mean" = tr_dated$tree$root.time, "max" = r[2]))
}
wanyuac/handyR documentation built on June 10, 2024, 1:24 a.m.