---
title: Sq vs. K Taxonomic Classification
url: https://www.emergentmind.com/topics/sq-or-k-taxonomic-classification
type: topic
---

# Sq vs. K Taxonomic Classification

The Sq (aligned sequence) and K (k-mer count) taxonomic classification frameworks constitute two principal paradigms for modeling molecular sequence data in computational taxonomy. Their distinction is foundational, directly determining the likelihood function, prior structure, inference algorithms, and suitability to varying molecular datasets and application contexts. Theoretical analyses and empirical work—including those of BayesANT [2201.09782], and broader k-mer–based classifiers—demonstrate not only the diverse implementation requirements but also notable differences in calibration, interpretability, statistical power, and robustness to sequence variability.

## 1. Formal Definitions: Sq and K Representations

The Sq approach, or "aligned-sequence model," represents each DNA or RNA sequence as a vector of nucleotides at $p$ globally aligned sites. For a sequence $X=X_1,\ldots,X_p$ with $X_s\in\{A,C,G,T,-\}$, the underlying generative model assumes

$$
P(X\mid\theta_v) = \prod_{s=1}^p \prod_{g\in\{A,C,G,T\}} \theta_{v,s,g}^{\mathbb{I}(X_s=g)},
$$

where $\theta_{v,s,\cdot}$ is a categorical distribution at site $s$ for taxon $v$.

By contrast, the K approach represents each sequence by its vector of observed $\kappa$-mer counts over the $4^\kappa$ possible canonical substrings of length $\kappa$, denoted $n_g(X)$. The associated multinomial likelihood is

$$
P(X \mid \theta_v) = \mathrm{Multinomial}(n_\cdot; \theta_v), \quad \theta_v \in \Delta^{4^\kappa - 1},
$$

with no explicit positional information; $\theta_v$ parameterizes the expected k-mer composition within taxon $v$.

## 2. Bayesian Nonparametric Framework: BayesANT and Issues of Taxonomic Novelty

BayesANT [2201.09782] instantiates both Sq and K kernels within a Bayesian nonparametric hierarchy, employing Pitman–Yor species sampling priors at each internal branch of the taxonomy. For every parent node $v_{\ell-1}$ at rank $\ell-1$,

- The Pitman–Yor process hyperparameters $(\sigma_{\ell}, \alpha_{\ell})$ control the probability assigned to previously seen versus new child taxa (see allocation rules below):

$$
P(\text{child}=V_{j,\ell}^*\mid \text{past})= \frac{n_j-\sigma_\ell}{\alpha_\ell+N_n(v_{\ell-1})},\quad P(\text{child new}\mid \text{past})=\frac{\alpha_\ell+\sigma_\ell K_n(v_{\ell-1})}{\alpha_\ell+N_n(v_{\ell-1})},
$$

where $n_j$ is the number of sequences assigned so far to child $j$ under parent $v_{\ell-1}$, and $K_n$ is the current number of distinct children. This prior guarantees every query is assigned a nontrivial posterior probability of belonging to a novel taxon at each rank.

In both Sq and K settings, Dirichlet-multinomial conjugacy allows analytic marginalization over $\theta_v$, yielding closed forms for predictive probabilities at both known and novel leaves.

## 3. Likelihoods, Posteriors, and Predictive Inference

In the Sq model, with Dirichlet priors $\theta_{v,s,\cdot} \sim \mathrm{Dir}(\xi_{v,s,A},\ldots)$, the marginal likelihood for a new sequence at leaf $v$ is

$$
P(X; \theta_v) = \prod_{s=1}^p \prod_{g\in\{A,C,G,T\}} \frac{\xi_{v,s,g}+n_{v,s,g}}{\xi_{v,s,\cdot}+n_{v,s,\cdot}}^{\mathbb{I}(X_s=g)},
$$

where $n_{v,s,g}$ aggregates training counts at site $s$ in $v$.

For the K model, with Dirichlet priors on the k-mer probability vector $\theta_v$, the posterior predictive for a new sequence is

$$
\prod_{g\in\mathcal{N}_\kappa} \frac{\xi_{v,g}+n_{v,g}}{\xi_{v,\cdot}+\sum n_{v,\cdot}}^{n_g(X)},
$$

where $n_{v,g}$ is the observed count of k-mer $g$ in $v$'s assigned training sequences.

At prediction time, BayesANT computes the posterior for each branch, calibrates via exponentiation ($\tilde p(v_L) \propto [p(v_L)]^{\rho}$, $\rho\approx 0.1$), and aggregates over leaves at each rank.

## 4. Comparative Methodological and Practical Considerations

### Alignment Dependency

- Sq methods require globally aligned sequences (e.g., COI barcodes 658 bp in FinBOL), delivering site-specific priors and leveraging positionally informative substitutions.
- K methods make no alignment assumptions; k-mer counts or compositions serve as a bag-of-words over local motifs, critical in highly variable or unalignable regions (e.g., fungal ITS).

### Statistical Power and Parameterization

- The Sq approach parameterizes $\sim 4p$ probabilities per leaf, where $p$ is the sequence length. This yields highly parsimonious models in well-aligned marker regions.
- The K approach grows exponentially in $\kappa$ ($4^\kappa$-dimensional multinomial). Large $\kappa$ leads to sparsity and risk of overfitting, while small $\kappa$ (e.g., 2–5) offers a compromise between expressivity and sample complexity.

### Predictive Performance and Discovery of Novel Taxa

Empirical results in [2201.09782] show, for the ornithopter segment of the Canadian barcode library:

- With the aligned Sq kernel, species-level identification reaches 85.2% (random split, S1) or 70.6% (half novel, S2), and BayesANT recognizes 77.9–93.8% of truly novel species.
- The m-2 (sitewise 2-mer) kernel yields indistinguishable performance ($<$0.5% difference), indicating only moderate gains from per-site higher-order motifs over pure position-independence.
- The K kernel achieves similar performance for small $\kappa$ (not explicitly benchmarked in [2201.09782]), and is standard when alignment is inapplicable.

A plausible implication is that for loci permitting reliable global alignment (e.g., animal COI), the Sq kernel is preferable, offering compactness and leveraging sitewise phylogenetic signal. For taxonomic groups and markers where alignment is infeasible (ITS, hypervariable regions), K is the default approach.

## 5. Extensions and Practical Implementations

### Mixture Models, Trees, and Machine Learning Integration

Beyond BayesANT, k-mer–based (K) taxonomic classification underpins methods such as MetaPalette [1602.05328], which employs "palette painting"—modeling samples as sparse mixtures over reference and hypothetical k-mer palettes, exploiting $\kappa$ as large as $30$–$50$ to achieve high strain specificity. Classification is then solved by penalized nonnegative least squares, recovering abundances of both known and novel representatives.

Resource-efficient implementations, such as those evaluated in [2303.06154], further process normalized k-mer frequency vectors using standard machine learning classifiers—subspace k-NN, shallow neural nets, bagged decision trees—yielding genus-level precision to $0.86$ with sub-millisecond per-read runtimes and memory footprints down to a few MB, far below alignment-based alternatives.

### Hybrid and Compression-Aware Models

MEM-based approaches (sequence-based or Sq) such as those in [2402.06935] extend the FM-index paradigm to arbitrarily long exact matches (not restricted to fixed k), allowing more flexible, alignment-free sequence comparison. Hybrid indices employing lossy compression (e.g., KATKA kernels, minimizer digests) achieve substantial reductions in storage and indexing time at minimal accuracy costs, narrowing the gap between pure K-mer and full-sequence Sq approaches.

## 6. Scope, Limitations, and Selection Guidelines

- Sq is preferred when: robust global alignment is possible, sitewise evolutionary signals are informative, and the repertoire of taxa is relatively stable (i.e., low likelihood of unclassifiable reads).
- K is necessary when: alignment is infeasible or not meaningful, sequences display high indel or motif variability, or when computational/algorithmic simplicity is needed for very large-scale datasets.
- For both approaches, Bayesian nonparametric priors (Pitman–Yor or Dirichlet processes) enable principled discovery and quantification of novel taxa at every rank, avoiding negative transfer or overconfidence due to hard assignment.
- Parameter choices (alignment reference, $\kappa$, Dirichlet concentration, feature preprocessing) crucially impact both statistical accuracy and computational trade-offs.

## 7. Summary Table: Sq vs. K Classification Paradigms

| Aspect                | Sq (Aligned sequence)       | K (k-mer count)                |
|-----------------------|-----------------------------|-------------------------------|
| Data structure        | Positionwise nucleotide     | k-mer frequency/count vector   |
| Alignment required    | Yes                         | No                            |
| Feature dimension     | $4p$ ($p$=length)           | $4^\kappa$                    |
| Parametric model      | Product-multinomial         | Multinomial                   |
| Sensitive to indels   | Yes                         | No                            |
| Performance (COI)     | 85.2%–70.6% (species)       | Comparable (for small $\kappa$)|
| Novelty detection     | Supported (BayesANT)        | Supported (BayesANT)          |
| Computational cost    | Moderate (if $p$ moderate)  | Grows rapidly with $\kappa$   |

Selection between Sq and K should be grounded in the molecular properties of the marker loci, the need for alignment, and the trade-off between computational resources and classification accuracy as demonstrated in empirical benchmarking studies [2201.09782], [1602.05328], [2303.06154], [2402.06935].

Source: https://www.emergentmind.com/topics/sq-or-k-taxonomic-classification