Abstract
The transformation of genomic sequences into k-mer-based feature vectors offers an efficient and convenient means for interpreting genomic signals and analyzing their similarity. However, genomic attribute signals derived directly from k-mers may contain some random background. Existing studies have confirmed that the original k-mer signals can be purified by assigning weights, entropy-based quantification, specific patterns, or simulating the original signals. Here, we propose Spark, a novel feature extraction algorithm that treats each k-mer as a resistor: the positional accumulation sum of a k-mer represents its resistance, so the sequential arrangement of k-mers mimics resistors in series, while splitting a k-mer into two shorter substrings and combining them mimics resistors in parallel to simulate the k-mer signal from its background. To compare features derived from different perspectives, we evaluate feature vectors extracted from the original signal, the simulated signal, and the ratio of the two on six genomic datasets. Theoretical analysis shows that this ratio ranges within (0, 2), and experiments reveal that on average 0.898 of original signals fall in (0, 1), with the proportion of such ratios exceeding 0.965 in two-thirds of the datasets. We therefore apply an odds transformation to ratios greater than 1 and then nonlinearly normalize all ratios with the Sigmoid function. The resulting ratio-based features improve the quantification of genomic differences: in a comparison against the best-performing alignment-free method, Spark achieves the smallest RF distance on most datasets and is within 2 of the best on the remaining ones. Spark thus offers a novel and effective approach to extracting features from the positional information of k-mers for genomic sequence vectorization, with potential applicability to other genomic analyses.
Keywords:
series-parallel of k-mer; position information; random background; dynamical splitting of k-mer; alignment-free phylogenetic analysis MSC:
92D20; 92-08; 62P10
1. Introduction
Comparative analysis of genomic sequences is a key task in downstream bioinformatics research, and analyzing genomes based on k-strings is one of the most common methods [1,2,3], such as for inferring species phylogeny. The collection of all possible k-length substrings (k-strings) is commonly referred to as kmers. After biological sequences are tokenized based on kmers, the sequences are transformed into genomic attribute vectors of kmers, such as frequency, position, etc. For example, FFP [4] directly captured kmers frequency from sequences as the feature vectors of sequences. Pwkmer [5] derived features from the positional information of kmers within sequences to facilitate similarity analysis of HIV-1 sequences. Moreover, combining the frequency and position information of kmers to extract features from the genome is also an effective strategy. For example, in our previous work, we concatenated k-mer frequency and positional data into feature vectors to identify HIV circulating recombinant forms (CRFs) [6]. CGRWDL [7] utilized the chaos game representation algorithm to map kmers at different positions of biological sequences to specific regions on a two-dimensional plane. Subsequently, a grid was overlaid on the region, and the k-mer was characterized by the horizontal and vertical coordinates of the grid cell containing it. And the coordinates of the k-mer were weighted by its k-mer frequency, so as to capture genomic feature vectors for species phylogenetic analysis and other related studies.
In addition, when performing k-mer-based feature extraction, longer sequences generally necessitate a larger k-value. For instance, in population structure analysis, k was set in the range of 13–31 [8]. For DNA sequences, the candidate k-mer set contains possibilities. Although the feature vector is a numerical vector of dimension , compared with genome alignment methods, sequence comparison methods based on k-mer perform better in terms of computational efficiency [1]. In fact, computing the distances among vectors is easier than directly comparing the overall symbolic similarity among sequences. Furthermore, to maximize the extraction of k-mer information from genomes, most existing methods traversed the sequence one character at a time (i.e., using a sliding window of length k), meaning that adjacent kmers in the sequence have overlapping strings. Therefore, the maximum number of distinct kmers actually appearing in a sequence is , where L is the length of the sequence.
However, some illegal characters could introduce noise in genomes, such as “N” in DNA sequences or “X” in protein sequences. These illegal characters cause minor variations in the genomic attribute features of kmers with originally low occurrence probabilities, resulting in small-scale errors. Analogously, this situation remained unavoidable during genome sequencing. Therefore, in second-generation sequencing technologies, to reduce such sequencing errors, sequencing samples need to be copy-extended, aiming to decrease sequencing errors and improve accuracy by increasing the number of sequencing samples [9]. Similarly, high-frequency short substrings can also be used to remove errors caused by illegal characters in kmers. In genomic sequences, shorter kmers occur at higher frequencies. However, due to their high frequency, the resulting genomic attribute vectors of kmers show little variation across different sequences. Consequently, the extracted features are inadequate for analyzing relationships among highly similar sequences. Therefore, how to integrate the high frequency of short series to perform kmers-based analysis of sequence similarity is a further issue that needs to be discussed.
At the molecular level, mutations occur in a more or less random way, and neutral mutations lead to a certain randomness in the composition of k-mer [10]. Therefore, the appearance of k-mer has a random background signal, and when using the genomic properties of k-mer, it is necessary to consider removing the random background. That means, when quantifying the genomic attributes of the k-mer sequence, the information obtained is not the entire real signal, which also contains a part of random background. Thus, simulating the random background of k-mer from its constituent components (i.e., its shorter, high frequency substrings) may be more intuitive and reliable. For example, Cvtree [10] counted the frequencies of -mer and -mer in the same genome, simulated the random background signal of k-mer based on the Markov model with -mer and -mer, and subtracted the random background from the k-mer frequency to obtain the real signal of k-mer. DLTree [11] split k-mer into 1-mer and -mer, and simulated the random background of k-mer based on the dynamical language model of 1-mer and -mer and then removed the background signal to obtain the characteristic information of k-mer in the genome.
Meanwhile, defining distances between character combination pairs via single-character positions can effectively capture genomic features. For example, IAGDP [12] and INP [13] derived features by collecting inner distance sequences of character combination pairs and counting the frequencies of different distance values, while simulating the random background of character pairs using the conditional geometric distribution based on single character frequency. Then, the true signal of character pairs was obtained by calculating the relative deviation between this background and the observed inner distance frequency. Furthermore, KINN [14] generalized the single-character approach to -mer by evenly splitting k-mer. The inner distance distributions among substring pairs of k-mer were captured, and the relative entropy of distributions was adopted to measure the contribution of kmers to the sequence, which subsequently contributed to genomic similarity analysis.
The effectiveness of the aforementioned methods has been validated across protein and DNA sequences of varying lengths. Thus, the random background of k-mer can be approximated by leveraging the information of k-mer substring. The difference among these methods lies in the specific combinations of shorter substrings employed for simulating the random background of k-mer. Cvtree adopted -mer and -mer frequencies to model the random background of k-mer, while DLTree utilized 1-mer and -mer frequency for the same purpose. In contrast, when using k-mer positional information, KINN defined the inner spacing of -mer pairs, indirectly capturing the characteristic signals of kmers. This naturally raises the question of whether any combination of k-mer substrings can also be used to simulate the random background of k-mer frequency or position. To address this, based on the previously mentioned k-mer splitting concept, the manuscript proposes a dynamic splitting strategy, namely , t, where t is variable. And this manuscript attempts to simulate the random background of k-mer by capturing the positional signal of dynamically split k-mer substrings in the genome.
On the other hand, the occurrences of the same k-mer at various genomic positions could be analogized to a series connection of resistors that share the same type but with different resistance values. Along the forward direction of the sequence, the positions of each k-mer are collected and summed. And the sum of positions is taken as the resistance value of the corresponding k-mer component. Consequently, different kmers correspond to distinct resistor types, and the positional sum of each k-mer serves as its resistance. The positional information of k-mer substring is similarly calculated. In accordance with the previous definitions, the dynamically split substrings of k-mer are analogized to two different resistor types, and their parallel connection is used to simulate the random background of the k-mer in the genome. In the process of removing the random background, the characteristic signal of kmers in biological sequences was captured by calculating the ratio between the k-mer signal and its simulated signal. Additionally, to verify whether the simulated signal can be regarded as random background, we performed comparative phylogenetic analysis based on k-mer positional information, k-mer simulated signals, and the characteristics of kmers after removing the simulated signal. The results indicate that the signal after removing the random background provides the best performance in phylogenetic analysis. Finally, we conducted phylogenetic analysis experiments on six datasets of different lengths, comparing our method with nine other state-of-the-art alignment-free methods that extract k-mer features from various perspectives. The results show that our method achieves the best or near-best performance among the compared methods on the datasets considered.
2. Materials and Methods
2.1. Data
To evaluate the overall performance of Spark, genomic datasets of various lengths were selected for performance assessment experiments. The DNA type datasets contained the complete mitochondrial genomes of 30 mammalian species [15], human immunodeficiency virus type 1 (HIV-1), hepatitis E virus (HEV) [16], hepatitis B virus (HBV), human rhinovirus (HRV) and hepatitis C virus (HCV). Additionally, performance testing was also conducted on rRNA gene sequences, including the 18sRNA gene of tetrapods [12]. The sequences in these datasets have a sequence length ranging from 2042 to 17,084. The accession numbers and names of the sequences are shown in Tables S1–S6 in the Supplementary Materials.
2.2. Analogize K-Mer to Resistors in Series
For a sequence s of length L, applying a fixed-length window of size k partitions it into overlapping k-strings. By recording the position of the first character of each k-string within the sequence, the position information of identical k-strings (i.e., k-mer) is transformed into a vector. If identical k-strings are defined as ‘’”, then the position vector can be denoted as . For instance, s = “ACGAGATAACAGATA”, k is set to 2, . After obtaining the position vector of k-mer, the position vector is normalized with the sequence length, that is,
After partitioning the sequence based on k-strings, identical k-strings are labeled as kmers, as illustrated in Figure 1a. When the same k-mer is displayed along the sequence (Figure 1b), it can be observed that the k-mer appears at multiple distinct positions across the genome. If the k-mer is analogized to a resistor, this scenario corresponds to resistors of the same type (i.e., the same k-mer) connected in series in a circuit. Intuitively, the positional information of k-mer within the genome can serve to quantify the resistance values of a resistor. In this manuscript, the positional accumulation sum of each k-mer serves as the corresponding resistance value of that resistor. Just as the total resistance of resistors connected in series equals the sum of their individual resistances, the occurrences of an identical k-mer at different genomic positions are treated as series-connected resistors of the same type, so that its positional accumulation sum is exactly the total series resistance. For example, the resistance of a resistor (any k-mer) in the circuit is the positional accumulation sum of in sequence s, denoted as . According to the previous definition, can be shown as follows:
Figure 1.
Sequence analysis based on the concept of resistor series and parallel connections. (a) Illustration of segmenting a sequence into k-strings using a sliding window and connecting them in series. Each small rectangle represents a k-string; identical k-strings appearing at different positions within the sequence are treated as series configurations of resistor elements of the same type but differing resistance values. (b) Simulates the resistance of within the sequence using two distinct combinations of t-mer and -mer, where , and are arranged in parallel (here, let t be 1). (c) Simulating by connecting and in parallel within the sequence. (d) Simulating by connecting and in parallel within the sequence. (e) Purification of the extracted ratio signals. (f) Nonlinear normalization of the purified ratio signals using the Sigmoid function. (g) Construction and visualization of feature vectors, followed by computation of a distance matrix using the cosine distances between the feature vectors, and finally construction of a neighbor-joining (NJ) tree for phylogenetic analysis.
It is worth noting that the positional accumulation measures more than the occurrence count of a k-mer: the spatial distribution of its copies in the genome is also taken into account. The multiple copies of the same k-mer may appear clustered in nearby regions or scattered across different genomic positions. The summation operation incorporates this distributional difference into the feature, so the positional signal includes a spatial heterogeneity that frequency information does not capture.
For example, suppose appears four times in sequence s, with . The resistance of in the circuit is the sum of the elements of , i.e., .
2.3. Modeling Random Background of K-Mer with a Parallel Prefix–Suffix Mode
Although short strings appear much more frequently than long ones, it is exactly for this reason that, when used alone, they cannot adequately quantify the differences among sequences. To simulate the random background of k-mer, we adopt a dynamic splitting strategy, i.e., splitting k-mer into t-mer and -mer. The t-mer may serve as either the prefix or the suffix of k-mer. To ensure format consistency, we split the k-mer () into and , as follows:
Subsequently, the resistance value of is simulated by connecting two different types of resistors in parallel (see Figure 1b). According to the definition in Equation (2), the resistance value of resistor i is denoted as , where . Furthermore, and are connected in parallel to simulate the random background of . For the circuit s, the parallel simulated resistances with and are denoted as . Similarly, and are connected in parallel to simulate the random background of , and the parallel simulated resistances are recorded . The schematic diagrams are shown in Figure 1c,d.
On the other hand, once appears in sequence s, its constituent shorter t-mer and -mer (i.e., ) must also appear. As a result,
According to the property of parallel resistors, the reciprocal of the total resistance equals the sum of the reciprocals of the resistances of the individual branches. Therefore, after simplification, and are shown as follows:
Conceptually, this parallel combination serves as a baseline expectation that is independent of the overall specificity of the k-mer, namely the background abundance predicted by the composition of its short substrings.
Let the random background of be . After and are obtained, can be directly computed by taking the average of and :
then, from the two lower bounds above,
then,
From a probabilistic perspective, the occurrence probability of k-mer is necessarily lower than that of its simulated substrings. However, Equation (7) reveals that the relationship between and extends beyond simply ‘’less than”. When , the signal and random background are equal, so cannot distinguish the difference. When , the obtained signal is smaller than the random background. This implies that indicates a relatively weak signal, and this effect should be equivalent to that of . In other words, when one of and greatly exceeds the other, compression of the ratio signal information is beneficial for preventing the inclusion of confounding random background. In contrast, the middle value of interval (0,1) should remain largely unchanged to retain its original information. When , it indicates that the signal is greater than the random background. Although such cases are likely rare, whether they can be further used as features depends on analyzing the actual data. Accordingly, the ratio signals are divided into two intervals, and an odds transformation is performed on all ratios exceeding 1. The results are shown as follows:
Synthesizing the above analysis, to further nonlinearly quantify the difference of , we apply the Sigmoid function to the ratio signals and denote the transformed values as , i.e.,
After sorting the kmers alphabetically and encoding them with natural numbers, the sequence s can be converted into a numerical vector v:
After obtaining the feature vectors of all sequences in the dataset, we compute the cosine distance matrix among the feature vectors and further analyze their phylogenetic relationships using MEGA11.
For convenience, Table 1 summarizes the main symbols and mathematical notations used in this work.
Table 1.
Main symbols and mathematical notations.
3. Results
3.1. Fine-Tuning Parameter Based on Phylogenetic Analysis
In the process of k-mer random background simulation, to ensure that the simulated information shares some information with the original data, the length difference between the chosen short substring and the k-mer should not be too large; for example, the length of short strings was and in CVTree [10] and in DLTree [11]. When simulating the random background of k-mer, we introduce an adjustable partitioning parameter t for fitting, i.e., t-mer and -mer. Therefore, two key parameters need to be discussed before conducting sequence similarity analysis, i.e., the k-mer length k and the partitioning parameter t.
Sequence similarity analysis can be directly performed using sequence alignment methods. However, its efficiency depends on the size of the dataset and the length of the sequence. In contrast, conducting sequence similarity analysis with alignment-free methods can circumvent the above-mentioned issues. Thus, the parameters and performance of an alignment-free algorithm can be assessed by comparing the topological relationships between the phylogenetic tree and the reference tree, which are built using alignment-free methods and alignment methods, respectively. The most commonly used tool for measuring the topological relationship between two phylogenetic trees is Robinson–Foulds (RF) distance [17]. A small RF value indicates that the phylogenetic tree construction algorithm is effective. When RF is 0, it indicates that the two trees are completely identical. In our manuscript, the reference phylogenetic tree was constructed by MAFFT [18]. To determine the values of parameters k and t, we conducted comparative analyses based on RF distance on the HIV-1 and HEV datasets. While fixing k, we systematically explored all integer values of , constructing a series of distinct partitioning schemes. By controlling the value of parameter t, the relationship between k and RF is shown in Figure 2.
Figure 2.
Relationship between RF values and different combinations of the parameters k and t. The RF distances are relatively small when k lies between 8 and 10.
From Figure 2, we observe that when k lies between 8 and 10, the RF distances are relatively small, indicating that the k values within this range are more conducive to enhancing the consistency of tree topological structure. Therefore, the middle value of the range (i.e., ) is selected as a compromise, and then the range of t values is discussed. After setting the value of k, we tested the RF distance values for different values of parameter t () on five viral datasets. The results are shown in Table 2. As can be observed from Table 2, the phylogenetic tree constructed using features extracted at produces superior results compared with the reference phylogenetic tree. Balancing performance and stability, we select and as the parameter values for subsequent experiments.
Table 2.
Performance comparison of Spark with different parameters of t on five viral datasets. Bold values indicate the minimum in each row.
3.2. How Does the Simulated Signal Affect the Original Signal?
3.2.1. Comparative Analysis of the Proportion of
After setting k and t, we further analyzed the proportional distribution of across different datasets. For instance, for each sequence in the HIV-1 dataset, we collected the values of all kmers present in the sequence. For each sequence in the HIV-1 dataset, the percentages of values exceeding 1 and falling below 1 were computed, and their overall distributions within the dataset were illustrated separately via histograms. The proportion of in the HIV-1 data is shown in Figure 3. As shown in the figure, the average proportion of ratios less than 1 is 98.2%, while the average proportion of ratios greater than 1 is only 1.8%. This is also consistent with the previous theoretical analysis. Histogram comparisons for the other datasets are shown in Figures S1–S6.
Figure 3.
Histogram showing the distribution of per-sequence proportions of and in the HIV-1 dataset. The x-axis represents the proportion of sequences falling into each ratio category, and the y-axis indicates the frequency or density. The solid vertical line indicates the proportion mean. The results confirm that the vast majority of ratios are below 1 (98.2% on average).
Subsequently, to test whether this fact holds true for all datasets, Figure 4 shows the proportions of ratios above 1 and below 1 in each dataset. As shown in Figure 4, the proportion of ratios greater than 1 exceeds 0.965 in four datasets, while the proportions for the remaining two datasets are 0.843 and 0.639, respectively. To further examine how these cases (ratio > 1) are distributed across sequences, we collected the maximum ratio values for each dataset; the results are presented in Figure 4. All maximum values are less than or equal to 1.395. Without loss of generality, let . We observe that arises when the t-mer is present only in the vicinity of the k-mer occurrence positions. In contrast, the shorter -mer is too broadly distributed, driving the ratio above 1 but not beyond 1.5.
Figure 4.
The proportions of values exceeding 1 and falling below 1, as well as the maximum values for each dataset, are presented in the figure across the six datasets. The results show that ratios exceeding 1 are rare across all datasets, and all maximum ratios are below 1.5.
3.2.2. The Effects of the Features of the Simulated Signal
Based on the above definitions and analysis, four types of k-mer-based feature vectors can be derived from the genome, i.e., , , , and . To reveal the feature differences among indirect feature vectors (), the most direct way is to quantitatively compare them with the direct feature vector (). To facilitate comparative analysis, all four feature vectors were normalized using min–max scaling prior to comparison, ensuring that they were evaluated on the same scale. We then collected the components of each feature vector and used violin plots to visualize their distributions, alongside the original signal R. Additionally, the Pearson correlation coefficients between each indirect feature vector and the original feature vector were calculated to quantify their relationships.
Figure 5 presents a comparative illustration of the distribution patterns and simple correlation coefficients of the direct and indirect feature vector components for two distinct sequence types. The four feature vectors belonging to the same category are illustrated in Figures S7 and S8. As can be seen from Figure 5, in B_A04321 and A1_AB098333, the components of the direct feature vector exhibit a relatively concentrated distribution with no distinct peaks. By contrast, the components of indirect feature vectors show clearer and more variable peak structures, particularly in the A1_AB098333 group, where the interquartile ranges are wider and the quartile values differ more markedly. And the extremely low values in the direct feature vector are amplified to varying degrees across the three indirect feature vectors. The component distributions of share a broadly similar structure in Figure 5. Nevertheless, displays notably higher volatility, including a bimodal pattern. Meanwhile, the components of show a relatively flat distribution with a broader range of values. In terms of correlation coefficients, exhibits the weakest correlation with in the sequences of both class A and class B. The correlation coefficients of and with are relatively close. And the correlation of with is slightly higher than the correlation of with .
Figure 5.
Comparison of four feature vectors for sequences B_A04321 and A1_AB098333 from the different type in HIV-1 dataset (, ). The upper-left corner shows the simple correlation coefficient between the direct feature vector and one of the indirect feature vector. The indirect features amplify low values of the original signal, and exhibits the weakest correlation with .
3.2.3. Performance Demonstration of Four Feature Vectors on Viral Datasets
Based on the above analysis, if is regarded as the original signal, is the simulated feature signal, and is the clean signal. Further comparative experiments of the four feature vectors were conducted on more similar viral sequences by constructing phylogenetic trees. The constructed trees were compared with the reference trees based on the Robinson–Foulds (RF) distance generated. The reference tree was generated by MAFFT. In feature extraction, the parameters k and t were set to 9 and 3, respectively. The results are shown in Table 3.
Table 3.
Performance comparison of four feature vectors using RF distance on multiple viral datasets with and . Bold values indicate the minimum in each row.
As shown in Table 3, after replacing the original signal with the ratio (), the RF values decrease overall, indicating that the feature vector signals are purified. The relative improvement of over the original signal , computed as and shown in parentheses in Table 3, ranges from 19.6% (HBV) to 55.9% (HRV). On the HEV, HIV-1 and HBV datasets, the RF distance between the reference tree and the tree built from the feature vector is also lower, in comparison to those built from and feature vectors. This phenomenon indicates that although introducing simulated signals in some cases may give modeling advantages, its effectiveness largely depends on the inherent diversity of the sequence data. In highly similar datasets, additional signals may introduce redundant or even misleading information, thereby undermining the model’s discriminative ability. Moreover, after nonlinearly normalizing the differences using , the RF distances of the reference tree and constructed tree based are notably reduced in most cases, and the deviation from the minimum RF distance is only 2 in a few datasets, demonstrating that Spark enhances the ability of k-mer feature vectors to quantify differences.
In addition to the classification performance, we also evaluated the computational cost of Spark. With the parameters fixed at and , the runtime and peak memory required to compute the distance matrices of the six datasets were measured on a desktop computer with an Intel Core i9-14900K CPU, 96 GB RAM, Windows 11 and Python 3.10. As shown in Table 4, the entire procedure of feature extraction and distance-matrix computation completes within about 3 s even for the largest dataset (HRV, 116 sequences, 2.85 s) and within about 1.5 s for the smaller datasets, with the peak memory not exceeding about 331 MB in all cases. These results demonstrate that Spark is computationally efficient for datasets of the scale considered in this study.
Table 4.
Runtime and peak memory of the distance-matrix computation of Spark (, ) on the six benchmark datasets.
3.3. Comparative Visualization of Spark-Based Species Phylogenetic Trees
Computing distance matrices from k-mer-based feature vectors and then applying the neighbor-joining method for phylogenetic analysis is a common approach to demonstrate sequence similarity. In the comparative experiment, the reference tree of genomes was constructed by MAFFT and the parameters k and t were set to 9 and 3.
We first performed phylogenetic analysis on the complete mitochondrial genomes of 30 mammalian species [15] to evaluate its effectiveness in the species classification task. The RF distances between the reference tree and the phylogenetic tree built from and are (14, 20, 12, 4), respectively. Among the four feature vectors, the Spark-based feature vector achieved the smallest RF distance. The RF value of the Spark-based method was reduced to 4. Furthermore, we performed a structural visual comparison between the mammalian phylogenetic tree generated by Spark and the reference tree generated by MAFFT, with the iTOL tool, as shown in Figure 6. The result shows that the phylogenetic trees constructed by Spark can be accurately classified, and the structure of the phylogenetic tree is highly consistent with the authoritative classification system provided by MAFFT.
Figure 6.
Comparison of phylogenetic trees of the complete mitochondrial genomes of 30 mammalian species constructed using Spark (with parameters k and t set to 9 and 3) and MAFFT. The phylogenetic tree constructed by Spark (left) and the MAFFT-based reference tree (right) have an RF distance of 4.
To further validate the applicability of our method, we then demonstrated the phylogenetic tree structures on viral datasets with a larger number of sequences and higher inter-sequence similarity. Then, we proceeded to demonstrate the species phylogenetic trees generated by Spark on the datasets of HIV-1, HEV and HCV. The phylogenetic trees of remaining datasets are presented in Figures S9–S11 in the Supplementary Materials. The HIV-1 phylogenetic tree constructed based on Spark is shown in Figure 7. As shown in the figure, all classes in the dataset were accurately clustered, and the outgroup subtypes (N, O, P) were grouped separately. Furthermore, the higher similarity between subtypes A and G, and between B and D, within the HIV-1 dataset is also illustrated in Figure 7.
Figure 7.
The phylogenetic tree of HIV-1 was constructed using Spark, with parameters k and t set to 9 and 3, respectively.
Similarly, the Spark-based phylogenetic trees for HEV and HCV are shown in Figure 8 and Figure 9, respectively. The HEV dataset contains 48 sequences across four categories, while the HCV dataset comprises 82 sequences across six categories. As can be observed, all subtypes were correctly clustered.
Figure 8.
The phylogenetic tree of HEV was constructed based on Spark, with parameters k and t set to 9 and 3, respectively.
Figure 9.
The phylogenetic tree of HCV was constructed using Spark, with parameters k and t set to 9 and 3, respectively.
3.4. Performance Evaluation of Spark Against Other State-of-the-Art Methods
Beyond assessing the effectiveness of the algorithm in extracting sequence features by examining the phylogenetic tree structures, we further employed the treedist program in PHYLIP [17] for quantitative evaluation of the tree topologies. We compared the performance of Spark with nine state-of-the-art alignment-free methods. Among the ten methods, nine methods are k-mer-based approaches, i.e., CGRWDL [7], KINN [14], Pwkmer [5], DLTree [11], FFP [4], Cvtree [10], d2 [19], RTD [20]. The remaining method, BBC [21], is an alignment-free approach that does not rely on k-mer information. The last five methods were integrated into Alfree [1]. Table 5 shows the RF distance of each method for each dataset. As shown in Table 5, although Spark shows slight discrepancies on the HEV and HBV datasets, it overall demonstrates superior performance. Furthermore, both Pwkmer [5] and Spark perform phylogenetic analysis based on positional information, differing only in how the features are defined. However, comparative experiments show that Spark significantly enhances the ability to analyze genome similarity based on positional feature vectors.
Table 5.
Comparison of RF distance with traditional alignment-free methods. Bold values indicate the minimum in each row.
4. Discussion
The extraction of feature information from sequences via k-mers plays a crucial role in bioinformatics analysis. Spark conducts genome feature extraction on single-stranded DNA sequences by establishing an analogy between the ordered occurrence of k-mers and the series connection of resistors. Building on this analogy and inspired by the series-parallel principles of resistors, this manuscript extracts genomic feature vector by summing k-mer positions (series) in the genome and simulates a k-mer signal in parallel using k-mer prefixes and suffixes. Moreover, we investigate the differences between the original signal , the simulated signal (), and their ratio in the context of phylogenetic-based genome similarity analysis. During the simulation of parallel resistors, we find that the effectiveness of the simulated signal for feature extraction remains uncertain. Therefore, whether the simulated signal conveys informative content or acts as confounding noise also remains ambiguous. Consequently, the following question naturally arises.
4.1. Is the Simulated Signal Useful Information or Interfering Information?
Based on the experimental results on the datasets used in this manuscript, we observe that the simulated feature signal not only captures the dynamics of evolution to a certain extent, but also enables accurate classification of different species datasets. Compared with directly using the simulated signal, our algorithm improves classification accuracy under conditions of high sequence similarity by appropriately removing simulated signals. This phenomenon indicates that although the simulated signals may give modeling advantages in some cases, their effectiveness largely depends on the inherent diversity of the sequence data. Under the condition of low diversity, additional signals may introduce redundant or even misleading information, thereby undermining the model’s discriminative ability.
4.2. Why Is Chosen to Purify Feature Vectors?
As shown in Figure 4, the proportion of cases where is relatively high, which is consistent with probability theory. The ratio provides a normalized measure: values far from 1 indicate meaningful biological differences, while values near 1 represent weak information. Accordingly, for cases where we employ an odds transformation to project these values into the (0, 1) range. Subsequently, the ratios are nonlinearly transformed using the Sigmoid function. As the experimental results show, ratio-based feature vector reduces RF distances in phylogenetic trees, demonstrating that Spark enhances the performance of genome similarity analysis.
5. Conclusions
Genome discretization into vectors provides an efficient analytical tool for bioinformatics tasks. In this work, we introduce the series-parallel resistor analogy from circuit theory into genomic k-mer analysis. Specifically, the position of a single k-mer occurring in a genome is analogized to the series connection mode of resistors of the same type but with different resistances in an electrical circuit. The resistance value corresponding to a k-mer is set to the sum of its positions in the genome. To simulate the random background of k-mer, we split it into two substrings and regard them as two resistors with resistances equal to the sum of their genomic positions. And the random background of k-mer is simulated by a parallel resistor configuration of them. As shown by the experimental results on the datasets used in this study, the ratio of the original k-mer signal to the simulated signal can quantify genomic differences. However, because this ratio tends to cluster near 1, making further discrimination difficult, we apply the Sigmoid function to nonlinearly amplify the ratio. Experimental results demonstrate that this method effectively quantifies genomic differences and improves the accuracy of RF-distance-based phylogenetic tree reconstruction. In summary, the analogy between series/parallel resistors and the positional distribution of kmers and their substrings may offer a novel computational perspective for genome similarity analysis, with potential for extension to other sequence analysis problems. While dynamic partitioning at a single k-mer length can already yield informative features, there remains considerable potential for further enhancement. A multi-scale strategy that further mines overlapping k-mer signals is therefore a natural extension of our study, offering deeper insights into genomic features.
Supplementary Materials
The following supporting information can be downloaded at https://www.mdpi.com/article/10.3390/math14183327/s1, Figure S1: Histogram of greater than 1 (left) and less than 1 (right) in 18SRNA dataset. The solid vertical line indicates the data mean; Figure S2: Histogram of greater than 1 (left) and less than 1 (right) in HBV dataset. The solid vertical line indicates the data mean; Figure S3: Histogram of greater than 1 (left) and less than 1 (right) in HCV dataset. The solid vertical line indicates the data mean; Figure S4: Histogram of greater than 1 (left) and less than 1 (right) in HEV dataset. The solid vertical line indicates the data mean; Figure S5: Histogram of greater than 1 (left) and less than 1 (right) in HRV dataset. The solid vertical line indicates the data mean; Figure S6: Histogram of greater than 1 (left) and less than 1 (right) in mammalian genomes. The solid vertical line indicates the data mean; Figure S7: Comparison of four feature vectors for sequences A1_AB098332 and A1_AB098333 from the identical type in HIV-1 dataset (k = 9, t = 3); Figure S8: Comparison of four feature vectors for sequences B_A04321 and B_A07867 from the identical type in HIV-1 dataset (k = 9, t = 3); Figure S9: The phylogenetic tree of HBV was constructed using Spark, with parameters k and t set to 9 and 3, respectively; Figure S10: The phylogenetic tree of 18SrRNA was constructed using Spark, with parameters k and t set to 9 and 3, respectively; Figure S11: The phylogenetic tree of HRV was constructed using Spark, with parameters k and t set to 9 and 3, respectively; Table S1: The detail description of HIV-1, including type and accession number of sequence; Table S2: The detail description of HCV, including type and accession number of sequence; Table S3: The detail description of HBV, including type and accession number of sequence; Table S4: The detail description of HEV, including type and accession number of sequence; Table S5: The detail description of HRV, including type and accession number of sequence; Table S6: The detail description of 18SRNA, including type and accession number of sequence.
Author Contributions
Conceptualization, Z.X., J.Z. and R.T.; Methodology, Z.X., J.Z. and R.T.; Software, Z.X., J.Z. and R.T.; Validation, Z.X., J.Z., J.H. and R.T.; Formal Analysis, Z.X., J.Z., J.H. and R.T.; Data Curation, R.T.; Writing—Original Draft, Z.X. and J.Z.; Writing—Review and Editing, Z.X., J.H. and R.T.; Supervision, J.H. and R.T.; Funding Acquisition, R.T. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by the National Natural Science Foundation of China (Grant No. 12501722), the Science and Technology Research Program of Chongqing Municipal Education Commission (Grant No. KJQN202300555), the Chongqing Normal University Foundation Project (Grant No. 22XLB032), and the Chongqing Normal University Graduate Research Innovation Project (Grant No. YKC26035).
Data Availability Statement
The genomic sequence data analyzed in this study are publicly available from GenBank https://www.ncbi.nlm.nih.gov/genbank/ (accessed on 9 September 2026). The accession numbers of all sequences are listed in Tables S1–S6 in the Supplementary Materials. The source code of Spark is available at https://github.com/Runbin-tang/Spark (accessed on 15 October 2025).
Acknowledgments
The authors thank the anonymous reviewers for their valuable suggestions.
Conflicts of Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
References
- Zielezinski, A.; Vinga, S.; Almeida, J.; Karlowski, W.M. Alignment-free sequence comparison: Benefits, applications, and tools. Genome Biol. 2017, 18, 186. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Jenike, K.M.; Campos-Domínguez, L.; Boddé, M.; Cerca, J.; Hodson, C.N.; Schatz, M.C.; Jaron, K.S. k-mer approaches for biodiversity genomics. Genome Res. 2025, 35, 219–230. [Google Scholar] [CrossRef] [Scilit]
- Roberts, M.D.; Davis, O.; Josephs, E.B.; Williamson, R.J. k-mer-based approaches to bridging pangenomics and population genetics. Mol. Biol. Evol. 2025, 42, msaf047. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Sims, G.E.; Jun, S.R.; Wu, G.A.; Kim, S.H. Alignment-Free Genome Comparison with Feature Frequency Profiles (FFP) and Optimal Resolutions. Proc. Natl. Acad. Sci. USA 2009, 106, 2677–2682. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ma, Y.; Yu, Z.; Tang, R.; Xie, X.; Han, G.; Anh, V.V. Phylogenetic analysis of HIV-1 genomes based on the position-weighted k-mers method. Entropy 2020, 22, 255. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Tang, R.; Yu, Z.; Ma, Y.; Wu, Y.; Phoebe Chen, Y.P.; Wong, L.; Li, J. Genetic Source Completeness of HIV-1 Circulating Recombinant Forms (CRFs) Predicted by Multi-Label Learning. Bioinformatics 2021, 37, 750–758. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wang, T.; Yu, Z.G.; Li, J. CGRWDL: Alignment-free phylogeny reconstruction method for viruses based on chaos game representation weighted by dynamical language model. Front. Microbiol. 2024, 15, 1339156. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Shi, G.; Dai, Y.; Zhou, D.; Chen, M.; Zhang, J.; Bi, Y.; Liu, S.; Wu, Q. An Alignment- and Reference-Free Strategy Using k-Mer Present Pattern for Population Genomic Analyses. Mycology 2025, 16, 309–323. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Nazari, F.; Patel, S.; LaRocca, M.; Sansevich, A.; Czarny, R.; Schena, G.; Murray, E.K. Lossless and reference-free compression of FASTQ/A files using GeneSqueeze. Sci. Rep. 2025, 15, 322. [Google Scholar] [CrossRef] [Scilit]
- Qi, J.; Luo, H.; Hao, B. CVTree: A phylogenetic tree reconstruction tool based on whole genomes. Nucleic Acids Res. 2004, 32, W45–W47. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wu, Q.; Yu, Z.G.; Yang, J. DLTree: Efficient and accurate phylogeny reconstruction using the dynamical language method. Bioinformatics 2017, 33, 2214–2215. [Google Scholar] [CrossRef] [Scilit] [PubMed][Green Version]
- Xie, X.H.; Yu, Z.G.; Han, G.S.; Yang, W.F.; Anh, V. Whole-proteome based phylogenetic tree construction with inter-amino-acid distances and the conditional geometric distribution profiles. Mol. Phylogenet. Evol. 2015, 89, 37–45. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Xie, X.H.; Yu, Z.G.; Ma, Y.L.; Han, G.S.; Anh, V. A novel genome signature based on inter-nucleotide distances profiles for visualization of metagenomic data. Phys. A Stat. Mech. Appl. 2017, 482, 87–94. [Google Scholar] [CrossRef] [Scilit]
- Tang, R.; Yu, Z.; Li, J. KINN: An alignment-free accurate phylogeny reconstruction method based on inner distance distributions of k-mer pairs in biological sequences. Mol. Phylogenet. Evol. 2023, 179, 107662. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Tang, J.; Hua, K.; Chen, M.; Zhang, R.; Xie, X. A novel k-word relative measure for sequence comparison. Comput. Biol. Chem. 2014, 53, 331–338. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Chang, G.; Wang, H.; Zhang, T. A novel alignment-free method for whole genome analysis: Application to HIV-1 subtyping and HEV genotyping. Inf. Sci. 2014, 279, 776–784. [Google Scholar] [CrossRef] [Scilit]
- Robinson, D.F.; Foulds, L.R. Comparison of Phylogenetic Trees. Math. Biosci. 1981, 53, 131–147. [Google Scholar] [CrossRef] [Scilit]
- Katoh, K.; Misawa, K.; Kuma, K.i.; Miyata, T. MAFFT: A novel method for rapid multiple sequence alignment based on fast Fourier transform. Nucleic Acids Res. 2002, 30, 3059–3066. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Vinga, S.; Almeida, J. Alignment-free sequence comparison—A review. Bioinformatics 2003, 19, 513–523. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kolekar, P.; Kale, M.; Kulkarni-Kale, U. Alignment-free distance measure based on return time distribution for sequence analysis: Applications to clustering, molecular phylogeny and subtyping. Mol. Phylogenet. Evol. 2012, 65, 510–522. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Liu, Z.; Meng, J.; Sun, X. A novel feature-based method for whole genome phylogenetic analysis without alignment: Application to HEV genotyping and subtyping. Biochem. Biophys. Res. Commun. 2008, 368, 223–230. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.








