Main

The outbreak of coronavirus disease 2019 (COVID-19) is a crisis that affects rich and poor countries alike1. Detection of SARS-CoV-2 in patient samples is a critical tool for monitoring spread of the disease, guiding therapeutic decisions and devising social distancing protocols2. Detection assays based on RT–PCR are the most effective and sensitive method for diagnosis of SARS-CoV-2 infection and are used in laboratories around the world3. However, some countries lack the laboratory resources and access to PCR kits to conduct testing at the required levels. Therefore, other reliable diagnostic techniques are needed. Most clinical diagnostic laboratories have MALDI-MS equipment, which is used to identify bacterial and fungal infections. We propose to leverage the ease-of-use and robustness of MALDI-MS pathogen identification for large-scale SARS-CoV-2 testing in developing countries.

MALDI-MS-based assays rely on reference spectra of strains and bioinformatics for high-sensitivity and high-specificity species identification through proteomic profiling. This approach is well established and accepted in many countries for routine diagnostics of yeast and bacterial infections. However, no spectral libraries for SARS-CoV-2 identification using MALDI-MS are publicly available to our knowledge.

We first acquired MALDI mass spectra of nasal swab samples that had been tested for SARS-CoV-2 by RT–PCR and analyzed them using machine learning (ML). In this experiment (Fig. 1a), a total of 362 samples (211 SARS-CoV-2-positive and 151 negative, unequivocally confirmed by PCR), which came from three different countries, Argentina (Lab 1), Chile (Lab 2) and Peru (Lab 3), were placed on the MALDI plate without prior sample purification.

Fig. 1: Coronavirus detection in nasal mucous secretion.
figure 1

a, A general scheme for SARS-CoV-2 detection by MALDI-MS and ML. The same samples of nasal mucous secretion swabs employed for PCR tests were used for MALDI mass spectra acquisition and the obtained spectra were analyzed using ML methods. b, Prediction of SARS-CoV-2 using ML. Spectral preprocessing was performed on the spectra obtained from SARS-CoV-2-positive and SARS-CoV-2-negative groups of patients. FS was applied to the obtained intensity matrices, and then PCA and ML were performed.

All spectra from the two groups under study were preprocessed, and peak detection was applied to obtain an intensity matrix (Fig. 1b). FS methods were used to select the most characteristic peaks distinguishing SARS-CoV-2-positive from SARS-CoV-2-negative samples. These data were then used for principal component analysis (PCA), where we could explore and compare the spectra in multidimensional space using peaks selected by FS methods. Finally, FS methods together with six different ML algorithms (decision tree, DT; k-nearest neighbors, KNN; naive Bayes, NB; random forest, RF; support vector machine with a linear kernel, SVM-L; support vector machine with a radial kernel, SVM-R) allowed us with a certainty of 0.947 sensitivity and 0.926 specificity to distinguish samples of the control group from patients with COVID-19 (see the description below for ML).

For the purposes of quality and reproducibility of the analysis, the MALDI-MS data must be standardized for inter-laboratory applications to afford reliable spectra. For each sample, at least 500 individual spectra (50 laser shots at 10 different spot positions) were accumulated and averaged. The parameters that must be optimized to achieve reliable and high-quality spectra include base peak intensity, signal-to-noise ratio, base peak minimum resolution, external calibration, preprocessed smoothing, baseline subtraction and internal peak alignment. The most important for typing is the internal recalibration that allows the reliable comparison of spectra. The 362 samples (Fig. 2a) under study were processed together, while Fig. 2b and Fig. 2c show a comparison of the SARS-CoV-2-positive and -negative mean spectra. With this approach, we established a mass analysis range between 3 and 15.5 kDa and a peak detection process, which resulted in an intensity matrix of 88 peaks (Supplementary Data 13). To identify peaks that differentiate SARS-CoV-2-positive from -negative samples, we applied a two-tailed Wilcoxon rank sum test (with false discovery rate corrections for multiple hypothesis testing), which afforded 31 peaks (Supplementary Table 1) with a P value < 0.05. Figure 2d shows the intensity comparison of the first six selected peaks together with one of the most relevant peaks (mass-to-charge ratio (m/z) 7,612). Differences in peak intensities between mean preprocessed MALDI-MS spectra are shown in Fig. 2e,f. The most substantial intensity difference was exhibited by the peak with m/z of 3,358 (Fig. 2e).

Fig. 2: Comparative analysis of SARS-CoV-2-positive and -negative samples.
figure 2

a, Summary of samples by country. b, Mean MALDI-MS spectra and the respective interquartile range (IQR) (denoted by orange, see the inset) processed with the MALDIquant R package, obtained from a nasal mucous secretion in the SARS-CoV-2 group. c, Mean MALDI-MS spectra and the respective IQR (denoted by blue, see the inset) processed with the MALDIquant R package, obtained from a nasal mucous secretion in the control group. d, Intensity comparison of seven selected peaks of distinct m/z in the dataset under study (the SARS-CoV-2 group is denoted as orange and the control group is denoted as blue). One of the most relevant peaks (of m/z 7,612) is highlighted by a dashed box. The boxes show the 25th–75th percentile with the median; the whiskers correspond to 1.5 × IQR. n = 362 independent samples (211 SARS-CoV-2-positive samples and 151 SARS-CoV-2-negative) were used. ****P < 0.0001 by two-tailed Wilcoxon rank sum test. Exact P values for each peak are presented in Supplementary Table 1. e, Comparison of the intensities of one of the most relevant peaks (of m/z 3,358) to differentiate the control group from the SARS-CoV-2 group; data are presented as mean values (line) ± IQR (shadow). n = 362 independent samples (211 SARS-CoV-2-positive samples and 151 SARS-CoV-2-negative) were used. f, Comparison of the intensities of one of the most relevant peaks (of m/z 7,612) to differentiate the control group from the SARS-CoV-2 group; data are presented as mean values (line) ± IQR (shadow). n = 362 independent samples (211 SARS-CoV-2-positive samples and 151 SARS-CoV-2-negative) were used. g, PCA of the mass spectra of the SARS-CoV-2 and control samples from three countries using peaks selected with the Cfs method. h, PCA of the mass spectra of the SARS-CoV-2 and control samples from Lab 1 using peaks selected with the Cfs method. i, PCA of the mass spectra of the SARS-CoV-2 and control samples from Lab 2 using peaks selected with the Cfs method. j, PCA of the mass spectra of the SARS-CoV-2 and control samples from Lab 3 using peaks selected with the Cfs method.

Next, two FS methods were used for peak selection: information gain-based (Ig) FS4 and correlation-based FS (Cfs)5. Both methods were applied to all spectra, as well as separately to the spectra obtained from each laboratory. Of note, when selected peaks were compared between laboratories, only the m/z 7,612 peak was common to all. The difference in the intensities of this peak for SARS-CoV-2-positive and -negative samples is presented in Fig. 2f (selected Ig FS and Cfs peaks for each laboratory are presented in Supplementary Table 2).

We then used PCA6 to explore and compare SARS-CoV-2-positive and -negative samples (all samples and each laboratory separately) in a multidimensional space using all 88 peaks and selected peaks for FS methods. PCA for Cfs peaks is shown in Fig. 2g–j, and PCA for Ig peaks and all 88 peaks is shown in Supplementary Fig. 1. When PCA was performed with samples from the three laboratories, the data did not completely separate (Fig. 2g); however, when samples from each country were handled independently, the SARS-CoV-2-positive group was well separated from the control group (Fig. 2h–j). For example, for samples from Lab 1, it was possible to show a better separation between groups (Fig. 2h).

Using data from Lab 2 and Lab 3 samples we could visualize better data separation into two clusters, as depicted in Fig. 2i,j. Although the Cfs method used together with PCA helps to interpret and compare the data under study, complete sample separation was not achieved, especially when samples from all three laboratories were used, and therefore more advanced methods are required to discriminate SARS-CoV-2-positive and -negative samples.

Next, we applied ML approaches to different sets of peaks to detect SARS-CoV-2 in a smaller set of 80 SARS-CoV-2-positive and -negative samples (n = 40 per group, data from Lab 2 and Lab 3). We used two different FS methods (Ig FS and Cfs; Supplementary Table 3) or no FS method. They were evaluated using six different ML methods (DT, NB, KNN, RF, SVM-L and SVM-R), thus affording a total number of 18 trained and tested ML models (Methods). Fourfold (outer) nested repeated (five times) tenfold (inner) cross-validation was used to train and test ML models and the hyperparameters of each algorithm were optimized (Supplementary Table 4).

A receiver operating characteristic (ROC) curve indicates the relationship of the true-positive rate (TPR) and the false-positive rate (FPR) and takes the uncertainty of each prediction into account when evaluating the performance of a ML model (Fig. 3a–c)7. The precision–recall (PR) curves for the six different ML algorithms are shown in Fig. 3d–f. The area under the ROC curve is equal to the probability that a classifier sorts a randomly selected positive sample higher than a randomly selected negative one8. The SVM-R model demonstrates the highest area under curve (AUC) values of 0.98 and 0.95 for ROC and PR curves, respectively (among six ML algorithms and with no FS used), indicating the highest true-positive numbers.

Fig. 3: Results of testing of 18 ML models.
figure 3

Each ML model is the combination of an FS method and an ML algorithm (40 SARS-CoV-2 samples and 40 control samples were used). a, ROC curves (TPR–FPR) for no FS and six ML algorithms. b, ROC curves (TPR–FPR) for Ig FS and six ML algorithms. c, ROC curves (TPR–FPR) for Cfs FS and six ML algorithms. d, PR curves for no FS and six ML algorithms. e, PR curves for Ig FS and six ML algorithms. f, PR curves for Cfs FS and six ML algorithms. g, Summary of the specificities obtained for each model. h, Summary of the sensitivities obtained for each model. i, Summary of the accuracies obtained for each model. j, The error count for each ML model (SARS-CoV-2 errors are denoted in orange and control errors are in blue).

Performance analysis demonstrates that the models’ sensitivities, specificities and accuracies do not vary substantially among the ML methods (Fig. 3g–i). Here, SVM-R with no FS proved to be the best method, detecting 36/40 SARS-CoV-2-positive samples and 36/40 SARS-CoV-2-negative samples (Fig. 3j). It is worth mentioning that NB, RF and SVM-L achieved high performance metrics as well, while DT and KNN showed lower performance.

Finally, we tested the ML approach for detection of SARS-CoV-2-positive samples among all 362 samples from all 3 laboratories using the SVM-R ML algorithm, together with two FS methods (Ig and Cfs) and a model without FS (Fig. 4). Each model was trained and tested with fourfold (outer) nested repeated (five times) tenfold (inner) cross-validation. In the inner cross-validation, the FS methods were applied (peaks in Supplementary Table 5) and the hyperparameters of each algorithm were optimized (Supplementary Table 6). To test each of the trained models, these were evaluated in four independent datasets (outer cross-validation). This stage allows evaluation of the models’ robustness and demonstration of their possible application for SARS-CoV-2 detection (Fig. 4). In addition, this testing approach can demonstrate whether a set of attributes from one group of patients can be used to determine the SARS-CoV-2 status in others.

Fig. 4: Performance metrics from fourfold nested cross-validation with 362 samples (inter-laboratory detection).
figure 4

a, A confusion matrix of the SVM-R model without FS. b, A confusion matrix of the SVM-R model with Ig FS. c, A confusion matrix of the SVM-R model with Cfs. d, The ROC curve for the model with all peaks (no FS). e, The ROC curve for the model with peaks selected with Ig FS. f, The ROC curve for the model with peaks selected with Cfs. g, The PR curve for the model with all peaks (no FS). h, The PR curve for the model with peaks selected with Ig FS. i, The PR curve for the model with peaks selected with Cfs. j, Performance measures for inter-laboratory detection. k, Ct values of all RT–PCR-positive sample distribution evaluated by MALDI-MS/ML confusion matrices.

Figure 4a–c presents the general confusion matrix (outer cross-validation) obtained from different models. Using no FS, 340 of 362 samples were correctly classified (Fig. 4a), achieving 0.939 ± 0.023 accuracy (Fig. 4j). Ig FS reached 0.936 ± 0.024 accuracy, with 339 of 362 samples correctly classified (Fig. 4b). When Cfs was used, 0.92 ± 0.014 accuracy was obtained, with 333 correctly classified samples. As can be seen from the ROC curves for these three approaches (no FS, Ig and Cfs, Fig. 4d–i), using SVM-R the AUC values are 0.99, 0.98 and 0.97, respectively (Fig. 4d–f). The PR curves were used as an additional indicator to assess model prediction performance (Fig. 4g–i). SVM-R achieved an AUC of 0.99 (no FS; Fig. 4g), 0.98 (Ig FS; Fig. 4h) and 0.97 (Cfs; Fig. 4i). The analysis of the ROC and PR curves indicates that it is not necessary to perform FS to have high performance, as the model without FS is highly robust. The metrics presented in Fig. 4j also support the robust performance of the SVM-R algorithm. For example, the model with the highest accuracy is SVM-R with no FS, which also achieves a sensitivity of 0.947 ± 0.029 and a specificity of 0.926 ± 0.039. Class imbalance is a common problem in ML tasks, causing instances of the minority class to be classified as the majority class9. It has also been reported that some algorithms tend to suffer more than others10. However, our model is imbalance-robust (for comparisons of ML models, see Supplementary Fig. 2).

Our approach could be used to determine SARS-CoV-2 positivity in samples screened by RT–PCR with Ct values ranging from 17 to 37 (Fig. 4k and Supplementary Table 8) from patients seeking medical care following symptoms consistent with COVID-19. Although several studies11,12 have described the relationship between Ct values and disease severity, in this study we were unable to make such correlations given a lack of data regarding patient characteristics and disease severity.

Although molecular techniques such as RT–PCR and immunochromatography are undoubtedly useful for SARS-CoV-2 detection, MALDI-MS with ML is a promising alternative given its speed, simplicity and low cost, and the availability of equipment and expertise in many hospital laboratories in developing countries. In this work, we implemented this method according to standardized protocols for SARS-CoV-2. Nasal swabs used for RT–PCR tests were useful for acquisition of MALDI mass spectra without purification, and as such, samples testing positive for SARS-CoV-2 by MS could be used in a follow-up confirmation test using the RT–PCR gold standard. Comparing RT–PCR and MALDI/ML results on our set of samples, we found a concordance rate that is acceptable as a clinical diagnostic approach (>80%). We propose a step-by-step diagnostic method that can be implemented through a ranking system combining the most robust ML models, which could be rapidly validated in other laboratories before being adopted as a fast screening assay for SARS-CoV-2.

Methods

Data reporting

No statistical methods were used to determine the patient sample size—all 362 RT–PCR swab samples available were analyzed by MALDI-MS and employed to develop the ML platform of analysis. The investigators were blinded to discrimination during experiments and outcome assessment for the samples from Argentina.

Ethical and biosafety statement

The work followed the ethical protocols approved by the Hospital Regional de Talca Commission of Ethics and no identity of any sample was related to the name of the patient or other information that could lead to personal identification. Specific patient demographic information (disease severity, age and comorbidity) was limited during this work. It was not possible obtain according to administrative protocols from clinical laboratories and confidentiality agreements. All samples were spotted on the MALDI plate and were used according to Hospital de Talca Clinical Laboratory protocols. Before analyses in the mass spectrometer, the MALDI plates, after spotting the samples inside a biosecurity cabinet, were irradiated by an ultraviolet lamp for at least 20 min to prevent any source of contamination to the mass spectrometrists.

Sample collection

A total of 362 clinical (211 RT–PCR-positive and 151 RT–PCR-negative with Ct values above 40) nasal mucous secretion samples were obtained from patients suffering or not from symptoms of SARS-CoV-2 (Regional Talca Hospital, Chile; Instituto Nacional, Peru; Reference Respiratory Virus Laboratory INEI-ANLIS “Dr. Carlos G Malbran” in Argentina) during the pandemic outbreaks in March–April of 2020. The swabs were ABS plastic sticks with a flocked nylon tip end (break point at 3 cm and total stick of 15 cm), RNAse/DNAse-free with sterile tubes containing Cary–Blair transport medium. All patients were developing symptoms suggestive of COVID-19 and had a nasopharyngeal swab sample taken for RT–PCR analyses, according to the World Health Organization PCR clinical protocols. In brief, a nasopharyngeal patient swab was collected by inserting a swab into the nostril parallel to the palate. The swab was inserted to a location equidistant from the nostril and the outer opening of ear and was left in place for a few seconds to absorb secretions. The synthetic fiber swab with a plastic shaft was placed immediately into a sterile tube containing 3 ml of viral transport medium. The same samples of nasopharyngeal swab solutions employed for RT–PCR were used directly for MALDI-MS analysis without sample preparation.

MALDI-MS analysis

Mass spectrometric analyses were performed with a MALDI time-of-flight instrument (Autoflex, Bruker) with a pulsed nitrogen laser (337 nm), operating in positive-ion linear mode using a 19 kV acceleration voltage. The matrix solution was prepared with α-ciano-hydroxy-cinnamic acid (CHCA) at 1% in acetonitrile/0.1% trifluoroacetic acid (1:1). One microliter of each nasopharyngeal swab sample (previously used for RT–PCR analysis) was spotted on a MALDI steel plate followed by the addition of 1 μl of the matrix solution (CHCA) and air-drying. Before analyses in the mass spectrometer, the MALDI plates were finally irradiated by an ultraviolet lamp inside a biosecurity cabinet for at least 20 min to prevent any source of contamination to the mass spectrometrists. Spectra were generated by summing 500 single spectra (10 × 50 shots) in the range between 3 and 20 kDa by shooting the laser at random positions on the target spot.

Spectral preprocessing

MALDI-MS fid files (Bruker) were converted to mzML with MSconvert (version 3.0.19039) from the ProteoWizard suit13, and subsequently preprocessed in R (version 4.0.0) using the MALDIquant14 and MALDIquantForeign14,15 packages. All spectra were trimmed to a range from 3 to 15.5 kDa. Square root transformation was applied, and smoothing was realized by the Savitzky–Golay method16. The baseline correction was performed using the TopHat algorithm17, and the intensity was normalized using the total ion current calibration method18. To correct the calibration differences between the samples obtained from Lab 2 (Talca) measured with a Bruker Autoflex, and Lab 1 (Argentina) and Lab 3 (Peru) measured with a Shimadzu and Bruker Microflex, respectively, we used the MALDIquant warpMassSpectra command. The applied calibration function was calculated using 14 high-intensity peaks obtained from Lab 1 and Lab 2 (Supplementary Table 8) affording the equation −(7 × 10−11)x3 + (2 × 10−6)x2 + 0.973x + 51.611. The selected peaks were manually verified to be the same. Peak detection was carried out applying a signal-to-noise ratio of 2 and a halfWindowSize of 10. Peaks were binned with the binpeaks command with a tolerance of 0.003. To avoid any additional calibration differences, the peak binning was carried out in two stages. First, SARS-CoV-2-positive and control group spectra for each laboratory were separately binned (six spectral subgroups); additionally at this stage peak filtration was performed, keeping only those peaks that were present in 80% of the spectra of each subgroup. Next, all peaks were binned together. The resulting matrix of peak intensities was used for FS, PCA and ML analyses.

Statistical analysis and FS

To compare COVID-19 and control samples, a two-tailed Wilcoxon rank sum test with false discovery rate corrections for multiple hypothesis testing was performed. Previously, sample normality was discarded by a Shapiro–Wilk test, and P values < 0.05 were considered to indicate a significant difference. The number of features is critical to determine the performance of ML-based methodologies. The MALDI-MS data highlight successful FS methods to find the most important peaks and to discriminate two or more different samples. In this work we have applied two different FS methods, Ig FS and Cfs. Both were performed using the FSelector19 package in R. We have chosen two FS filter methods, since they are faster than wrapper/embedded methods; also they are classifier independent, which is a major advantage when evaluating various algorithms. Ig FS was chosen for being a univariate filter method and Cfs for being a multivariate filter method, which evaluates dependencies between attributes (correlations).

PCA

PCA is an unsupervised ML method to reduce the dimensionality of a dataset comprising many interrelated variables. To explore and compare spectra in multidimensional space, PCA was conducted using the R FactoMineR20 and factoextra21 packages (data were scaled to unit variance). PCA was performed on all samples, and for each laboratory separately, using FS methods and without FS.

ML

An initial ML classification was performed with 80 samples to find the best algorithm. Lab 3 samples (34 SARS-CoV-2 and 17 control) together with Lab 2 samples (6 SARS-CoV-2 and 23 control) were used. Six different ML algorithms were chosen to classify SARS-CoV-2 and control samples, namely NB22, SVM-L23, SVM-R23, KNN24, DT25 and RF25. We implemented 18 ML models: combining no FS, Ig FS and Cfs methods together with 6 ML algorithms. The training and testing stages were carried out through fourfold (outer) nested repeated (five times) tenfold (inner) cross-validation (with randomized stratified splitting) in R with the Caret package. The hyperparameters of each algorithm were optimized in the inner loop by random search among 20 parameters (hyperparameters are reported in Supplementary Table 4). In this way, repeated tenfold cross-validation was performed 20 times and the models obtained with the best results were reported, according to their AUC.

ROC and PR curves were constructed using the MLeval R package, and respective AUCs were calculated. Besides, the overall cross-validation prediction performance was summarized by the accuracy, sensitivity and specificity performance measures. The equations used to quantify these performance measures are presented below (in which TP represents true positives, TN represents true negatives, FP represents false positives and FN represents false negatives):

$${\mathrm{Accuracy}} = \frac{{{\rm TP} + {\rm TN}}}{{{\rm TP} + {\rm TN} + {\rm FP} + {\rm FN}}}$$
(1)
$${\mathrm{Sensitivity}} = \frac{{{\rm TP}}}{{{\rm TP} + {\rm FN}}}$$
(2)
$${\mathrm{Specificity}} = \frac{{{\rm TN}}}{{{\rm TN} + {\rm FP}}}$$
(3)

Inter-laboratory detection

Inter-laboratory detection of SARS-CoV-2 based on ML was developed with a total of 362 MALDI-MS spectra from 3 laboratories. The training and testing stages were carried out through fourfold (outer) nested repeated (five times) tenfold (inner) cross-validation (with randomized stratified splitting) utilizing a different random sampling each time. Since the best performance measures were obtained in the previous section, SVM-R was used to train and test the ML model using all peaks from the spectral processing section; also we have applied two different FS methods, Ig FS and Cfs, to compare the obtained results. During model training, the hyperparameters of each algorithm were optimized in the inner loop by random search among 20 parameters (hyperparameters are reported in Supplementary Table 7). In summary, each model was trained 20 times by repeated tenfold cross-validation (each time using different parameters). The AUC was estimated each time, and better hyperparameters were chosen for the final model. With fourfold nested cross-validation, four independent test datasets were generated, and then the total confusion matrix and the general ROC curve for the fold were reported. In addition, the mean and standard deviation of the accuracy, sensitivity and specificity were calculated through the folds. ML was carried out in R with the Caret package and ROC and PR curves were constructed using the R package MLeval.

Reporting Summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.