-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveMegaDistance.Rd
More file actions
44 lines (40 loc) · 1.26 KB
/
saveMegaDistance.Rd
File metadata and controls
44 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distances_and_export.R
\name{saveMegaDistance}
\alias{saveMegaDistance}
\title{Save distance matrix in MEGA format}
\usage{
saveMegaDistance(filename, distance_matrix)
}
\arguments{
\item{filename}{Character. Output filename (typically with .meg extension).}
\item{distance_matrix}{Numeric matrix. A square distance matrix with row and
column names corresponding to sequence identifiers.}
}
\value{
NULL. Writes file as a side effect.
}
\description{
Exports a distance matrix to MEGA format for use with MEGA software for
phylogenetic tree visualization and analysis.
}
\details{
MEGA (Molecular Evolutionary Genetics Analysis) is widely used for
phylogenetic analysis. This function creates a distance matrix file
compatible with MEGA's format specifications.
}
\examples{
# Build a small symmetric distance matrix
dist_mat <- matrix(
c(0.00, 0.12, 0.25,
0.12, 0.00, 0.18,
0.25, 0.18, 0.00),
nrow = 3
)
rownames(dist_mat) <- colnames(dist_mat) <- c("Seq1", "Seq2", "Seq3")
# Save to a temporary file (no permanent files written during checks)
out <- tempfile(fileext = ".meg")
saveMegaDistance(out, dist_mat)
# Inspect the first few lines of the output
writeLines(readLines(out, n = 8))
}