Skip to content

Function to export simulated trees from twt #145

@hugocastelan

Description

@hugocastelan

Function for exporting simulated trees generated with twt

twt_export_inner_tree <- function(inner, file = NULL,
                                  transmissions = FALSE,
                                  migrations = FALSE,
                                  transitions = FALSE) {
  
  # directly use the internal twt method
  phy <- as.phylo(inner,
                  transmissions = transmissions,
                  migrations = migrations,
                  transitions = transitions)
  
  # ensure it is a phylo object
  class(phy) <- "phylo"
  
  # Export the tree to a file
  if (!is.null(file)) {
    ape::write.tree(phy, file = file)
    message("Tree exported to: ", file)
  }
  
  return(phy)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions