-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculateDistanceMatrix.Rd
More file actions
43 lines (39 loc) · 1.51 KB
/
calculateDistanceMatrix.Rd
File metadata and controls
43 lines (39 loc) · 1.51 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distances_and_export.R
\name{calculateDistanceMatrix}
\alias{calculateDistanceMatrix}
\title{Calculate pairwise distance matrix for multiple sequences}
\usage{
calculateDistanceMatrix(freq_matrices, distance_type = "Euclidean")
}
\arguments{
\item{freq_matrices}{List. A named list of frequency matrices, one per
sequence, as returned by cgat().}
\item{distance_type}{Character. Type of distance to calculate:
"Euclidean" (default), "S_Euclidean", or "Manhattan".}
}
\value{
Numeric matrix. A symmetric distance matrix with sequence names as
row and column names.
}
\description{
Computes a full pairwise distance matrix from a list of CGR frequency
matrices.
}
\details{
This function calculates all pairwise distances between sequences based on
their CGR frequency matrices. The resulting distance matrix can be used for
phylogenetic tree construction, clustering, or other downstream analyses.
}
\examples{
# Build two minimal frequency matrices (4 k-mers each, normalized)
fm1 <- matrix(c(0.4, 0.3, 0.2, 0.1), ncol = 1,
dimnames = list(c("A", "C", "G", "T"), NULL))
fm2 <- matrix(c(0.1, 0.2, 0.3, 0.4), ncol = 1,
dimnames = list(c("A", "C", "G", "T"), NULL))
fm3 <- matrix(c(0.25, 0.25, 0.25, 0.25), ncol = 1,
dimnames = list(c("A", "C", "G", "T"), NULL))
freq_list <- list(Seq1 = fm1, Seq2 = fm2, Seq3 = fm3)
dist_matrix <- calculateDistanceMatrix(freq_list, distance_type = "Euclidean")
print(round(dist_matrix, 4))
}