cluster_to_nexus {EvoPhylo}R Documentation

Export character partitions to a Nexus file


Creates and exports a Nexus file with a list of characters and their respective partitions as inferred by the make_clusters function. The contents can be copied and pasted directly into a Mr. Bayes commands block for a partitioned clock Bayesian inference analysis.


cluster_to_nexus(cluster_df, file = NULL)



A cluster_df object; the output of a call to make_clusters.


The path of the text file to be created containing the partitioning information in Nexus format. If NULL (the default), no file will be written and the output will be returned as a string. If "", the text will be printed to the console. Passed directly to the file argument of cat.


The text as a string, returned invisibly if file is not NULL. Use cat on the resulting output to format it correctly (i.e., to turn "\n" into line breaks).

See Also

vignette("char-part") for the use of this function as part of an analysis pipeline.



# See vignette("char-part") for how to use this
# function as part of an analysis pipeline

# Load example phylogenetic data matrix

# Create distance matrix
Dmatrix <- get_gower_dist(characters)

# Find optimal partitioning scheme using PAM under k=3
# partitions
cluster_df <- make_clusters(Dmatrix, k = 3)

# Write to Nexus file and export to .txt file:
file <- tempfile(fileext = ".txt")

# You would set, e.g.,
# file <- "path/to/file.txt"

cluster_to_nexus(cluster_df, file = file)

[Package EvoPhylo version 0.3.2 Index]