% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.R
\name{compare_sequences}
\alias{compare_sequences}
\alias{compare_sequences.default}
\alias{compare_sequences.group_tna}
\title{Compare Sequences Between Groups}
\usage{
compare_sequences(x, ...)

\method{compare_sequences}{default}(
  x,
  group,
  sub,
  min_freq = 5L,
  test = TRUE,
  iter = 1000L,
  adjust = "bonferroni",
  ...
)

\method{compare_sequences}{group_tna}(
  x,
  sub,
  min_freq = 5L,
  test = TRUE,
  iter = 1000L,
  adjust = "bonferroni",
  ...
)
}
\arguments{
\item{x}{A \code{group_tna} object or a \code{data.frame} containing sequence data in
wide format.}

\item{...}{Not used.}

\item{group}{A \code{vector} indicating the group assignment of each
row of the data/sequence. Must have the same length as the number of
rows/sequences of \code{x}. Alternatively, a single \code{character} string giving
the column name of the data that defines the group when \code{x} is a wide
format \code{data.frame} or a \code{tna_data} object.}

\item{sub}{An \code{integer} vector of pattern lengths to analyze.
The default is \code{2:5}.}

\item{min_freq}{An \code{integer} giving the minimum number of times that a
specific pattern has to be observed in each group to be included in the
analysis. The default is \code{5}.}

\item{test}{A \code{logical} value indicating whether to test the differences
of pattern counts between the groups using a permutation test.
The default is \code{TRUE}.}

\item{iter}{An \code{integer} giving the number of iterations for the permutation
test. The default is \code{1000}.}

\item{adjust}{A \code{character} string naming the multiple comparison
correction method (default: \code{"bonferroni"}). Supports all
\link[stats:p.adjust]{stats::p.adjust} methods: \code{"holm"}, \code{"hochberg"}, \code{"hommel"},
\code{"bonferroni"}, \code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}. The adjustment
is carried out within sequences of the same length.}
}
\value{
A \code{tna_sequence_comparison} object, which is a \code{data.frame} with
columns giving the names of the patterns, pattern frequencies, pattern
proportions (within patterns of the same length), effect sizes,
and p-values of the tests.
}
\description{
Performs comprehensive sequence comparison analysis between groups. All
patterns of the sequences (subsequences of specific length) are extracted
from all sequences in each group. The pattern frequencies are compared
between the groups using a permutation test. The reported effect size is the
difference between the observed test statistic (sum of squared differences
between the observed and expected counts) and the mean value over the
permutation samples divided by their standard deviation times square root of
the number of observations.
}
\examples{
\donttest{
# Use a subset to keep the example fast.
idx <- c(1:500, 1001:1500)
group <- c(rep("High", 500), rep("Low", 500))
comp <- compare_sequences(group_regulation[idx, ], group)

# With permutation test (small number of iterations for CRAN)
comp_test <- compare_sequences(
  group_regulation[idx, ],
  group,
  test = TRUE,
  iter = 5
)
}

}
\seealso{
Model comparison functions
\code{\link{compare}()},
\code{\link{compare.group_tna}()},
\code{\link{plot.tna_comparison}()},
\code{\link{plot.tna_sequence_comparison}()},
\code{\link{plot_compare}()},
\code{\link{plot_compare.group_tna}()},
\code{\link{print.tna_comparison}()},
\code{\link{print.tna_sequence_comparison}()}
}
\concept{comparison}
