Drug-resistant gene detection method and device, electronic equipment and storage medium
By acquiring sequencing data from test samples and negative control samples, calculating noise baseline values and stability coefficients, and performing abundance correction for target genes, combined with a pre-trained detection model, the problem of noise interference in pathogen drug resistance gene detection was solved, achieving higher detection accuracy and robustness.
Patent Information
- Application Number
- CN202511532993.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-02-03
AI Technical Summary
In existing technologies, the detection of drug resistance genes of pathogens is severely affected by background noise and sample instability, resulting in decreased detection specificity and sensitivity, high false positive and false negative probabilities, and insufficient detection accuracy.
By acquiring sequencing data from the test sample and negative control sample, calculating the noise baseline value and stability coefficient, performing abundance correction of the target gene, and combining it with a pre-trained drug resistance gene detection model, background noise interference is reduced and the signal-to-noise ratio is improved.
It improves the accuracy of drug resistance gene detection, reduces the probability of false positives and false negatives, enhances the robustness and reliability of detection, and can more accurately identify low-abundance drug resistance genes.
Smart Images

Figure CN121459945A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of gene identification, and in particular to a drug-resistant gene detection method and device, electronic equipment and a storage medium. BACKGROUND
[0002] With the increasingly serious problem of microbial drug resistance and the continuous deepening of the concept of precision medicine, pathogen drug resistance gene detection technology has become a key means for clinical diagnosis and public health prevention and control, which can directly identify the drug resistance mechanism of microorganisms from the genetic level, and can provide guidance for precision medicine earlier, so as to effectively curb the spread of drug-resistant bacteria and improve the cure rate of patients. Pathogen drug resistance gene detection technology often performs metagenomic sequencing on clinical samples (such as blood, sputum, etc.), and can obtain sequencing data containing pathogen and drug resistance gene information. However, in the actual detection process, the sequencing data is often seriously disturbed by many factors, which causes the drug resistance gene to be submerged, the specificity and sensitivity of the detection to decrease significantly, and the detection ability of the drug resistance gene to be insufficient. SUMMARY
[0003] The drug resistance gene detection method and device, electronic equipment and storage medium disclosed by the embodiments of the present application can reduce the interference of background noise and sample instability on the detection result, improve the signal-to-noise ratio of the detection, thereby reducing the probability of false positives and false negatives, and improving the accuracy of drug resistance gene detection.
[0004] The embodiments of the present application disclose a drug resistance gene detection method, which comprises: obtaining first sequencing data corresponding to a to-be-detected sample and second sequencing data corresponding to a negative control sample; the first sequencing data contains at least one non-drug resistance housekeeping gene; and the second sequencing data contains at least one drug resistance gene; obtaining a noise baseline value according to the coverage of the second sequencing data in a target region; the target region is composed of drug resistance genes; calculating a stability coefficient corresponding to the first sequencing data according to the original abundance of the at least one non-drug resistance housekeeping gene respectively; correcting the original abundance of a target gene corresponding to the first sequencing data based on the noise baseline value and the stability coefficient, to obtain a target abundance corresponding to the target gene; the target gene is one or more genes in the first sequencing data except the at least one non-drug resistance housekeeping gene; performing drug resistance detection on the target gene according to the first sequencing data and the target abundance corresponding to the target gene, to obtain a detection result corresponding to the target gene, which is used to indicate whether the target gene is a drug resistance gene.
[0005] As an optional implementation, the step of correcting the original abundance of the target gene in the first sequencing data based on the noise baseline value and the stability coefficient to obtain the target abundance of the target gene includes: The original abundance of the target gene is standardized to obtain the first abundance. The difference between the first abundance and the noise baseline value is calculated to obtain the second abundance; The product of the second abundance and the stability coefficient is calculated to obtain the target abundance corresponding to the target gene.
[0006] As an optional implementation, the step of calculating the stability coefficient corresponding to the first sequencing data based on the original abundance of each of the at least one non-drug-resistant housekeeping gene includes: Based on the original abundance of each of the at least one non-drug-resistant housekeeping gene, calculate the abundance standard deviation and abundance mean. The ratio of the abundance standard deviation to the abundance mean is calculated to obtain the coefficient of variation corresponding to the first sequencing data; The reciprocal of the coefficient of variation is used as the stability coefficient corresponding to the first sequencing data.
[0007] As an optional implementation, the step of performing drug resistance detection on the target gene based on the first sequencing data and the target abundance corresponding to the target gene to obtain the detection result corresponding to the target gene includes: Based on the first sequencing data, feature extraction is performed on the target gene to obtain the sequence features corresponding to the target gene; The target abundance and sequence features are weighted and fused using a drug resistance gene detection model to obtain the target features corresponding to the target gene. Then, based on the target features, drug resistance is detected on the target gene to obtain the detection results corresponding to the target gene.
[0008] As an optional implementation, the training process of the drug resistance gene detection model includes: Multiple training sample sets are obtained, each training sample set including the target sample abundance corresponding to multiple training sample genes, the sample sequence features corresponding to each training sample gene, and the drug resistance tag corresponding to each training sample gene; the target sample abundance corresponding to multiple training sample genes contained in each training sample set belongs to the same abundance interval; the multiple training sample sets correspond to different abundance intervals respectively. The pre-trained drug resistance gene detection model is trained sequentially according to the abundance intervals corresponding to the multiple training sample sets from high to low, so as to obtain the trained drug resistance gene detection model.
[0009] As an optional implementation, training the pre-trained drug resistance gene detection model to obtain a trained drug resistance gene detection model includes: The drug resistance gene detection model, through pre-training, performs drug resistance detection on the first training sample gene based on the abundance of the first target sample corresponding to the first training sample gene and the sequence characteristics of the first sample, and determines the first predicted label corresponding to the first training sample gene; the first training sample gene can be any training sample gene. Based on the first predicted label and the drug resistance label corresponding to the genes of the first training sample, a target loss value is determined based on the target loss function; the target loss function consists of cross-entropy loss and adversarial loss. Based on the target loss value corresponding to the first training sample gene, the parameters of the pre-trained drug resistance gene detection model are adjusted according to the gradient descent direction of the target loss value until the model convergence condition is met, thus obtaining the trained drug resistance gene detection model.
[0010] As an optional implementation, the training process of the drug resistance gene detection model includes: Calculate the species richness corresponding to the gene of the first training sample; the species richness is used to characterize the relative abundance of the species carrying the gene of the first training sample in the training sample to which the gene of the first training sample belongs. Calculate the host contamination rate corresponding to the gene in the first training sample; the host contamination rate is used to indicate the proportion of host DNA in the training sample to which the gene in the first training sample belongs; The training weights corresponding to the genes in the first training sample are calculated based on the species richness and the host contamination rate. The step of adjusting the parameters of the pre-trained drug resistance gene detection model according to the target loss value corresponding to the first training sample gene and in accordance with the gradient descent direction of the target loss value includes: Based on the training weights corresponding to the genes in the first training sample, the target loss values corresponding to the genes in the first training sample are weighted. Based on the weighted target loss value corresponding to the genes in the first training sample, the parameters of the pre-trained drug resistance gene detection model are adjusted according to the gradient descent direction.
[0011] This application discloses a device for detecting drug resistance genes, comprising: The data acquisition module is used to acquire the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample; the first sequencing data contains at least one non-drug-resistant housekeeping gene; the second sequencing data contains at least one drug-resistant gene. A data calculation module is used to calculate the noise baseline value based on the coverage of the second sequencing data in the target region; the target region is composed of drug resistance genes. The data calculation module is also used to calculate the stability coefficient corresponding to the first sequencing data based on the original abundance of the at least one non-drug-resistant housekeeping gene. An abundance correction module is used to correct the original abundance of the target gene in the first sequencing data based on the noise baseline value and the stability coefficient, so as to obtain the target abundance of the target gene; the target gene is one or more genes in the first sequencing data other than the at least one non-drug-resistant housekeeping gene. The drug resistance detection module is used to perform drug resistance detection on the target gene based on the first sequencing data and the target abundance corresponding to the target gene, and obtain the detection result corresponding to the target gene. The detection result is used to indicate whether the target gene is a drug-resistant gene.
[0012] This application discloses an electronic device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor causes the processor to implement the method described in any of the above embodiments.
[0013] This application discloses a computer-readable storage medium that stores a computer program, which, when executed by a processor, implements the methods described in any of the above embodiments.
[0014] This application discloses a computer program product, including a computer program, wherein when the computer program is executed by a processor, it implements the method described in any of the above embodiments. This application discloses a method, apparatus, electronic device, and storage medium for detecting drug resistance genes. The method involves acquiring first sequencing data corresponding to a test sample and second sequencing data corresponding to a negative control sample. The first sequencing data contains at least one non-drug-resistant housekeeping gene. The second sequencing data contains at least one drug-resistant gene. A noise baseline value is obtained based on the coverage of the second sequencing data in a target region. The target region is composed of drug resistance genes. A stability coefficient corresponding to the first sequencing data is calculated based on the original abundance corresponding to each of the at least one non-drug-resistant housekeeping gene. Based on the noise baseline value and the stability coefficient, the original abundance corresponding to the target gene in the first sequencing data is corrected to obtain the target abundance corresponding to the target gene. The target gene is one or more genes in the first sequencing data other than at least one non-drug-resistant housekeeping gene. Based on the first sequencing data and the target abundance corresponding to the target gene, drug resistance detection is performed on the target gene to obtain the detection result corresponding to the target gene. The detection result is used to indicate whether the target gene is a drug-resistant gene. In this embodiment, the electronic device calculates the noise baseline value using negative control samples and drug-resistant genes, and combines it with the stability coefficient obtained from the original abundance of non-drug-resistant housekeeping genes. The original abundance of the target gene is double-corrected by the noise baseline value and the stability coefficient. This not only reduces the interference of background noise during sequencing on the detection results and improves the detection sensitivity and signal-to-noise ratio for low-abundance drug-resistant genes, allowing low-abundance drug-resistant genes that were originally submerged by noise to be revealed, but also dynamically smooths out technical fluctuations, enhances robustness and reliability of results in real test samples, and reduces the probability of false positives and false negatives, thereby achieving more accurate detection of drug-resistant genes. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart illustrating the detection of drug resistance genes in one embodiment; Figure 2 This is a flowchart illustrating the calculation of the target abundance corresponding to the target gene in one embodiment; Figure 3 This is a flowchart illustrating the process of obtaining the stability coefficient corresponding to the first sequencing data in one embodiment. Figure 4 This is a flowchart illustrating the detection of drug resistance genes in one embodiment; Figure 5 This is a schematic diagram illustrating the training of a drug resistance gene detection model in one embodiment; Figure 6This is a schematic diagram illustrating the training of a drug resistance gene detection model in another embodiment; Figure 7 This is a block diagram of a device for detecting drug resistance genes in one embodiment; Figure 8 This is a structural block diagram of an electronic device in one embodiment. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0018] It should be noted that the terms "comprising" and "having," and any variations thereof, in the embodiments and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0019] It is understood that the terms "first," "second," etc., used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of this application, the first sequencing data may be referred to as the second sequencing data, and similarly, the second sequencing data may be referred to as the first sequencing data. The first sequencing data and the second sequencing data are obtained from sequencing analyses of two different samples.
[0020] In some embodiments, hospital personnel collect samples from target users and transport them to a testing institution. The testing institution receives the samples and sequences them using gene sequencing technology to obtain sequencing data corresponding to the target user. The testing institution sequences the samples to obtain sequencing data corresponding to the target user, which contains a large number of gene fragments. The testing institution then sends the sequencing data to an electronic device via email, which analyzes the data to determine whether the target gene in the sequencing data is a drug resistance gene.
[0021] A gene segment refers to a continuous sequence of genomic DNA obtained through sequencing technology during genome sequencing. A gene segment is a part of the genome, composed of multiple bases, and represents information from a specific region within the genome. Bases are one of the basic units that make up nucleic acids (DNA and RNA). In DNA, bases are linked by phosphodiester bonds to form nucleic acid chains, which, together with deoxyribose and phosphate, constitute the basic structure of DNA. There are four common types of bases in DNA: adenine (A), thymine (T), guanine (G), and cytosine (C).
[0022] It should be noted that different gene segments encode proteins and have different biological functions due to differences in the number, type, and sequence of their bases. For example, drug resistance genes are genes that can mediate pathogens' resistance to antimicrobial drugs, and their products may lead to drug resistance through mechanisms such as drug inactivation, target site modification, and changes in cell membrane permeability; housekeeping genes are genes that are stably expressed in all types of cells and are responsible for maintaining basic cellular life activities.
[0023] In some embodiments, the sequencing technologies used by the testing agency to sequence the samples to be tested may include, but are not limited to, first-generation sequencing (based on Sanger sequencing), second-generation sequencing (high-throughput sequencing, including Illumina's HiSeq and MiSeq series, Thermo Fisher's Ion Torrent series, etc.), third-generation sequencing (long-read sequencing, such as Pacific Biosciences' SMRT technology and Oxford Nanopore's MinION), single-molecule sequencing, etc.
[0024] In related technologies, the detection of drug resistance genes is mainly divided into phenotypic detection methods and molecular biological detection methods. Phenotypic detection methods determine drug resistance by observing the inhibitory effect of drugs on pathogen growth. Although the results are intuitive, they are time-consuming and dependent on culture. Molecular biological detection methods (such as PCR, gene chips, sequencing, etc.) predict drug resistance by directly detecting the sequence of drug resistance genes, and have the advantages of high speed and high throughput. However, these methods (especially high-throughput detection methods based on sequencing) are generally susceptible to severe interference from background noise (such as host DNA, environmental pollutants, sequencing errors, etc.). When processing complex samples (such as clinical samples with high host contamination and low microbial biomass), background noise often drowns out the true drug resistance genes, leading to a sharp decrease in the detection sensitivity of low-abundance drug resistance genes, and introducing the risk of false positives, which seriously restricts the accuracy and reliability of the detection results.
[0025] This application discloses a method, apparatus, electronic device, and storage medium for detecting drug resistance genes, which can reduce the interference of background noise and sample instability on the detection results, improve the signal-to-noise ratio of the detection, thereby reducing the probability of false positives and false negatives and improving the accuracy of drug resistance gene detection.
[0026] like Figure 1 As shown, in one embodiment, a method for detecting drug resistance genes is provided, which can be applied to electronic devices, including but not limited to mobile phones, tablets, PCs (Personal Computers), computers, digital scanners, electrophoresis apparatus, etc. The method may include steps 110 to 150.
[0027] Step 110: Obtain the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample.
[0028] In some embodiments, a sequencing device is used to perform sequencing analysis on a user's sample to be tested, so that an electronic device can acquire first sequencing data from the sequencing device. The first sequencing data contains at least one non-drug-resistant housekeeping gene. Housekeeping genes refer to genes that are stably and constitutively expressed in all cells and are responsible for maintaining basic life activities (such as 16S rRNA genes and rpoB genes), and their sequences are highly conserved; non-drug-resistant housekeeping genes refer to housekeeping genes that are not related to drug resistance mechanisms, and whose functions are focused on basic cellular processes, such as ribosome assembly and DNA replication.
[0029] In some embodiments, negative control samples are sequenced using a sequencing device to obtain second sequencing data from the sequencing device. A negative control sample refers to a control sample (e.g., sterile water, buffer) known not to contain any target pathogen or drug resistance gene during sample preparation and sequencing, used to monitor background contamination introduced during the experiment. The second sequencing data contains at least one drug resistance gene. A drug resistance gene refers to a gene sequence carrying a known drug resistance mutation (e.g., the mecA gene causing methicillin resistance) or a drug resistance element (e.g., an integron, transposon).
[0030] In some embodiments, the electronic device may preprocess the first sequencing data and the second sequencing data. Possible preprocessing methods include, but are not limited to, correcting GC base content, eliminating batch effects, quality filtering, and outlier handling.
[0031] Specifically, electronic devices can use the LOESS regression model to model and correct the relationship between sequencing data readings and GC base content of gene regions, eliminate quantitative bias introduced by GC bias, and ensure that gene regions with different GC base contents are comparable in abundance estimation.
[0032] Specifically, electronic devices can also employ the ComBat algorithm to identify and correct technical variations caused by differences in sequencing batches, experimental dates, or kits, thereby eliminating batch effects and ensuring that sequencing data from different batches can be directly compared and integrated for analysis.
[0033] Specifically, the electronic device can also set quality control thresholds to remove gene fragments with sequencing depths below 1M reads and / or host contamination rates above 60%, in order to ensure that subsequent analyses have sufficient statistical power; at the same time, it prevents excessive host genetic material from seriously interfering with the detection and analysis of target genes.
[0034] Specifically, to reduce false positive interference, electronic devices can also remove genes that have a detection rate of more than 5% in negative control samples. These genes are considered "false positive genes" caused by systematic contamination or non-specific comparisons.
[0035] Specifically, electronic devices can also apply median absolute deviation detection technology to robustly identify extreme outliers in abundance data; for extreme values that exceed 5 times the median MAD (median absolute deviation), the Winsorize tail reduction method is used to limit them to a reasonable range, thereby reducing the potential impact of outliers on the overall statistical model and data analysis results.
[0036] Step 120: Obtain the noise baseline value based on the coverage of the second sequencing data in the target region.
[0037] The target region is composed of drug resistance genes. Specifically, the target region refers to the genomic region defined by the sequences of one or more drug resistance genes.
[0038] Alternatively, the target region can be identified through public databases (such as CARD (Comprehensive Antibiotic Resistance Database), NCBI database) or lists of drug-resistant genes reported in the literature.
[0039] The coverage of the second sequencing data in the target region refers to the depth of sequencing reads aligned to each drug resistance gene in the target region in the second sequencing data of the negative control sample. It quantifies the intensity of nonspecificity generated by the experimental procedure in the target region in the absence of a real target.
[0040] Optionally, the electronic device can use the ratio of the number of reads of a drug-resistant gene in the target region that the second sequencing data is aligned to to the length of the drug-resistant gene as the coverage of the drug-resistant gene by the second sequencing data.
[0041] In some embodiments, the electronic device may employ a median statistical method to calculate the noise baseline value, that is, to calculate the median coverage of each drug resistance gene in the target region using the second sequencing data, as the noise baseline value. This method can resist the influence of individual extremely high or low outliers, ensuring that the obtained noise baseline value is stable and reliable.
[0042] The noise baseline value can quantify the level of background noise generated by the sequencing process itself in the target region when the target gene is not present, providing a quantitative basis for subtracting the noise from the first sequencing data of the sample to be tested.
[0043] Step 130: Calculate the stability coefficient corresponding to the first sequencing data based on the original abundance of at least one non-drug-resistant housekeeping gene.
[0044] The original abundance of non-drug-resistant housekeeping genes refers to the relative count of non-drug-resistant housekeeping genes in the sample to be tested (first sequencing data).
[0045] The relationship between the raw abundance of at least one non-drug-resistant housekeeping gene and the stability coefficient corresponding to the first sequencing data is a negatively correlated fluctuation relationship. The more stable the raw abundance value of the housekeeping gene, the larger the obtained stability coefficient. Conversely, if the abundance of the housekeeping gene fluctuates greatly, the value of the stability coefficient decreases.
[0046] The stability coefficient corresponding to the first sequencing data is used to characterize the overall technical stability and background consistency of the sample during the sequencing process. The larger the stability coefficient, the more stable the expression of at least one non-drug-resistant housekeeping gene, the smaller the fluctuation of background noise, and the higher the quality and reliability of the first sequencing data of the sample.
[0047] Step 140: Based on the noise baseline value and stability coefficient, the original abundance of the target gene in the first sequencing data is corrected to obtain the target abundance of the target gene.
[0048] The target genes are one or more genes in the first sequencing data, excluding at least one non-drug-resistant housekeeping gene.
[0049] The original abundance of the target gene in the first sequencing data refers to the ratio of the number of reads of the target gene in the first sequencing data to the total number of reads in the first sequencing data.
[0050] Because raw abundance data includes experimental background noise and is affected by fluctuations in sequencing stability, directly using raw abundance data for drug resistance analysis of target genes can lead to a low signal-to-noise ratio and inaccurate results. Electronic equipment performs dual correction on the raw abundance data corresponding to the target gene using both a noise baseline value and a stability coefficient. This eliminates the influence of background noise and improves the stability of the abundance data, thus benefiting subsequent drug resistance detection.
[0051] Step 150: Based on the first sequencing data and the target abundance corresponding to the target gene, drug resistance detection is performed on the target gene to obtain the detection results corresponding to the target gene.
[0052] The test results are used to indicate whether the target gene is a drug-resistant gene.
[0053] In some embodiments, the electronic device can use the first sequencing data and the corrected target abundance as features to input into a pre-trained drug resistance gene detection model to calculate the predicted probability that the target gene is a drug resistance gene; the electronic device then obtains the detection result based on the relationship between the predicted probability and the probability threshold; if the predicted probability is greater than the probability threshold, the detection result indicates that the target gene is a drug resistance gene; if the predicted probability is less than or equal to the probability threshold, the detection result indicates that the target gene represents a drug resistance gene.
[0054] In this embodiment, the electronic device calculates the noise baseline value using negative control samples and drug-resistant genes, and combines it with the stability coefficient obtained from the original abundance of non-drug-resistant housekeeping genes. The original abundance of the target gene is double-corrected by the noise baseline value and the stability coefficient. This not only reduces the interference of background noise during sequencing on the detection results and improves the detection sensitivity and signal-to-noise ratio for low-abundance drug-resistant genes, allowing low-abundance drug-resistant genes that were originally submerged by noise to be revealed, but also dynamically smooths out technical fluctuations, enhances robustness and reliability of results in real test samples, and reduces the probability of false positives and false negatives, thereby achieving more accurate detection of drug-resistant genes.
[0055] In one embodiment, such as Figure 2 As shown, the steps are based on the noise baseline value and stability coefficient to correct the original abundance of the target gene in the first sequencing data to obtain the target abundance of the target gene. The steps may also include steps 202 to 206.
[0056] Step 202: Standardize the original abundance of the target gene to obtain the first abundance.
[0057] Because the total sequencing depth varies among different samples, direct comparison using raw reads can lead to bias and unreliable results. Electronic equipment standardizes the raw abundance, bringing the abundance of all samples to a common scale, thereby ensuring the accuracy and impartiality of subsequent analyses.
[0058] In some embodiments, the electronic device may use different methods to standardize gene readings, including but not limited to CPM (Counts Per Million), RPKM (Reads Per Kilobase of transcript per Million reads mapped), FPKM (Fragments Per Kilobase of transcript per Million reads mapped), and TPM (Transcripts Per Million).
[0059] In some embodiments, the electronic device can set the reading count unit to CPM (representing "how many readings per million readings belong to the target gene"), and subtract the noise baseline value from the first abundance to obtain the second abundance. Specifically, the electronic device can calculate the first abundance using formula (1). .
[0060] (1); in, This indicates the number of reads aligned to target gene i (the original abundance of target gene i). This indicates the total number of reads in the first sequencing data.
[0061] Step 204: Calculate the difference between the first abundance and the noise baseline value to obtain the second abundance.
[0062] In some embodiments, the electronic device may subtract the noise baseline value from the first abundance to obtain the second abundance. Specifically, the electronic device may calculate the second abundance using formula (2). .
[0063] (2); Where B represents the noise baseline value; Indicates the highest abundance.
[0064] Since the noise baseline value can quantify the average background expression level in the target gene region during sequencing and data analysis in the absence of the target gene, electronic devices can subtract the noise baseline value from the first abundance value to eliminate systematic background noise introduced by the experimental procedure itself and / or mitigation factors. This effectively distinguishes the true biological expression of the sample from technical noise, making the second abundance value used for subsequent analysis closer to the true biological expression of the sample. This improves the signal-to-noise ratio of the detection, reduces the risk of misjudging background fluctuations as false positives, and makes low-abundance genes that were originally submerged by noise stand out, thereby improving the sensitivity of the detection.
[0065] Step 206: Calculate the product of the second abundance and the stability coefficient to obtain the target abundance corresponding to the target gene.
[0066] In some embodiments, the electronic device weights the second abundance based on the stability coefficient to obtain the target abundance corresponding to the target gene. Specifically, the electronic device can calculate the target abundance using formula (3). .
[0067] (3); Where S represents the stability coefficient; Indicates the second abundance.
[0068] The stability coefficient quantifies the quality of the first sequencing data of a sample. A higher stability coefficient indicates a more stable sequencing process, less background fluctuation, and more reliable first sequencing data. Therefore, electronic devices can use the stability coefficient to weight the second abundance, amplifying genes from high-quality samples (high stability coefficients) to contribute more to subsequent analyses; conversely, they can suppress genes from low-quality samples (low stability coefficients), thereby enhancing the robustness of the entire detection process and ensuring stable and accurate performance even when handling samples of varying quality.
[0069] In this embodiment, the electronic device transforms the original abundance data into high signal-to-noise ratio, high-quality target abundance by performing a three-level correction on the corresponding original abundance of the target gene, including standardization, noise subtraction, and stability weighting. Standardization ensures the comparability of data between samples; noise subtraction effectively removes systematic background interference introduced by the experimental procedure, improving the detection sensitivity for low-abundance drug-resistant genes and reducing the risk of false positives; and stability weighting dynamically adjusts based on the intrinsic data quality of the samples, enhancing adaptability to samples of varying quality, thereby improving the overall robustness of the detection process and the accuracy of the detection results.
[0070] In one embodiment, such as Figure 3As shown, the steps include calculating the stability coefficient corresponding to the first sequencing data based on the original abundance of at least one non-drug-resistant housekeeping gene, and may also include the following steps 302 to 306.
[0071] Step 302: Calculate the abundance standard deviation and abundance mean based on the original abundance corresponding to at least one non-drug-resistant housekeeping gene.
[0072] In some embodiments, the electronic device calculates the ratio of the number of reads of each non-drug-resistant housekeeping gene in the first sequencing data to the total number of reads in the first sequencing data to obtain the original abundance of each non-drug-resistant housekeeping gene; then, the sum of the original abundances of each non-drug-resistant housekeeping gene is divided by the number of non-drug-resistant housekeeping genes to obtain the average abundance of the first sequencing data, which represents the average expression level of these non-drug-resistant housekeeping genes in the first sequencing data; based on the original abundance of each non-drug-resistant housekeeping gene, the electronic device calculates the square root of the mean of the sum of squares of their deviations from the average to obtain the standard deviation of the abundance of the first sequencing data, which quantifies the degree of dispersion of the abundance of each non-drug-resistant housekeeping gene around the average.
[0073] Step 304: Calculate the ratio of the abundance standard deviation to the abundance mean to obtain the coefficient of variation corresponding to the first sequencing data.
[0074] The coefficient of variation (COP) of the first sequencing data represents the proportion of the fluctuation in the abundance of non-drug-resistant housekeeping genes to their average abundance. The smaller the COP value, the smaller the abundance fluctuation between different non-drug-resistant housekeeping genes, and the higher the consistency, which indirectly reflects the more stable the sequencing process of the sample and the better the technical noise control.
[0075] Specifically, the electronic device can calculate the coefficient of variation (CV) corresponding to the first sequencing data using formula (4).
[0076] (4); Where σ represents the abundance standard deviation; μ represents the abundance mean.
[0077] Step 306: The reciprocal of the coefficient of variation is used as the stability coefficient corresponding to the first sequencing data.
[0078] By processing the coefficient of variation, the stability coefficient becomes an indicator positively correlated with data stability. A higher stability coefficient indicates more consistent expression of non-drug-resistant housekeeping genes, a more stable background in the entire sequencing experiment, and more reliable quality of the first sequencing data corresponding to the sample.
[0079] Specifically, the electronic device can calculate the stability coefficient S corresponding to the first sequencing data using formula (5).
[0080] (5); Wherein, CV represents the coefficient of variation corresponding to the first sequencing data.
[0081] In this embodiment, the electronic device uses the inverse of the coefficient of variation corresponding to the non-drug-resistant housekeeping gene as a stability coefficient, which can quantify the quality of the first sequencing data, enhance high-stability samples, and suppress noise interference in low-stability samples. This improves the signal-to-noise ratio at the source, enhances the robustness of the electronic device when facing complex real samples, and reduces the risk of misjudgment caused by technical fluctuations, thus providing a guarantee for the accurate identification of drug-resistant genes.
[0082] like Figure 4 As shown, in one embodiment, a method for detecting drug resistance genes is provided, which can be applied to the aforementioned electronic device. The method may include steps 402 to 412.
[0083] Step 402: Obtain the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample.
[0084] Step 404: Obtain the noise baseline value based on the coverage of the second sequencing data in the target region.
[0085] Step 406: Calculate the stability coefficient corresponding to the first sequencing data based on the original abundance of at least one non-drug-resistant housekeeping gene.
[0086] Step 408: Based on the noise baseline value and stability coefficient, the original abundance of the target gene in the first sequencing data is corrected to obtain the target abundance of the target gene.
[0087] The relevant descriptions of steps 402 to 412 can be found in the relevant descriptions of steps 110 to 140 in the above embodiments, and will not be repeated here.
[0088] Step 410: Extract features from the target gene based on the first sequencing data to obtain the sequence features corresponding to the target gene.
[0089] Optionally, the electronic device can extract features from the target gene based on the first sequencing data using k-mer (nucleotide sequence fragments of length k) statistical methods and deep learning technology to comprehensively capture sequence information from local patterns to long-range dependencies, thereby obtaining the sequence features corresponding to the target gene. It can extract sequence features that characterize the structural and functional properties of the target gene from its original gene sequence.
[0090] The k-mer statistical method can cut a gene sequence into short gene fragments of a fixed length k. For example, if k=7, the electronic device can analyze the gene sequence of the target gene in all possible combinations of 4 to the power of 7 = 16384 seven-base combinations.
[0091] In some embodiments, the electronic device can construct a k-mer spectrogram corresponding to the target gene based on the k-mer statistical method; and use a deep learning architecture that combines convolutional neural networks with self-attention mechanisms to extract deep features from the target gene based on the k-mer spectrogram to obtain the sequence features corresponding to the target gene.
[0092] Specifically, electronic devices can segment the target gene sequence into all possible consecutive k-base fragments, traversing the entire gene sequence through a sliding window. Then, the frequency of each specific k-mer fragment appearing in the first sequencing data is counted, constructing a complete k-mer frequency distribution table. Finally, this k-mer frequency distribution table is converted into a two-dimensional k-mer spectrogram, where the horizontal and vertical axes represent different k-mer combinations, and the frequency of each k-mer is visually displayed through color intensity. This transforms the abstract gene sequence into structured numerical features.
[0093] Specifically, the convolutional neural network that can be used in electronic devices may include: a first convolutional layer for extracting local pattern features of the gene sequence of the target gene, identifying local features (such as short sequence conserved motifs, specific mutation sites, etc.) by sliding the convolutional kernel on the k-mer spectrogram; a second convolutional layer for learning local features of the gene sequence of the target gene in parallel to generate a noise-perceiving mask, identifying and marking unreliable regions that may be caused by sequencing errors or non-specific alignments by analyzing the background features of the gene sequence of the target gene; and a third convolutional layer for fusing the outputs of the first and second convolutional layers by element-wise multiplication, thereby suppressing interference from noisy regions and enhancing the contribution of drug resistance genes.
[0094] To further capture the long-range dependencies of the target gene sequence in the first sequencing data and focus on key sites, the electronic device can introduce the output of the third convolutional layer into a self-attention layer. Based on the Transformer architecture, the self-attention layer projects the convolutional features output from the third convolutional layer onto the query, key, and value vector spaces, respectively, according to the self-attention mechanism. An attention weight matrix is obtained by calculating the similarity between the query and the key, which characterizes the importance of different positions of the target gene sequence in the first sequencing data to the current site. The electronic device performs a weighted summation of the value vectors based on the attention weight matrix to generate new features that reflect global contextual information. Finally, the electronic device performs residual connections and / or splicing fusion of the output of the self-attention layer and the convolutional features output from the third convolutional layer to generate the sequence features corresponding to the target gene. These sequence features contain both local details and a global perspective.
[0095] In the above embodiments, the k-mer spectrogram provides a global view of sequence features, the convolutional neural network enables synergistic optimization of local feature extraction and noise suppression, and the self-attention layer ensures that key drug resistance-related sites (such as drug resistance mutation sites) are fully emphasized in the sequence features. Through this series of processes, the resulting sequence features can robustly and comprehensively characterize the sequence properties of the target gene, laying a solid foundation for accurately determining its drug resistance.
[0096] Step 412: The target abundance and sequence features are weighted and fused using the drug resistance gene detection model to obtain the target features corresponding to the target gene. Then, based on the target features, the drug resistance of the target gene is detected to obtain the detection results corresponding to the target gene.
[0097] Drug resistance gene detection models are used to integrate gene sequence characteristics and expression level information. Through weighted fusion and classification decision-making, they output prediction results on whether the target gene is a drug resistance gene.
[0098] In some embodiments, the drug resistance gene detection model may include a feature fusion module and a drug resistance detection module; the electronic device uses the feature fusion module to perform weighted fusion of target abundance and sequence features to obtain the target feature corresponding to the target gene; and then uses the drug resistance detection module to perform drug resistance detection on the target gene based on the target feature to obtain the detection result corresponding to the target gene.
[0099] Optionally, the electronic device can use a feature fusion module to dynamically weight the target abundance and sequence features based on a gating mechanism to obtain the target features corresponding to the target gene.
[0100] Specifically, the electronic device can concatenate sequence features with the target abundance to form a comprehensive multimodal feature. Through the Sigmoid activation function layer (gating weight generation mechanism) of the feature fusion module, the electronic device calculates a gating weight value between 0 and 1 for each feature dimension in the multimodal feature. The closer the corresponding gating weight value is to 1, the more important the corresponding feature dimension is in the current fusion decision; the closer it is to 0, the smaller the contribution of that feature dimension. The electronic device multiplies the original sequence features element-wise with the corresponding gating weights through the feature fusion module to obtain the weighted sequence features. Simultaneously, it multiplies the target abundance element-wise with the corresponding (1 - gating weight) to obtain the weighted abundance feature. Finally, the weighted sequence features and the weighted abundance features are added together to generate the target feature.
[0101] Among them, sequence features can reflect the gene sequence composition, local patterns and key site information of the target gene, while target abundance can characterize the relative expression level of the target gene in the first sequencing data after noise subtraction and quality weighting. The target features obtained by fusing these two types of features can provide an overview of the characteristics of the target gene from two dimensions: "sequence structure" and "expression level".
[0102] By splicing sequence features with target abundance, the integrity of the original features is preserved, and a dynamic balance between different feature dimensions is achieved through a gating mechanism. This allows the feature fusion module to flexibly adjust its dependence on sequence and abundance information according to specific gene and sample characteristics, thereby enhancing the robustness and accuracy of the drug resistance gene detection model.
[0103] In some embodiments, in addition to target abundance and sequence features, the electronic device can also acquire clinical data corresponding to the target gene, perform weighted fusion of target abundance and sequence features through a drug resistance gene detection model to obtain target features corresponding to the target gene, and then perform drug resistance detection on the target gene based on the target features and clinical data to obtain the detection results corresponding to the target gene.
[0104] In some embodiments, during the application of the drug resistance gene detection model, electronic devices can monitor and regularly maintain the model, preventing "data drift" and ensuring its stable performance over long-term use. Data drift refers to the phenomenon that, over time, the sequencing data (such as pathogen abundance, background noise level, etc.) corresponding to new test samples may gradually deviate from the training sample set used for model training, leading to a decline in the performance of the drug resistance gene detection model.
[0105] In some embodiments, electronic devices may identify data changes through a drift detection mechanism.
[0106] Specifically, the electronic device uses the KS (Kolmogorov-Smirnov) test to compare the abundance distribution changes of the current sequencing data with historical sequencing data (old data). When the value of the statistic obtained by the KS test exceeds the preset statistic (e.g., 0.3), it confirms that data drift has occurred, and the electronic device can optimize the model parameters of the drug resistance gene detection model.
[0107] Specifically, the electronic device can determine the historical noise range through multiple historical noise baseline values and compare the current noise baseline value with the historical noise range. When the current noise baseline value deviates from the historical noise range by ±50%, it is confirmed that the current noise has changed and data drift has occurred. In this case, the electronic device can optimize the model parameters of the drug resistance gene detection model.
[0108] Specifically, the electronic device can construct a historical feature set through multiple historical target features; calculate the Mahalanobis distance between the current target feature and the historical feature set; if the Mahalanobis distance exceeds a preset distance threshold, it is confirmed that the current drug resistance-related feature has shifted and data drift has occurred, then the electronic device can optimize the model parameters of the drug resistance gene detection model.
[0109] In some embodiments, when an electronic device detects data drift, it can adopt different optimization strategies for the drug resistance gene detection model according to the different degrees of drift detected, so as to minimize the impact on the performance of the drug resistance gene detection model, while ensuring that the drug resistance gene detection model can adapt to new data.
[0110] Specifically, if the electronic device detects a statistic value between 0.3 and 0.5, or a noise baseline value within ±50% of the historical noise range, or a Mahalanobis distance not exceeding a preset distance threshold, then the current drift level is confirmed as slight drift; if the detected statistic value between 0.5 and 0.7, or a noise baseline value exceeding ±50% but not exceeding ±100% of the historical noise range, or a Mahalanobis distance exceeding a preset distance threshold but not reaching the target significance level, then the current drift level is confirmed as moderate drift; if the detected statistic value exceeds 0.7, or a noise baseline value exceeding ±100% of the historical noise range, or a Mahalanobis distance reaching the target significance level, then the current drift level is confirmed as significant drift.
[0111] Alternatively, for slight drift, the optimization strategy that the electronic device can adopt is: calculate the gradient between the current model parameters and the new data, and use the exponential smoothing formula ( , These are the model parameters before the update. For the updated model parameters, The learning rate controls the update magnitude, gradually updating the model parameters to avoid overfitting of the drug resistance gene detection model to new data due to small drifts.
[0112] Optionally, for moderate drift, the optimization strategy that the electronic device can adopt is: retrain the fully connected layers of the drug resistance gene detection model, using the current data as the training sample set, and keeping the parameters of other layers of the drug resistance gene detection model unchanged to retain existing knowledge; evaluate the performance of the updated drug resistance gene detection model to ensure that the performance of the drug resistance gene detection model has not significantly decreased.
[0113] Alternatively, for significant drift, the optimization strategy that the electronic device can adopt is to use the current data as a new training sample set, start an active learning mechanism, select the most representative data for annotation and training, retrain the entire drug resistance gene detection model, and update all model parameters.
[0114] Optionally, when the electronic device detects a significant drift, it can also output a drift alert so that the user can manually adjust the model parameters to ensure that the adjusted drug resistance gene detection model has the performance required by the user.
[0115] In some embodiments, the electronic device may record drift parameters (including the conditions that trigger the drift, the drift detection time, data characteristics, and the degree of drift) each time a drift is detected, and record the execution status of the optimization strategy (including changes in model parameters) so that the user can know the specific situation when data drift occurs.
[0116] By employing different optimization strategies for drug resistance gene detection models based on varying degrees of drift, electronic devices can ensure that these models maintain superior detection performance over the long term, even when faced with constantly changing real-world data.
[0117] In this embodiment, the electronic device achieves comprehensive feature extraction of the target gene sequence from local patterns to global dependencies by organically combining k-mer spectrum analysis, dual-path convolutional neural network and self-attention mechanism; and forms a target feature with strong discriminative power by gating and weighting the dynamic balance sequence features and the target abundance weight; and finally, through the drug resistance gene detection model, accurately determines whether the target gene is a drug resistance gene, improves the detection sensitivity of low abundance genes, and reduces the risk of false negatives and false positives.
[0118] like Figure 5 As shown, in one embodiment, training the drug resistance gene detection model may include the following steps 502 to 504.
[0119] Step 502: Obtain multiple training sample sets.
[0120] Each training sample set includes the target sample abundance corresponding to multiple training sample genes, the sample sequence features corresponding to each training sample gene, and the drug resistance tag corresponding to each training sample gene; the target sample abundance corresponding to multiple training sample genes contained in each training sample set belongs to the same abundance interval; multiple training sample sets correspond to different abundance intervals.
[0121] The drug resistance tag corresponding to the training sample gene indicates whether the training sample gene is a drug resistance gene in actual circumstances.
[0122] In some embodiments, the abundance interval corresponding to the first training sample set may be a high abundance interval (abundance greater than or equal to 5%); the abundance interval corresponding to the second training sample set may be a medium abundance interval (abundance greater than or equal to 1% but less than 5%); and the abundance interval corresponding to the third training sample set may be a low abundance interval (abundance less than 1%).
[0123] Specifically, the target sample abundance corresponding to the multiple training sample genes included in the first training sample set is greater than or equal to 5%; the target sample abundance corresponding to the multiple training sample genes included in the second training sample set is between 1% and 5% (inclusive of 1%, exclusive of 5%); and the target sample abundance corresponding to the multiple training sample genes included in the third training sample set is less than 1%.
[0124] Step 504: Train the pre-trained drug resistance gene detection model sequentially according to the abundance intervals corresponding to the multiple training sample sets from high to low, to obtain the trained drug resistance gene detection model.
[0125] In some embodiments, electronic devices can use training sample sets in stages to enable the drug resistance gene detection model to gradually learn and adapt to environments ranging from clear drug resistance genes to weak noise (abundance range from high to low), so that the trained drug resistance gene detection model can stably detect drug resistance in genes of the full abundance spectrum.
[0126] Specifically, assume there are three training sample sets (the three training sample sets correspond to the high abundance interval, medium abundance interval, and low abundance interval, respectively). First, the pre-trained drug resistance gene detection model is trained using the first training sample set corresponding to the high abundance interval (≥5%). The first training sample set has the advantages of high signal-to-noise ratio and obvious feature patterns, enabling the drug resistance gene detection model to quickly identify the core features of drug resistance genes, learn the basic correlation between target features and abundance, and lay a stable parameter foundation for subsequent training.
[0127] Once the performance of the drug resistance gene detection model on the first training sample set reaches a stable state (e.g., the loss function converges and the accuracy tends to stabilize), the model parameters are further optimized using a second training sample set corresponding to a medium abundance range of 1% to 5%. The second training sample set contains enhanced noise interference, enabling the drug resistance gene detection model to learn to extract effective information from partially ambiguous target features, thereby improving the model's ability to distinguish target features and its generalization performance.
[0128] Finally, the drug resistance gene detection model was trained using a third training sample set corresponding to the low abundance range (<1%). This third training sample set typically contains high background noise and weak drug resistance genes, making it the most challenging data for training the drug resistance gene detection model. Building upon the feature extraction capabilities established in the first two training processes, this third training enhances the drug resistance gene detection model's resistance to noise interference and its sensitivity to weak drug resistance genes, enabling the model to learn how to identify genuine drug resistance genes from complex backgrounds (high noise interference).
[0129] In some embodiments, the electronic device may also evaluate the drug resistance gene detection model during the training process and optimize the drug resistance gene detection model based on the evaluation results.
[0130] Specifically, electronic devices can evaluate drug resistance gene detection models using noise robustness index and low abundance recall. The noise robustness index calculates the ratio of the accuracy of the drug resistance gene detection model on noisy data to that on clean data, quantifying the model's ability to maintain performance under interference. A higher noise robustness index indicates that the model's performance in noisy environments is closer to that in clean data environments, demonstrating stronger noise resistance. Low abundance recall assesses the ability of the drug resistance gene detection model to identify true drug resistance genes among genes with extremely low abundance (less than 0.5%), directly affecting the detection sensitivity of rare drug resistance genes. For example, low abundance recall is the ratio of correctly identified low abundance genes to the total number of low abundance genes.
[0131] To expand the diversity of the training sample set and improve the robustness of the drug resistance gene detection model, electronic devices can perform data augmentation on the training sample genes included in the training sample set during training. Possible data augmentation methods include background noise injection, abundance perturbation, and sequence mutation.
[0132] Optionally, background noise injection refers to simulating different levels of contamination of the host DNA with the genes in the training samples, thereby enabling the drug resistance gene detection model to learn the ability to distinguish between the genes in the training samples and the host DNA.
[0133] Optionally, abundance perturbation refers to adding random noise that conforms to a log-normal distribution to the abundance of the target sample, so that the drug resistance gene detection model can adapt to the natural fluctuations in abundance.
[0134] Optionally, sequence mutation refers to introducing random base substitutions at non-critical sites in the genes of training samples to improve the tolerance of drug resistance gene detection models to gene sequence variations.
[0135] In some embodiments, after each or several rounds of training of the drug resistance gene detection model, the electronic device can test the current drug resistance gene detection model using a validation sample set and calculate the noise robustness index and low abundance recall corresponding to the current drug resistance gene detection model to identify the current weaknesses of the drug resistance gene detection model (e.g., weak resistance to a certain type of noise, or insufficient recall for a certain abundance range). The validation sample set is different from the training sample set. This allows the electronic device to adjust the data augmentation parameters of the training sample set (e.g., specifically increase the injection intensity of a certain type of noise) or fine-tune the model parameters of the drug resistance gene detection model (e.g., adjust the weight λ of the adversarial loss, optimize the learning rate scheduling, etc.) based on the noise robustness index and low abundance recall, thereby performing targeted optimization training on the weaknesses of the drug resistance gene detection model in the next round of training.
[0136] In this embodiment, the electronic device is trained in stages and sequentially according to the abundance range from high to low. This avoids problems such as training instability, difficulty in convergence, or overfitting caused by the drug resistance gene detection model directly contacting a high-difficulty training sample set (low abundance, high noise data). Furthermore, it gradually enhances the adaptability of the drug resistance gene detection model to the full spectrum of abundance data. As a result, the trained drug resistance gene detection model maintains the detection performance of high abundance samples while also exhibiting excellent recognition sensitivity and robustness for low abundance drug resistance genes.
[0137] In one embodiment, such as Figure 6 As shown, training a pre-trained drug resistance gene detection model may include the following steps 602 to 604.
[0138] Step 602: Using a pre-trained drug resistance gene detection model, drug resistance is detected on the first training sample gene based on the abundance of the first target sample corresponding to the first training sample gene and the sequence characteristics of the first sample, and the first predicted label corresponding to the first training sample gene is determined.
[0139] The first training sample gene can be any training sample gene.
[0140] Optionally, the electronic device inputs the abundance of the first target sample corresponding to the first training sample gene (characterizing the relative expression level of the first training sample gene in its respective training sample) and the corresponding first sample sequence features (characterizing the sequence structure and key sites of the first training sample gene) into a pre-trained drug resistance gene detection model; the pre-trained drug resistance gene detection model performs drug resistance detection on the first training sample gene and outputs the first predicted label corresponding to the first training sample gene. The first predicted label is used to characterize whether the first training sample gene is a drug-resistant gene, as predicted by the drug resistance gene detection model.
[0141] Step 604: Based on the first predicted label and the drug resistance label corresponding to the gene of the first training sample, determine the target loss value based on the target loss function.
[0142] The target loss function consists of cross-entropy loss and adversarial loss.
[0143] Cross-entropy loss directly measures the difference between the first predicted label of the drug resistance gene detection model and the drug resistance label corresponding to the first training sample gene, maximizing the accuracy of the drug resistance gene detection model's predictions. Meanwhile, adversarial loss reduces the drug resistance gene detection model's over-reliance on target abundance, thereby enhancing the model's robustness.
[0144] In some embodiments, the electronic device can calculate the cross-entropy loss corresponding to the first training sample gene by using the number of training sample genes, the first predicted label, and the drug resistance label corresponding to the first training sample gene; calculate the adversarial loss corresponding to the first training sample gene by using the first predicted label, the drug resistance label corresponding to the first training sample gene, and the adversarial loss weight; and obtain the target loss value corresponding to the first training sample gene by weighted summing of the cross-entropy loss and the adversarial loss.
[0145] Specifically, the electronic device can calculate the target loss value corresponding to the i-th training sample gene using formulas (6) to (8). .
[0146] (6); (7); (8); in, This represents the cross-entropy loss corresponding to the i-th training sample gene; represents the adversarial loss corresponding to the i-th training sample gene; N represents the total number of training sample genes; This represents the drug resistance tag corresponding to the gene of the i-th training sample; λ represents the drug resistance probability of the predicted label of the i-th training sample gene output by the drug resistance gene detection model; λ represents the adversarial loss weight (usually set to 0.1~0.5). γ represents the relative abundance of the j-th species carrying the i-th training sample gene in the training sample to which the i-th training sample gene belongs; γ represents the dynamic adjustment coefficient (initially set to 1, decaying as training progresses). This represents the square of the L2 norm.
[0147] Step 606: Based on the target loss value corresponding to the gene in the first training sample, adjust the parameters of the pre-trained drug resistance gene detection model according to the gradient descent direction of the target loss value until the model convergence condition is met, and obtain the trained drug resistance gene detection model.
[0148] In some embodiments, after calculating the target loss value, the electronic device can use a backpropagation algorithm to calculate the gradient of the target loss value relative to all trainable parameters of the drug resistance gene detection model (such as convolutional kernel weights, fully connected layer parameters, etc.); using a gradient descent optimization algorithm (such as the Adam algorithm), the model parameters of the drug resistance gene detection model are fine-tuned along the direction of gradient descent to reduce the target loss value in the next iteration. This process is repeated on the training sample set until a preset model convergence condition is met (e.g., the target loss value no longer decreases significantly, the validation set accuracy tends to stabilize, or the maximum number of training epochs is reached), at which point the trained drug resistance gene detection model is obtained.
[0149] Because training datasets commonly suffer from class imbalance and uneven sample quality—low-abundance samples are scarce and easily overlooked by drug resistance gene detection models during training, while high-contamination samples have low signal-to-noise ratios, making it difficult for drug resistance gene detection models to learn—a reweighting mechanism can be used in some embodiments to optimize the training process. This reweighting mechanism, based on species richness and host contamination rate, guides the model to focus more on easily overlooked difficult samples (low-abundance samples) and complex samples that are difficult to learn (high-contamination samples) during training. This intelligent weighting strategy effectively mitigates training bias caused by class imbalance and uneven sample quality in the dataset, ensuring that the final trained model can achieve balanced and accurate detection of samples across the entire spectrum.
[0150] Optionally, the electronic device can calculate the species richness corresponding to the first training sample gene; the species richness is used to characterize the relative abundance of the species carrying the first training sample gene in the training sample to which the first training sample gene belongs; calculate the host contamination rate corresponding to the first training sample gene; the host contamination rate is used to indicate the proportion of host DNA in the training sample to which the first training sample gene belongs; calculate the training weight corresponding to the first training sample gene based on the species richness and the host contamination rate; weight the target loss value corresponding to the first training sample gene based on the training weight corresponding to the first training sample gene; and adjust the parameters of the pre-trained drug resistance gene detection model according to the gradient descent direction based on the weighted target loss value corresponding to the first training sample gene. This process continues until the model convergence condition is met, resulting in the trained drug resistance gene detection model.
[0151] Specifically, the electronic device can obtain the richness sub-weight based on the reciprocal of the species richness corresponding to the i-th training sample gene; obtain the contamination sub-weight based on the reciprocal of the host contamination rate corresponding to the i-th training sample gene; and use the product of the richness sub-weight and the contamination sub-weight as the training weight corresponding to the i-th training sample gene. For example, the electronic device can calculate the training weight corresponding to the i-th training sample gene using formulas (9) to (11). .
[0152] (9); (10); (11); in, This represents the species richness corresponding to the genes in the i-th training sample; This represents the host contamination rate corresponding to the gene in the i-th training sample. This represents the richness sub-weight corresponding to the gene of the i-th training sample; This represents the pollutant subweight corresponding to the i-th training sample gene; This represents extremely small positive numbers (such as 0.001) and is used to avoid division by zero errors. This represents extremely small positive numbers (such as 0.1) and is used to avoid division by zero errors.
[0153] In this embodiment, the electronic device combines standard cross-entropy loss with innovative adversarial loss, so that the drug resistance gene detection model not only pursues prediction accuracy during the optimization process, but is also forced to reduce its over-reliance on species abundance features. This makes the drug resistance gene detection model more focused on learning the essential association between gene sequence itself and drug resistance, rather than the superficial abundance correlation, thereby enhancing the stability and generalization ability of the drug resistance gene detection model when facing different abundance distributions, especially improving the sensitivity of identifying low-abundance drug resistance genes.
[0154] like Figure 7 As shown, in one embodiment, a drug resistance gene detection device 700 is provided, which can be applied to the above-mentioned electronic device. The drug resistance gene detection device 700 may include a data acquisition module 710, a data calculation module 720, an abundance correction module 730, and a drug resistance detection module 740.
[0155] The data acquisition module 710 is used to acquire the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample; the first sequencing data contains at least one non-drug-resistant housekeeping gene; the second sequencing data contains at least one drug-resistant gene. The data calculation module 720 is used to calculate the noise baseline value based on the coverage of the second sequencing data in the target region; the target region is composed of drug resistance genes. The data calculation module 720 is also used to calculate the stability coefficient corresponding to the first sequencing data based on the original abundance of at least one non-drug-resistant housekeeping gene; Abundance correction module 730 is used to correct the original abundance of the target gene in the first sequencing data based on the noise baseline value and stability coefficient to obtain the target abundance of the target gene; the target gene is one or more genes in the first sequencing data other than at least one non-drug-resistant housekeeping gene. The drug resistance detection module 740 is used to perform drug resistance detection on the target gene based on the first sequencing data and the target abundance corresponding to the target gene, and obtain the detection result corresponding to the target gene. The detection result is used to indicate whether the target gene is a drug-resistant gene.
[0156] In some embodiments, the abundance correction module 730 is further configured to standardize the original abundance corresponding to the target gene to obtain a first abundance; calculate the difference between the first abundance and the noise baseline value to obtain a second abundance; and calculate the product of the second abundance and the stability coefficient to obtain the target abundance corresponding to the target gene.
[0157] In some embodiments, the data calculation module 720 is further configured to calculate the abundance standard deviation and the abundance mean based on the original abundance corresponding to at least one non-drug-resistant housekeeping gene; calculate the ratio of the abundance standard deviation to the abundance mean to obtain the coefficient of variation corresponding to the first sequencing data; and use the reciprocal of the coefficient of variation as the stability coefficient corresponding to the first sequencing data.
[0158] In some embodiments, the drug resistance detection module 740 is further configured to extract features from the target gene based on the first sequencing data to obtain the sequence features corresponding to the target gene; to perform weighted fusion of the target abundance and sequence features through the drug resistance gene detection model to obtain the target features corresponding to the target gene; and then to perform drug resistance detection on the target gene based on the target features to obtain the detection results corresponding to the target gene.
[0159] In some embodiments, the training process of the drug resistance gene detection model includes: acquiring multiple training sample sets, each training sample set including the target sample abundance corresponding to multiple training sample genes, the sample sequence features corresponding to each training sample gene, and the drug resistance tag corresponding to each training sample gene; the target sample abundance corresponding to multiple training sample genes contained in each training sample set all belong to the same abundance interval; the multiple training sample sets correspond to different abundance intervals; and the pre-trained drug resistance gene detection model is trained sequentially according to the order of abundance intervals corresponding to the multiple training sample sets from high to low to obtain the trained drug resistance gene detection model.
[0160] Optionally, the training process of the drug resistance gene detection model further includes: using a pre-trained drug resistance gene detection model to perform drug resistance detection on the first training sample gene based on the abundance of the first target sample and the sequence features of the first sample corresponding to the first training sample gene, and determining the first predicted label corresponding to the first training sample gene; the first training sample gene can be any training sample gene; based on the first predicted label and the drug resistance label corresponding to the first training sample gene, a target loss value is determined based on a target loss function; the target loss function consists of cross-entropy loss and adversarial loss; based on the target loss value corresponding to the first training sample gene, the parameters of the pre-trained drug resistance gene detection model are adjusted according to the gradient descent direction of the target loss value until the model convergence condition is met, thereby obtaining the trained drug resistance gene detection model.
[0161] Optionally, the training process of the drug resistance gene detection model further includes: calculating the species richness corresponding to the first training sample gene; the species richness is used to characterize the relative abundance of the species carrying the first training sample gene in the training sample to which the first training sample gene belongs; calculating the host contamination rate corresponding to the first training sample gene; the host contamination rate is used to indicate the proportion of host DNA in the training sample to which the first training sample gene belongs; calculating the training weight corresponding to the first training sample gene based on the species richness and the host contamination rate; weighting the target loss value corresponding to the first training sample gene based on the training weight corresponding to the first training sample gene; and adjusting the parameters of the pre-trained drug resistance gene detection model according to the gradient descent direction based on the weighted target loss value corresponding to the first training sample gene.
[0162] In this embodiment, the electronic device calculates the noise baseline value using negative control samples and drug-resistant genes, and combines it with the stability coefficient obtained from the original abundance of non-drug-resistant housekeeping genes. The original abundance of the target gene is double-corrected by the noise baseline value and the stability coefficient. This not only reduces the interference of background noise during sequencing on the detection results and improves the detection sensitivity and signal-to-noise ratio for low-abundance drug-resistant genes, allowing low-abundance drug-resistant genes that were originally submerged by noise to be revealed, but also dynamically smooths out technical fluctuations, enhances robustness and reliability of results in real test samples, and reduces the probability of false positives and false negatives, thereby achieving more accurate detection of drug-resistant genes.
[0163] Figure 8 This is a structural block diagram of an electronic device in one embodiment. The electronic device can be a mobile phone, tablet computer, smart wearable device, etc. Figure 8 As shown, the electronic device 800 may include one or more of the following components: a processor 810 and a memory 820 coupled to the processor 810, wherein the memory 820 may store one or more computer programs, which may be configured to implement the methods described in the above embodiments when executed by one or more processors 810.
[0164] The processor 810 may include one or more processing cores. The processor 810 connects to various parts within the electronic device 800 using various interfaces and lines, and performs various functions and processes data of the electronic device 800 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 820, and by calling data stored in the memory 820. Optionally, the processor 810 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 810 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 810 and may be implemented separately using a communication chip.
[0165] The memory 820 may include random access memory (RAM) or read-only memory (ROM). The memory 820 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 820 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described above. The data storage area may also store data created by the electronic device 800 during use.
[0166] Understandably, the electronic device 800 may include more or fewer structural elements than those shown in the block diagram above, such as power supply, input buttons, camera, speaker, screen, RF (Radio Frequency) circuit, Wi-Fi (Wireless Fidelity) module, Bluetooth module, sensor, etc., and may not be limited herein.
[0167] This application discloses a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the methods described in the above embodiments.
[0168] This application discloses a computer program product, including a computer program, which, when executed by a processor, implements the methods described in the above embodiments.
[0169] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), etc.
[0170] Any references to memory, storage, databases, or other media used herein may include non-volatile and / or volatile memory. Suitable non-volatile memory may include ROM, Programmable ROM (PROM), Erasable PROM (EPROM), Electrically Erasable PROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as Static RAM (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus DRAM (RDRAM), and Direct Rambus DRAM (DRDRAM).
[0171] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Those skilled in the art should also recognize that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0172] In the various embodiments of this application, it should be understood that the sequence number of each process does not necessarily imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0173] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0174] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they can be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0175] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0176] If the integrated units described above are implemented as software functional units and sold or used as independent products, they can be stored in a computer-accessible memory. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several requests to cause a computer device (which can be a personal computer, server, or network device, specifically a processor in the computer device) to execute some or all of the steps of the methods described in the various embodiments of this application.
[0177] The foregoing has provided a detailed description of a method, apparatus, electronic device, and storage medium for detecting drug resistance genes disclosed in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting drug resistance genes, characterized in that, The method includes: Obtain the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample; the first sequencing data contains at least one non-drug-resistant housekeeping gene; the second sequencing data contains at least one drug-resistant gene. The noise baseline value is obtained based on the coverage of the second sequencing data in the target region; the target region is composed of drug resistance genes. Based on the original abundance of each of the at least one non-drug-resistant housekeeping gene, calculate the stability coefficient corresponding to the first sequencing data. Based on the noise baseline value and the stability coefficient, the original abundance of the target gene in the first sequencing data is corrected to obtain the target abundance of the target gene; the target gene is one or more genes in the first sequencing data other than the at least one non-drug-resistant housekeeping gene. Based on the first sequencing data and the target abundance corresponding to the target gene, drug resistance detection is performed on the target gene to obtain the detection result corresponding to the target gene. The detection result is used to indicate whether the target gene is a drug-resistant gene.
2. The method according to claim 1, characterized in that, The step of correcting the original abundance of the target gene in the first sequencing data based on the noise baseline value and the stability coefficient to obtain the target abundance of the target gene includes: The original abundance of the target gene is standardized to obtain the first abundance. The difference between the first abundance and the noise baseline value is calculated to obtain the second abundance; The product of the second abundance and the stability coefficient is calculated to obtain the target abundance corresponding to the target gene.
3. The method according to claim 1, characterized in that, The step of calculating the stability coefficient corresponding to the first sequencing data based on the original abundance of each of the at least one non-drug-resistant housekeeping gene includes: Based on the original abundance of each of the at least one non-drug-resistant housekeeping gene, calculate the abundance standard deviation and abundance mean. The ratio of the abundance standard deviation to the abundance mean is calculated to obtain the coefficient of variation corresponding to the first sequencing data; The reciprocal of the coefficient of variation is used as the stability coefficient corresponding to the first sequencing data.
4. The method according to claim 1, characterized in that, The step of performing drug resistance detection on the target gene based on the first sequencing data and the target abundance corresponding to the target gene, and obtaining the detection result corresponding to the target gene, includes: Based on the first sequencing data, feature extraction is performed on the target gene to obtain the sequence features corresponding to the target gene; The target abundance and sequence features are weighted and fused using a drug resistance gene detection model to obtain the target features corresponding to the target gene. Then, based on the target features, drug resistance is detected on the target gene to obtain the detection results corresponding to the target gene.
5. The method according to claim 4, characterized in that, The training process of the drug resistance gene detection model includes: Multiple training sample sets are obtained, each training sample set including the target sample abundance corresponding to multiple training sample genes, the sample sequence features corresponding to each training sample gene, and the drug resistance tag corresponding to each training sample gene; the target sample abundance corresponding to multiple training sample genes contained in each training sample set belongs to the same abundance interval; the multiple training sample sets correspond to different abundance intervals respectively. The pre-trained drug resistance gene detection model is trained sequentially according to the abundance intervals corresponding to the multiple training sample sets from high to low, so as to obtain the trained drug resistance gene detection model.
6. The method according to claim 5, characterized in that, The process of training the pre-trained drug resistance gene detection model to obtain the trained drug resistance gene detection model includes: The drug resistance gene detection model, through pre-training, performs drug resistance detection on the first training sample gene based on the abundance of the first target sample corresponding to the first training sample gene and the sequence characteristics of the first sample, and determines the first predicted label corresponding to the first training sample gene; the first training sample gene can be any training sample gene. Based on the first predicted label and the drug resistance label corresponding to the genes of the first training sample, a target loss value is determined based on the target loss function; the target loss function consists of cross-entropy loss and adversarial loss. Based on the target loss value corresponding to the gene in the first training sample, the parameters of the pre-trained drug resistance gene detection model are adjusted according to the gradient descent direction of the target loss value until the model convergence condition is met, thus obtaining the trained drug resistance gene detection model.
7. The method according to claim 6, characterized in that, The training process of the drug resistance gene detection model includes: Calculate the species richness corresponding to the gene of the first training sample; the species richness is used to characterize the relative abundance of the species carrying the gene of the first training sample in the training sample to which the gene of the first training sample belongs. Calculate the host contamination rate corresponding to the gene in the first training sample; the host contamination rate is used to indicate the proportion of host DNA in the training sample to which the gene in the first training sample belongs; The training weights corresponding to the genes in the first training sample are calculated based on the species richness and the host contamination rate. The step of adjusting the parameters of the pre-trained drug resistance gene detection model according to the target loss value corresponding to the first training sample gene and in accordance with the gradient descent direction of the target loss value includes: Based on the training weights corresponding to the genes in the first training sample, the target loss values corresponding to the genes in the first training sample are weighted. Based on the weighted target loss value corresponding to the genes in the first training sample, the parameters of the pre-trained drug resistance gene detection model are adjusted according to the gradient descent direction.
8. A device for detecting drug resistance genes, characterized in that, The device includes: The data acquisition module is used to acquire the first sequencing data corresponding to the sample to be tested and the second sequencing data corresponding to the negative control sample; the first sequencing data contains at least one non-drug-resistant housekeeping gene; the second sequencing data contains at least one drug-resistant gene. A data calculation module is used to calculate the noise baseline value based on the coverage of the second sequencing data in the target region; the target region is composed of drug resistance genes. The data calculation module is also used to calculate the stability coefficient corresponding to the first sequencing data based on the original abundance of the at least one non-drug-resistant housekeeping gene. An abundance correction module is used to correct the original abundance of the target gene in the first sequencing data based on the noise baseline value and the stability coefficient, so as to obtain the target abundance of the target gene; the target gene is one or more genes in the first sequencing data other than the at least one non-drug-resistant housekeeping gene. The drug resistance detection module is used to perform drug resistance detection on the target gene based on the first sequencing data and the target abundance corresponding to the target gene, and obtain the detection result corresponding to the target gene. The detection result is used to indicate whether the target gene is a drug-resistant gene.
9. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 7.