A method and device for determining homology of metagenomic contigs based on multi-dimensional feature fusion and convolutional neural network
By employing multidimensional feature fusion and convolutional neural network methods, the problem of classifying Hi-C sequencing data among highly homologous strains was solved, achieving high-precision and interference-resistant metagenomic contig homology determination and improving the accuracy and adaptability of assembly.
Patent Information
- Application Number
- CN202611239773.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2046-08-17
AI Technical Summary
Existing technologies do not fully utilize the local topological features of Hi-C sequencing data when dealing with highly homologous strains, and are susceptible to assembly errors and multiple alignment noise, resulting in poor classification of metagenomic contigs.
A multidimensional feature fusion and convolutional neural network approach is adopted. Through high-confidence interaction feature extraction, image-based composite feature map reconstruction and center boundary masking techniques, combined with a convolutional neural network model, the homology of metagenomic contigs is determined. This includes multiple alignment conflict resolution, physical and enzyme digestion dual constraints, sparse matrix generation and two-dimensional composite feature map processing, and outputting the connection score.
It improves the anti-interference ability and judgment accuracy of metagenomic assembly, can identify subtle differences in the spatial distribution structure of the genome, enhances the distinguishability of similar strains, and has adaptability to different species and sequencing depths, achieving high-accuracy judgment.
Smart Images

Figure CN122799951B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary field of bioinformatics and deep learning, specifically to a method and apparatus for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks. Background Technology
[0002] In metagenomic research, classifying fragmented contigs to their corresponding species (binning) is a core task. Traditional methods rely on k-mer frequency and coverage, but they are less effective when dealing with highly homologous strains. Hi-C technology provides spatial interaction information, but existing Hi-C utilization methods are mostly simple linear counting, which cannot fully utilize the local topological features in Hi-C heatmaps (such as interaction attenuation patterns, signal uniformity, etc.) and are susceptible to assembly errors and multiple alignment noise.
[0003] The information in the background section is merely intended to illustrate the general background of the invention and should not be construed as an admission or implication in any way that such information constitutes prior art known to those skilled in the art. Summary of the Invention
[0004] To address at least some of the technical problems existing in the prior art, this invention provides a complete logical framework from raw alignment data to homology probability output. It utilizes Hi-C sequencing data characteristics and a convolutional neural network (CNN) to determine whether metagenomic contigs originate from the same physical genome. Specifically, this invention includes the following:
[0005] A first aspect of the present invention provides a method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks, comprising the following steps: (1) A high-confidence interaction feature extraction step, which includes: performing multiple alignment conflict resolution processing on each pair of reads in the Hi-C alignment file to determine the alignment coordinates, performing physical and enzyme digestion dual constraint processing on the alignment coordinates to obtain effective interaction pairs, and discretizing and binning the effective interaction pairs into whole genomes according to a preset resolution to obtain a file containing a sequence information table with a global offset index and a sparse matrix recording the spatial interaction strength; (2) The image-based composite feature map reconstruction step includes: extracting the internal interaction sub-matrix and the cross interaction sub-matrix from the file, performing nonlinear enhancement and scaling on the extracted sub-matrix to obtain the scaled sub-matrix, performing topological stitching on the scaled sub-matrix to obtain the two-dimensional composite feature map, and performing center boundary masking on the two-dimensional composite feature map to obtain the reconstructed two-dimensional composite feature map. (3) The determination step includes: inputting the two-dimensional composite feature map into a trained convolutional neural network model and outputting a connection score, wherein the connection score is used to characterize the probability that the overlapping groups to be determined belong to the same microbial genome.
[0006] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural network according to the present invention, step (1) of performing multiple alignment conflict resolution processing on each pair of reads in the Hi-C alignment file includes: grouping and caching all alignments of the same pair of reads into first reads and second reads, selecting the record with the highest alignment quality value, if the alignment quality values are the same, selecting the alignment record with the smallest edit distance, if they still cannot be distinguished, calculating the effective alignment length by parsing the CIGAR string, and selecting the record with the longest alignment length as the unique exact physical location.
[0007] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural network according to the present invention, step (1) of performing physical and enzyme digestion dual constraint processing on the alignment coordinates includes: removing redundant fragments that failed to align, were below a preset alignment quality value threshold, and were marked as PCR repeats; mapping the genomic coordinates to the restriction enzyme digestion fragment index; removing self-circularization noise that aligns to the same enzyme digestion fragment at both ends; and removing short-distance connection noise that is too close in physical distance.
[0008] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention, the image-based composite feature map reconstruction includes: extracting the internal interaction sub-matrices and the cross-interaction sub-matrices between the contigs to be determined; performing a log(1+x) nonlinear transformation on the values of each sub-matrix; uniformly scaling them to a fixed resolution of 32×32 through bilinear interpolation; and stitching the scaled sub-matrices together to form a 64×64 two-dimensional composite feature map.
[0009] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention, the central boundary masking process includes: performing pixel masking zeroing in the central cross region of the stitched image; Preferably, after the topology splicing, adaptive truncation and normalization processing is further performed to eliminate the impact of a very small number of abnormal high-frequency signals on the model gradient.
[0010] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention, the trained convolutional neural network model comprises three consecutive convolutional modules, each module comprising a 3×3 two-dimensional convolutional layer, batch normalization, ReLU activation function and a 2×2 max pooling layer; Preferably, after the input composite feature map is processed through three convolutional modules, the size is reduced to 8×8 and the number of channels is increased to 128; Preferably, the flattened one-dimensional vector is processed by a fully connected layer and Dropout regularization to output an unnormalized logical value with a dimension of 2. Preferably, the logical value is mapped to a probability value representing "connected" and "not connected" using the Softmax function, and the "connected" probability value is used as the connection score.
[0011] In some embodiments, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention, the trained convolutional neural network model is obtained through the following steps: a. Perform controlled fragmentation simulation on reference genome sequences of known species origins to generate a set of simulated contigs carrying unique traceability identifiers, and use these to construct truth mapping relationships; b. Obtain the Hi-C contact matrix of the simulated overlap group using the same processing procedure as described above; c. Based on the truth mapping relationship, simulated overlapping groups originating from the same traceability identifier are marked as positive samples, simulated overlapping groups originating from different traceability identifiers are marked as negative samples, and positive samples are oversampled. d. Obtain the composite feature map for training from the simulated Hi-C contact matrix using the same processing procedure as described above; e. Using the training composite feature map and its labels, the convolutional neural network is trained through cross-entropy loss and gradient backpropagation. After each training round, the accuracy is evaluated on an independent validation set. When the validation set accuracy exceeds a preset threshold, early stopping is triggered to lock the model weights.
[0012] In some implementations, according to the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention, the controlled fragmentation simulation includes: retaining a number of core sequences with the longest length in each reference genome; randomly cutting the retained sequences using a dynamic sliding window, with the cutting step size randomly determined within the range of 1 to 1.5 times the preset minimum length threshold; and judging the length of the remaining sequence before each cutting. If the remaining length is less than twice the minimum length threshold, the remaining part is retained as a complete simulated contig to avoid generating excessively short sequences.
[0013] In some implementations, the method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to the present invention further includes, before constructing training samples: performing symmetric closure processing on the simulated Hi-C contact matrix to ensure complete extraction of cross-contig interaction information; and removing contigs with lengths below a threshold and positive sample pairs with overly sparse interaction signals.
[0014] A second aspect of the present invention provides an apparatus for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks, the apparatus comprising a memory, a processor, and an executable program stored in the memory and capable of running on the processor, the executable program being configured to implement the steps of the method as described in any of the first aspects.
[0015] A third aspect of the present invention provides a computer-readable storage medium or cloud that stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method as described in any of the first aspects.
[0016] This invention develops a method and apparatus for determining whether metagenomic contigs originate from the same physical genome by utilizing Hi-C sequencing data features and employing a convolutional neural network. It has the following advantages: 1. Strong anti-interference ability: Through the center boundary masking technology, the problem of false features caused by excessive differences in contig length and sequence discontinuity in metagenomic assembly is effectively solved.
[0017] 2. High accuracy: Compared with simple counting and commonly used normalization methods, this invention can identify subtle differences in the spatial distribution structure of the genomes of different bacteria in the Hi-C heatmap, rather than the overall normalized value, which significantly improves the distinguishability of similar strains.
[0018] 3. Model generalization: The model is trained on a large amount of real bacterial genome assembly data, which makes it highly adaptable to metagenomic data of different species and sequencing depths.
[0019] 4. High accuracy: In some implementations, a judgment accuracy of 98.68% was achieved on the validation dataset. Attached Figure Description
[0020] Figure 1 The training set loss curve of the convolutional neural network model of the present invention is shown.
[0021] Figure 2 The accuracy of this invention in determining whether any two contigs belong to the same original genomic sequence is shown.
[0022] Figure 3 The invention demonstrates the highest global precision, recall, and overall performance index F1-Score. Detailed Implementation
[0023] Various exemplary embodiments of the present invention will now be described in detail. This detailed description should not be considered as a limitation of the present invention, but rather as a more detailed description of certain aspects, features, and embodiments of the present invention.
[0024] It should be understood that the terminology used in this invention is merely for describing particular embodiments and is not intended to limit the invention. Furthermore, with respect to numerical ranges in this invention, it should be understood that the upper and lower limits of the range and each intermediate value between them are specifically disclosed. Any stated value or intermediate value within a stated range, as well as each smaller range between any other stated value or intermediate value within said range, are also included in this invention. The upper and lower limits of these smaller ranges may be independently included or excluded from the range.
[0025] Unless otherwise stated, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. While only preferred methods and materials have been described herein, any methods and materials similar or equivalent to those described herein may be used in the implementation or testing of this invention. All references to documents cited herein are incorporated by way of citation to disclose and describe methods and / or materials associated with those references.
[0026] In this invention, a contig (sometimes also called a continuous sequence or adjacent fragment) is a continuous sequence formed by splicing DNA fragments together through adjacent or overlapping sequences during genome sequencing. Specifically, it refers to a gapless DNA fragment formed by splicing short reads. After determining the positional relationship between contigs based on paired-end sequencing data, they can be further assembled into higher-level scaffold sequences.
[0027] In this invention, the Mapping Quality (MapQ) score refers to the alignment quality score of each read when sequencing data is aligned to a reference genome. MapQ scores are typically generated by alignment software (such as BWA, Bowtie2, etc.) to measure the reliability and uniqueness of the read's alignment to the reference genome. MapQ scores are usually integer values, ranging from approximately 0 to 60, with the specific range and calculation method varying depending on the alignment tool used. In some implementations, a high MapQ value typically indicates that the read has uniquely and correctly aligned to a location on the reference genome, meaning the alignment is reliable. For example, a MapQ value of 30 indicates a 99.9% probability that the read aligned to this location. A low MapQ value typically indicates that the read aligned to multiple locations, or that the alignment is less reliable. In such cases, the alignment may be inaccurate, or the true location of the read may be undetermined.
[0028] In this invention, the edit distance represented by the "NM" tag is defined as the minimum number of single nucleotide edits (replacements, insertions, and deletions) required to convert a read sequence into a reference sequence aligned fragment. Low NM values (e.g., NM=0 or 1) generally indicate high-quality alignment.
[0029] In this invention, binning refers to the process of clustering contigs obtained from the assembly of metagenomic sequencing data according to Hi-C interaction data. Each bin represents a set of contigs that may originate from a single microbial genome.
[0030] In this invention, the matrix is used to represent the frequency of physical interactions between genomic regions in metagenomic assembly assisted by three-dimensional genomic technologies such as Hi-C. Each element represents the contact strength between two bins, thereby correctly binning contigs and mounting them onto the complete genome.
[0031] Example 1 This embodiment provides a method for determining whether metagenomic contigs originate from the same physical genome based on a high-precision alignment feature screening strategy, image-based composite feature map reconstruction technology, and a CNN determination model with a boundary masking mechanism. The method mainly includes: 1. High-confidence interaction feature extraction (Pre-processing Logic) To eliminate contamination of the results by metagenomic homologous sequence comparison, this embodiment employs the following hierarchical screening logic: (1) Multiple alignment conflict resolution: For multiple alignment sites of the same Read pair, competitive screening is carried out in sequence according to the alignment quality value (MapQ) > edit distance (NM label) > effective alignment length (CIGAR resolution), and only the best unique physical location is retained.
[0032] (2) Dual constraints of physical and enzymatic digestion: The alignment coordinates are mapped to the restriction endonuclease fragment index, and logical judgment is used to eliminate them: Self-circularization noise: Both ends are aligned to the same enzyme digestion fragment.
[0033] Neighbor interference: Signals whose physical span is less than the set segment number threshold or whose absolute distance is less than 100.
[0034] 2. Image-based composite feature map reconstruction (Feature Engineering) In order to transform the interaction of one-dimensional sequences into features that can be recognized by computer vision, this embodiment performs the following transformation: (1) Submatrix extraction: Extract the four interaction quadrants of the pair to be detected (contig A and contig B): AA (inner), BB (inner), AB (cross), BA (cross).
[0035] (2) Nonlinear enhancement and scaling: The original matrix counts are transformed by log(x+1), and bilinear interpolation is used to uniformly scale the four submatrices to 32×32 resolution. This reduces the impact of contig length and discontinuity on the model.
[0036] (3) Topological stitching: The scaled submatrices are stitched together to form a 64×64 two-dimensional composite feature map (top left AA, bottom right BB, top right and bottom left AB / BA).
[0037] (4) Center Boundary Masking: A pixel mask is set to zero in the central cross region of the stitched image (i.e., the intersection of the two contigs). This is intended to enhance the model's ability to recognize the boundary between contig A and contig B, enabling the model to learn the overall topological features inside and between contigs, rather than focusing excessively on edge effects at the assembly breakpoint.
[0038] (5) Adaptive truncation: global normalization with 99.5 percentile is used to eliminate the impact of rare abnormal high-frequency signals on the model gradient.
[0039] 3. CNN Model Architecture and Dynamic Training Strategies (1) Model structure: Three consecutive convolutional modules (Conv2d+BatchNorm+ReLU+MaxPool2d) are used, the number of channels is increased from 1 to 128, and finally the connection probability is output through a fully connected layer and Softmax.
[0040] (2) Negative Sample Sampling Logic: When constructing the training set, a random sliding window is used to cut the bacterial reference genome to simulate real contigs. Contigs with the same genome are positive samples, and contigs with different genomes are negative samples. All genomes are derived from real microbial samples assembled from third-generation HiFi metagenomics, including more than 120 strains with high similarity and 135 strains with normal similarity. A 2:1 positive-to-negative sample oversampling strategy is adopted to address the sample imbalance caused by all-zero signals in actual detection.
[0041] (3) Dynamic evaluation of interception: The accuracy of the validation set is monitored in real time during training, and 0.985 accuracy is set as the early stopping trigger to lock the optimal weights while ensuring generalization performance.
[0042] The following is a detailed explanation: I. Hi-C Signal Processing To extract high-confidence three-dimensional spatial interaction information from Hi-C sequencing data to assist in metagenomic binning, a high-efficiency Hi-C contact matrix processing tool (hicmap) was developed in C++. This tool directly processes BAM format alignment files sorted by read name, converting them into a normalized interaction frequency matrix. The specific processing method is as follows: (1) Dynamic screening of optimal alignment sites. Due to the high homology of metagenomic sequences, Hi-Creads often produce multiple alignments. Therefore, the BAM files read by hicmap are sorted according to read ID. To ensure the accuracy of interaction signals, the program groups all alignments of the same pair of reads into Read 1 and Read 2 and reads them into the cache. A hierarchical optimal alignment screening algorithm is designed to select these alignments: First, the record with the highest mapping quality (MapQ) is selected; if the MapQ is the same, the NM tag in the BAM file is extracted, and the alignment record with the smallest edit distance (mismatch number) is selected; if the first two cannot be distinguished, the effective alignment length is calculated by parsing the CIGAR string, and the record with the longest alignment length is selected as the unique and exact physical location of the sequence at that end.
[0043] (2) Physical Constraints and Noise Filtering of Interaction Signals. After determining the read coordinates, the program performs strict physical and quality-based dual filtering. First, redundant fragments that fail to align, are below the preset MapQ threshold, or are marked as PCR duplicates are removed. Based on this, to eliminate random ligation noise during Hi-C library construction, the program maps genomic coordinates to specific restriction enzyme fragment indices using restriction enzyme restriction site information. Subsequently, two types of false-positive interactions caused by non-real spatial conformations are systematically removed: one is self-circularization noise where both ends align to the same restriction fragment; the other is short-distance ligation noise where the physical distance is too close (e.g., the number of fragments crossed is below the minimum threshold, or the absolute distance is less than 100 bp).
[0044] (3) Whole-genome discretization and binning, and matrix generation. Valid Hi-C interaction pairs filtered above were used to construct a sparse contact matrix. Based on the user-defined resolution (bin size, default 20 kbp), all assembled contigs were divided into continuous equal-length windows, and the global offset of each contig in the whole-genome coordinate system was calculated cumulatively. The coordinates of the valid interaction pairs were discretized and mapped to these global bins. To optimize storage and ensure matrix symmetry, bitwise operations were used to encode the indices of the two interacting bins into unique keys (always ensuring the smaller index comes first), and then the interaction frequencies within each grid were counted to form an upper triangular sparse matrix. Finally, the program outputs a sequence information table (offset.tsv) containing global offset indices and a sparse matrix file (matrix.tsv) recording the spatial interaction strengths, providing topological data support for subsequent graph-based binning optimization.
[0045] II. Hi-C Connection Score Based on CNN In this invention, the binning and connection algorithms do not directly process the original values of the Hi-C contact matrix. Instead, they use the original Hi-C matrix to calculate a connection score for the connection matrix of each pair of contigs. To accurately quantify the probability that any two contigs belong to the same microbial genome, deep learning prediction based on convolutional neural networks (DL mode) is employed, and a multiprocessing mechanism is used for feature preprocessing to accelerate pairwise testing of large-scale contig pairs.
[0046] Deep learning prediction and image preprocessing (DL mode): Traditional algorithms struggle to identify subtle differences between similar strains when analyzing Hi-C connectivity matrices. This embodiment employs a two-dimensional feature-based convolutional neural network (contig pair CNN) to determine whether two contigs belong to the same genome. Instead of a binary classification output, it outputs a connectivity score, representing the probability that they belong to the same genome. The main steps are as follows: (1) Image-based reconstruction of the contact matrix: In the data processing workflow, the internal interaction sub-matrices of contig A and contig B, as well as the cross interaction matrix between them, are first extracted. To highlight weak topological features, the matrix values are first subjected to a nonlinear transformation of log(1+x), and then bilinear interpolation is used to uniformly scale matrices AA (internal matrix of contig A), BB (internal matrix of contig B), and AB (connection matrix between contig A and contig B) to a fixed resolution of 32×32. The four scaled matrices are concatenated and reconstructed into a 64×64 two-dimensional composite feature map (the upper left corner is the internal signal of contig A, the lower right corner is the internal signal of contig B, and the upper right and lower left corners are the cross signals). Finally, the image is adaptively truncated and normalized at the 99.5th percentile, and the cross boundary (edge region) at the center of the image is masked to zero to eliminate the interference of boundary assembly artifacts on network feature extraction.
[0047] (2) CNN Model Structure: The preprocessed 64×64 tensors are batched and fed into the GPU for forward propagation. The network contains three consecutive convolutional modules to extract spatial topological features. Each module consists of a 3×3 two-dimensional convolutional layer (Conv2d), batch normalization (BatchNorm2d), ReLU activation function, and a 2×2 max pooling layer (MaxPool2d). After three downsampling operations, the feature map dimension is reduced from 64×64 to 8×8, and the number of channels is gradually increased to 128. The extracted features are flattened into a one-dimensional vector of length 128×8×8=8192, passed through a fully connected layer (Dense Layer), and 50% Dropout regularization, finally outputting unnormalized logits of dimension 2, which are then mapped to probability values representing "connected" and "unconnected" through the Softmax function.
[0048] The specific dataset construction and training are as follows: In order to enable contig Pair CNN to fully learn the Hi-C contact topological features between segments of the same physical genome in the metagenomics, this embodiment uses Hi-C sequencing of 255 assembled bacterial genomes and metagenomics to design a scheme from low-level sequence simulation, matrix reconstruction to dynamic model training.
[0049] (1) Simulation of contig generation and truth label construction Since real metagenomic assembly results are often highly fragmented and lack absolute truth-value correspondences, this embodiment performs strictly controlled sequence fragmentation simulation on 255 bacterial reference genomes. To ensure that the generated simulated contigs have sufficient information, only the top 3 longest core sequences in each assembled genome are fragmented (bacterial genome assembly contains some short redundant sequences, and some genomes also contain multiple pseudo-chromosomes). In terms of fragmentation strategy, the program introduces a dynamic sliding window and a minimum length threshold (default 200 kbp). The step size of each cut fluctuates randomly between 1 and 1.5 times the minimum threshold. To prevent the generation of extremely short, useless sequences, this method makes a real-time prediction before each cut: if the total length of the remaining sequence is less than twice the minimum threshold, the remaining part is directly retained as a complete contig. All fragments generated through this simulation process are assigned a unique genome ID and output as a mapping table (contig_map.tsv), which provides absolute ground truth labels for the construction of positive and negative samples in the subsequent supervised learning stage.
[0050] (2) Hi-C feature matrix acquisition and sample pair sampling Obtain the Hi-C contact matrix of the contig. Align the five Hi-C data points to the simulated contig fragment generated in the previous step using the short sequence alignment mode "-x sr" of minimap2, and then sort the generated SAM file using samtools sort -n. Finally, input the generated sorted BAM file into the hicmap pipeline to obtain the contact matrix and the offset file at the input resolution.
[0051] (3) Construction of training samples After obtaining the simulated contigs and their initial Hi-C contact matrices (stored in COO sparse coordinate format), this method performs quality control and symmetry reconstruction on the data. To address the slice addressing problem caused by upstream alignment software only outputting the upper triangular matrix, the program converts the sparse matrix into CSR format in memory and uses matrix algebra operations to achieve a symmetry closure of the entire image, ensuring the complete extraction of cross-contig interaction information. .
[0052] Based on the contig set and source mapping table after sequence quality control (removing short contigs shorter than the threshold and positive samples with very few interaction values between themselves and contigs), this method performs exhaustive and random sampling. Contigs belonging to the same Genome ID are paired to form "positive samples" (real connections, labeled 1); combinations from different Genome IDs are labeled "negative samples" (non-connections, labeled 0). Considering that a large number of useless samples will be removed due to all contact signals being zero in the subsequent feature slicing stage, the program adopts a positive sample oversampling strategy with twice the number of negative samples in the initialization stage to ensure the class balance of the final input model. For the paired samples, their internal and cross submatrices are extracted from the symmetric matrix, and after logarithmic transformation and bilinear interpolation scaling, they are finally concatenated into a 64×64 two-dimensional input tensor.
[0053] Use 80% of all positive and negative samples as the training dataset and 20% as the validation dataset for the next training step.
[0054] (4) Training and dynamic evaluation mechanism of CNN model The model is trained using the PyTorch deep learning framework, with a maximum training epoch count of 50. During training, the network reads image tensors and ground truth labels in batches, and outputs logistic probabilities through forward propagation. Subsequently, the prediction error is quantified using the cross-entropy loss function, and the network weight coefficients are updated through backpropagation and an optimizer. To objectively evaluate the model's generalization ability on unseen data and avoid overfitting, the program automatically switches to validation mode after each training epoch, performing inference tests on an independent validation set. This embodiment integrates a dynamic monitoring and early stopping interception mechanism. Real-time training visualization: With the help of a plotting library, the program dynamically records and plots the loss (Log Loss) and accuracy curves of the training set and validation set at the end of each epoch.
[0055] Early Stopping Mechanism: To minimize computational cost while acquiring a high-confidence model, the process sets strict interception thresholds. Once the validation accuracy exceeds 0.985 (98.5%), a breakpoint will be triggered immediately, prematurely terminating the training loop and locking in the optimal weight state for model generalization performance.
[0056] Test Example 1 To verify the effectiveness of the deep learning model in determining whether contigs originate from the same genome based on the Hi-C contact matrix between contigs, this test case performed 20 epochs of standardized training and cross-validation on the contigPairCNN model. Figure 1-3 The performance evaluation curves show that the model exhibits excellent convergence characteristics and extremely high prediction accuracy.
[0057] Observing the dynamic changes in the loss function and accuracy during training reveals that the model exhibits a high learning rate in the early stages of training. The training loss decreases exponentially during this phase, while the training accuracy rapidly climbs to over 95%. Notably, after a brief period of feature adaptation and performance fluctuations in the first 3 to 4 training epochs, the validation set's accuracy rapidly increases in the 5th epoch, fitting the training set perfectly. In subsequent iterations (Epochs 5 to 20), the loss and accuracy curves of the training and validation sets remain highly correlated and converge smoothly. The validation set loss consistently approaches 0.05 without any rebound, indicating that the model avoids overfitting and possesses strong generalization ability for unseen homologous data segments. Figure 1 ).
[0058] In a rigorous validation set evaluation, the model achieved globally optimal predictive performance in the 19th training iteration. Figure 2 and 3 At this point, the accuracy (ValAccuracy) for determining whether any two contigs belong to the same original genome sequence is as high as 0.9879. Further examination of key metrics reflecting the model's classification balance reveals that the model achieves a global maximum precision of 0.9880, a recall of 0.9879, and a similarly high F1-Score of 0.9879. The Validation Metric curves show that the Precision, Recall, and F1-Score curves almost completely overlap in the later stages of iteration, demonstrating that the model exhibits no bias in identifying positive and negative samples.
[0059] In summary, the above results strongly demonstrate that the preprocessing strategy and 2D convolutional network structure constructed in Example 1 can extract the microscopic topological texture indicating real physical connections from a sparse Hi-C contact matrix containing background noise with extremely high fidelity. The high-confidence connection probabilities output provide a solid data foundation for subsequent deentanglement and hierarchical precise binning of the assembly graph.
[0060] Example 2 This embodiment is based on the method shown in Example 1, and further analyzes the assembly diagram to evaluate its performance in extracting high-quality genomes from real metagenomic samples.
[0061] This embodiment uses the assembly graph (GFA), Hi-C connection score (output of Example 1), and sequence similarity matrix as inputs, and achieves genome recovery through the steps of "graph dimensionality reduction - path addressing - bridging extension - supernode clustering".
[0062] Specifically as follows: 1. Classification, deconstruction, and topological dimensionality reduction of assembly graphs (Graph Pruning) (1) Classification of connected components: Based on the number of long nodes (>500 kbp) and short nodes, the global graph is divided into “giant complex components”, “fragmented components” and “ordinary components”.
[0063] (2) Iterative stripping and pruning: For giant components, an iterative dimensionality reduction strategy is implemented: Identify and remove short nodes that are "dead-ends" with only in-degree or only out-degree.
[0064] By removing detached noise nodes with extremely low depth (approximately 1×) and shorter than 50 kbp, the complex graph is decomposed into parsable subgraphs.
[0065] 2. Constrained Path Exploration Using the longest contig sorted by length as the core anchor point, initiate a multi-constraint search: (1) Loop path priority addressing: Using constrained breadth-first search (BFS), closed loop structures are prioritized for search under the conditions of length upper limit, abundance difference threshold, and Hi-C connection threshold. If a closed loop with the same start and end directions is detected, it is prioritized as the complete genome output.
[0066] (2) Bidirectional linear extension based on “short bridging”: For anchor points that cannot be closed, the path is allowed to traverse short repeating sequences to find the next long contig (>200 kbp).
[0067] (3) Connection scoring function: When faced with multiple candidate long nodes, a comprehensive scoring logic is used to resolve conflicts. ; This formula ensures that optimal ligation must simultaneously possess strong evidence of three-dimensional contact and highly consistent sequencing depth.
[0068] 3. Path-level global hierarchical clustering (1) Super-node encapsulation: The path contig and free nodes parsed in the previous step are encapsulated as "super-nodes".
[0069] (2) Signal normalization penalty mechanism: In order to eliminate the system bias caused by the unequal number of segments within a supernode, instead of using simple signal accumulation, a normalization weight based on component product is adopted: , Signal raw This represents the sum of the contig HiC signals between supernodes u and v. Nu and Nv are the original contigs contained within each supernode, respectively. This effectively prevents fragmented paths from generating embedding errors due to statistical advantages.
[0070] (3) Dynamic resolution-driven hierarchical Louvain algorithm: a. Set the initial resolution to 1.0.
[0071] b. Iterative splitting logic: If the total length of a cluster exceeds a set upper limit (e.g., 6 Mbp), it is considered over-merged. This method keeps the cluster active and re-clusters it by doubling the resolution parameter (Multiplier = 2.0).
[0072] c. Final Breakdown: When the resolution reaches the limit (e.g., 256) and still cannot be split, the supernode is forcibly downgraded to an independent singleton to ensure bin purity.
[0073] The CheckM2 evaluation results of various binning tools show that this embodiment achieves significant advantages in both the quantity and quality of recovered metagenomically assembled genomes (MAGs). 629 nearly complete microbial genomes were obtained from sheep gut metagenomics. This embodiment significantly outperforms Bin3C, VAMB, and MetaBAT2 in terms of the output of nearly complete (integrity >90% and contamination <10%) and high-quality (integrity >75% and contamination <10%) MAGs, while also outperforming the other three tools in MAG accuracy. The distribution trend of MAG length shows that other clustering algorithms are easily limited by the high sequence similarity between strains, leading to chimeras or huge MAGs, resulting in high MAG error rates and reducing the number of correct MAGs. In contrast, this embodiment can more accurately resolve complex contig relationships, significantly improving the recall rate of high-integrity genomes while strictly suppressing the increase in contamination, achieving a perfect balance between assembly continuity and accuracy.
[0074] In summary, this embodiment has the unique advantage of overcoming the limitations of existing reference databases and capturing and reconstructing the complete genome of unknown species, providing an efficient and reliable technical means for exploring and defining new taxa in complex micro-ecosystems.
[0075] Example 3 This embodiment illustrates an apparatus for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks. The apparatus includes a memory, a processor, and an executable program stored in the memory and capable of running on the processor. The executable program is configured to implement the steps of determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks as described in this invention.
[0076] In this embodiment, the device specifically includes: A high-confidence interaction feature extraction unit is configured to perform the following steps: perform multiple alignment conflict resolution processing on each pair of reads in the Hi-C alignment file to determine the alignment coordinates; perform physical and enzyme digestion dual constraint processing on the alignment coordinates to obtain effective interaction pairs; and discretize and bin the effective interaction pairs into whole-genome segments at a preset resolution to obtain a file containing a sequence information table with a global offset index and a sparse matrix recording the spatial interaction strength. The image-based composite feature map reconstruction unit is configured to implement the following steps: extracting the internal interaction submatrix and the cross interaction submatrix from the file, performing nonlinear enhancement and scaling on the extracted submatrix to obtain the scaled submatrix, performing topological stitching on the scaled submatrix to obtain a two-dimensional composite feature map, and performing center boundary masking on the two-dimensional composite feature map to obtain the reconstructed two-dimensional composite feature map. The determination unit is configured to perform the following steps: inputting the two-dimensional composite feature map into a trained convolutional neural network model and outputting a connection score, wherein the connection score is used to characterize the probability that the overlapping groups to be determined belong to the same microbial genome.
[0077] Those skilled in the art will understand that the various exemplary embodiments described in this invention can be implemented by software or by combining software with necessary hardware. Therefore, specific embodiments of the invention can be embodied in the form of a software product, which can be stored on a non-volatile storage medium or a non-transitory computer-readable storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the method according to the invention.
[0078] In exemplary embodiments, the program product of the present invention can employ any combination of one or more readable media. A readable medium can be a readable signal medium or a readable storage medium. A readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include, but are not limited to: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0079] Accordingly, based on the same inventive concept, the present invention also provides an electronic device.
[0080] In an exemplary embodiment, the electronic device is manifested as a general-purpose computing device. Components of the electronic device may include, but are not limited to: at least one processor, at least one memory, and a bus connecting different system components (including the memory and the processor). The memory stores program code that can be executed by the processing unit to cause the processing unit to perform the methods described in this invention, wherein the processor includes at least the data processing unit (also referred to as a "module") described in this invention. The memory may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) and / or cache memory cells, and may further include read-only memory (ROM).
[0081] The memory of the present invention may also include a program / utility having a set (at least one) of program modules, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0082] A bus can represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus that uses any of the various bus structures.
[0083] Electronic devices can also communicate with one or more external devices (such as keyboards, pointing devices, Bluetooth devices, etc.), and with one or more devices that enable users to interact with the electronic device, and / or with any device that enables the electronic device to communicate with one or more other computing devices (such as routers, modems, etc.).
[0084] This communication can be achieved through input / output (I / O) interfaces. Furthermore, the electronic device can communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter. The network adapter communicates with other modules of the electronic device via a bus. It should be understood that, although not shown herein, other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0085] Although the invention has been described with reference to exemplary embodiments, it should be understood that the invention is not limited to the disclosed exemplary embodiments. Various adjustments or changes may be made to the exemplary embodiments described in this specification without departing from the scope or spirit of the invention. The scope of the claims should be interpreted in the broadest possible sense to cover all modifications and equivalent structures and functions.
Claims
1. A method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks, characterized in that, Includes the following steps: (1) A high-confidence interaction feature extraction step, which includes: performing multiple alignment conflict resolution processing on each pair of reads in the Hi-C alignment file to determine the alignment coordinates, performing physical and enzyme digestion dual constraint processing on the alignment coordinates to obtain effective interaction pairs, and discretizing the effective interaction pairs into whole-genome bins according to a preset resolution to obtain a file containing a sequence information table with a global offset index and a sparse matrix of record space interaction strength. The multiple alignment conflict resolution processing on each pair of reads in the Hi-C alignment file includes: grouping and caching all alignments of the same pair of reads into first and second reads, selecting the record with the highest alignment quality value, and if the alignment quality values are the same, selecting the alignment record with the smallest edit distance. If they still cannot be distinguished, the effective alignment length is calculated by parsing the CIGAR string, and the record with the longest alignment length is selected as the unique exact physical location. (2) The image-based composite feature map reconstruction step includes: extracting the internal interaction sub-matrix and the cross interaction sub-matrix from the file, performing nonlinear enhancement and scaling on the extracted sub-matrix to obtain the scaled sub-matrix, performing topological stitching on the scaled sub-matrix to obtain a two-dimensional composite feature map, and performing center boundary masking on the two-dimensional composite feature map to obtain a reconstructed two-dimensional composite feature map. The image-based composite feature map reconstruction includes: extracting the internal interaction sub-matrix and the cross interaction sub-matrix between the overlapping groups to be judged, performing a log(1+x) nonlinear transformation on the values of each sub-matrix, scaling them uniformly to a fixed resolution of 32×32 through bilinear interpolation, and stitching the scaled sub-matrix into a 64×64 two-dimensional composite feature map. (3) The determination step includes: inputting the two-dimensional composite feature map into a trained convolutional neural network model and outputting a connection score, wherein the connection score is used to characterize the probability that the overlapping groups to be determined belong to the same microbial genome; The trained convolutional neural network model is obtained through the following steps: a. Perform controlled fragmentation simulation on reference genome sequences of known species origins to generate a set of simulated contigs carrying unique traceability identifiers, and use these to construct truth mapping relationships; b. Obtain the Hi-C contact matrix of the simulated overlap group using the same processing procedure as described above; c. Based on the truth mapping relationship, simulated overlapping groups originating from the same traceability identifier are marked as positive samples, simulated overlapping groups originating from different traceability identifiers are marked as negative samples, and positive samples are oversampled. d. Obtain the composite feature map for training from the simulated Hi-C contact matrix using the same processing procedure as described above; e. Using the training composite feature map and its labels, the convolutional neural network is trained through cross-entropy loss and gradient backpropagation. After each training round, the accuracy is evaluated on an independent validation set. When the validation set accuracy exceeds a preset threshold, early stopping is triggered to lock the model weights.
2. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 1, characterized in that, In step (1), the physical and enzyme digestion dual constraint processing of the alignment coordinates includes: removing redundant fragments that failed to align, were below the preset alignment quality threshold, and were marked as PCR repeats; mapping the genome coordinates to the restriction enzyme digestion fragment index; removing self-circularization noise that aligns to the same enzyme digestion fragment at both ends; and removing short-distance connection noise that is too close in physical distance.
3. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 1, characterized in that, The center boundary masking process includes: setting the pixel mask to zero in the central cross region of the stitched image.
4. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 3, characterized in that, The topology is then stitched together and then subjected to adaptive truncation and normalization to eliminate the impact of rare abnormal high-frequency signals on the model gradient.
5. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 1, characterized in that, The trained convolutional neural network model comprises three consecutive convolutional modules, each of which includes a 3×3 two-dimensional convolutional layer, batch normalization, ReLU activation function, and a 2×2 max pooling layer.
6. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 5, characterized in that, After the composite feature map is processed through three convolutional modules, its size is reduced to 8×8 and the number of channels is increased to 128.
7. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 6, characterized in that, The flattened one-dimensional vector is processed by a fully connected layer and Dropout regularization to output an unnormalized logical value with a dimension of 2.
8. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 7, characterized in that, The logical value is mapped to a probability value representing "connected" and "not connected" using the Softmax function, and the "connected" probability value is used as the connection score.
9. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 1, characterized in that, The controlled fragmentation simulation includes: retaining several core sequences with the longest length in each reference genome, randomly cutting the retained sequences using a dynamic sliding window, with the cutting step size randomly determined within the range of 1 to 1.5 times the preset minimum length threshold; and judging the length of the remaining sequence before each cutting. If the remaining length is less than twice the minimum length threshold, the remaining part is retained as a complete simulated contiguous group to avoid generating excessively short sequences.
10. The method for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks according to claim 1, characterized in that, Before constructing the training samples, the process also includes: performing symmetric closure processing on the simulated Hi-C contact matrix to ensure complete extraction of cross-overlapping group interaction information; and removing overlapping groups with lengths below a threshold and positive sample pairs with overly sparse interaction signals.
11. A device for determining metagenomic contig homology based on multidimensional feature fusion and convolutional neural networks, characterized in that, The apparatus includes a memory, a processor, and an executable program stored in the memory and capable of running on the processor, the executable program being configured to implement the steps of the method as claimed in any one of claims 1-10.
12. A computer-readable storage medium or cloud, said computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-10.
Citation Information
Patent Citations
Method and device for splitting homologous chromosomes of polyploid genome and application thereof
CN112289382A
Assembly contig detection method, device and equipment
CN122575491A
