Published: Vol 16, Iss 23, Dec 5, 2026 DOI: 10.21769/BioProtoc.5909 Views: 30
Reviewed by: Prashanth N SuravajhalaAnonymous reviewer(s)
Abstract
Peptides have considerable potential as therapeutics (e.g., antimicrobials, anticancer chemotherapeutics, or diabetic drugs) and drug delivery vehicles, but optimizing candidate sequences remains costly and labor-intensive because each design cycle requires experimental synthesis and testing. Machine learning offers a means to accelerate sequence-to-function optimization, yet conventional models often require thousands of labeled examples, far more than the few dozen typically available at the start of an engineering campaign. A key challenge is therefore determining, before committing experimental resources, whether a model trained on limited data is sufficiently reliable to guide candidate selection. This protocol presents a practical workflow using small-sample cross-validation-anchored regression solution for low-resource peptide engineering (SCARSE), a user-friendly computational framework designed for small datasets. By leveraging pretrained protein representations alongside standard statistical learning algorithms, SCARSE operates on as few as 20 labeled sequences without requiring structural data, complex alignments, or specialized computing hardware. We provide step-by-step instructions for data preparation, model training, candidate ranking, and integration into iterative laboratory design cycles via either a web interface or a simple Python script. Finally, we show how internal validation metrics can act as an early decision tool, allowing researchers to evaluate a model's predictive power and estimate potential candidate success before committing experimental resources.
Key features
• Trains a peptide property predictor from as few as 20 labeled sequences using ESM2 embeddings, without fine-tuning, multiple sequence alignment, or structural input.
• Provides a cross-validation R2 criterion that estimates, before any new experiment, by how much a SCARSE-guided campaign will outperform random screening.
• Runs either as a two-function Python package or as a no-code web application, on CPU-only hardware, for regression endpoints.
• Built for iterative peptide engineering, ranks unlabeled candidates, selects the next synthesis batch, and retrains as new activity data become available.
Keywords: Peptide engineeringGraphical overview
End-to-end workflow for AI-guided peptide engineering with SCARSE. The cycle begins with a small set of experimentally characterized peptides and an unlabeled candidate pool (step 1). Sequences are embedded with the ESM2 650M protein language model, and a downstream regressor [Gaussian process regressor (GPR)] is tuned by cross-validation hyperparameter search (step 2). The cross-validation (CV) R2 returned by training is compared with the published calibration curve (Figure 3h and Figure S16 of the source article [1]) in order to estimate, in advance, the enrichment of high-performing peptides the campaign will deliver relative to random screening (step 3). Every candidate is then scored, and the top N are selected (step 4), synthesized, and assayed (step 5), and the resulting labels are appended to the training set before the next round (step 6). Steps 2–4 can be performed either in the web application (Route A) or through the Python package (Route B).
Background
Peptide engineering is an inherently iterative process, in which experimental measurements accumulate gradually as candidate sequences are designed, tested, and refined. Early-stage campaigns therefore operate under a fundamental data constraint, with available measurements often comprising only a few tens or hundreds of sequences even when the ultimate objective is to explore a much larger sequence space [2,3]. This creates a substantial gap between the scale of data available in many peptide engineering campaigns and the larger datasets commonly used to develop and benchmark machine learning (ML) models. More importantly, having too few measurements to train a highly accurate model does not necessarily mean that ML is uninformative. The practical challenge is to determine whether the information contained in a small experimental dataset is sufficient to make model-guided selection more effective than unguided screening. Establishing this before investing in another round of synthesis and characterization is therefore an important part of deciding if and how to incorporate ML into a peptide engineering campaign.
Protein language models (PLMs) offer a potential way to address this data limitation by transferring information learned from large collections of unlabeled protein sequences to the peptide engineering problem at hand. Through self-supervised training, PLMs learn sequence representations that capture aspects of protein structure, function, and evolutionary relationships, which can then be used as inputs to relatively simple supervised models when only limited labeled data are available [4]. This strategy has been particularly promising in low-data protein engineering. For example, eUniRep adapts representations from the UniRep model to a target protein family, having demonstrated that useful sequence-function models could be trained from as few as 24 experimentally characterized variants, enabling the identification of improved variants in subsequent rounds of experimentation [3,5]. Related few-shot approaches have further explored how pretrained protein representations can be adapted using only small numbers of experimental measurements, while systematic benchmarking has shown that fine-tuning can improve performance across a range of protein sequence tasks [6,7].
PLM-based approaches have also been increasingly developed specifically for peptides. PeptideBERT uses pretrained sequence representations to predict properties including hemolysis, solubility, and antifouling activity, while Multi-Peptide combines sequence representations with graph-based molecular information through contrastive learning [8,9]. Other approaches, such as PepMNet, incorporate atom-level graph representations to better accommodate peptides containing non-canonical residues [10]. Beyond protein language models, a range of feature-based machine learning approaches have been applied to specific peptide activities; for example, antiviral activity has been predicted from periodicities of amino acid properties [11], and membranolytic anticancer activity has been modeled and optimized using descriptor-based classifiers [12]. Together, these studies demonstrate the growing potential of pretrained representations for peptide property prediction, but they also highlight an important practical question for experimental engineering. When only a small number of labeled peptides are available, it remains unclear whether the resulting model is sufficiently reliable to guide which candidates should be tested next.
Further practical limitations include the reliance of some methods on additional inputs that can be difficult to obtain for short peptides. Structure-aware models such as SaProt incorporate structural information alongside sequence, requiring experimentally determined or predicted structures for the sequences being evaluated [13,14]. Other approaches rely on multiple sequence alignments, for which short peptide sequences provide limited evolutionary information, and can make reliable homolog identification and alignment more challenging. These additional inputs introduce extra preprocessing steps and, in some cases, substantial computational requirements.
A more fundamental limitation concerns the low-data setting itself. Many existing methods have been developed and benchmarked using datasets that are considerably larger than those typically available at the beginning of an experimental peptide engineering campaign. Their performance in settings with only a few tens of labeled sequences is therefore less well characterized. More importantly, high predictive performance on a retrospective benchmark does not by itself indicate whether a model will provide useful guidance for selecting the next candidates to synthesize. A practical workflow therefore needs not only a model capable of learning from limited data but also a way to assess whether the available data contain sufficient signal to justify an ML-guided experimental campaign.
SCARSE (small-sample cross-validation-anchored regression solution for low-resource peptide engineering) was developed to address exactly this gap [1]. The framework uses ESM2 650M as a fixed sequence encoder, converting each peptide into a compact representation without model fine-tuning or multiple sequence alignment [4]. These design choices allow SCARSE to retain information learned during large-scale protein language model pretraining while avoiding additional structure prediction, alignment, or fine-tuning steps. The resulting representations are paired with a Gaussian process regressor, selected for its robustness on small datasets [15]. This combination provides a computationally lightweight approach for fitting sequence-to-function models when only limited experimental measurements are available.
The feature that makes SCARSE useful as a planning tool, rather than solely as a predictive model, is the relationship reported in the source study between cross-validation (CV) R2 calculated from the available labels and the endpoint performance of simulated active learning campaigns. Across diverse peptide and small-protein datasets spanning substitution and indel variants, antimicrobial peptides with minimal inhibitory concentration (MIC) endpoints, and hemolytic peptides, CV R2 was strongly correlated with active learning performance, with Pearson correlation coefficients ranging from 0.80 to 0.84 depending on the size of the labeled set [1,16–18]. The analysis further indicated that approximately 50 labeled peptides were sufficient for this relationship to provide a reasonably stable estimate. Thus, CV R2, which is obtained during routine model evaluation without additional experiments, can provide an early indication of whether model-guided selection is likely to outperform random screening. This observation forms the basis of the present protocol, which describes how to run SCARSE, interpret CV performance when deciding whether to proceed with an ML-guided campaign, and respond when the available data do not provide sufficient evidence that model-guided selection will be beneficial.
SCARSE operates exclusively on regression endpoints, for which the relationship between CV R2 and active learning performance was established.
The protocol is applicable to datasets in which a small set of peptides has been measured using a consistent assay, and a larger pool of untested candidates is available for selection. SCARSE does not generate new sequences or define the candidate search space. Instead, the candidate pool is supplied by the user and may consist of a mutational library around a lead sequence, a curated public library, or sequences generated using a separate design method. SCARSE currently operates on sequences composed of the 20 canonical amino acids and therefore does not directly support peptides containing modified side chains, covalent staples, cyclic topologies, or non-canonical residues. This limitation originates from the underlying protein language model, ESM2, which was designed to process conventional amino acid sequences. Although amino acid modifications are important in therapeutic peptide development, they fall outside the scope of the current SCARSE framework [1].
Software and datasets
All items listed in Table 1 are free of charge and openly licensed. No commercial software is required at any point. Version numbers give the configuration under which this protocol was written and verified.
Table 1. Software, model, datasets, and web application required to run the protocol.
| Type | Software/dataset/resource | Version | Date | License | Access |
|---|---|---|---|---|---|
| Code | SCARSE Python package (https://github.com/LeoAnd00/scarse) (accessed 29 Oct 2026) | 2.0.0 | 11 Oct 2026 | MIT | Free |
| Dataset | SCARSE Python package tutorial train data (https://github.com/LeoAnd00/scarse/blob/main/tutorial_data/train.csv) (accessed 29 Oct 2026) | 2.0.0 | 11 Oct 2026 | MIT | Free |
| Dataset | SCARSE Python package tutorial test data (https://github.com/LeoAnd00/scarse/blob/main/tutorial_data/test.csv) (accessed 29 Oct 2026) | 2.0.0 | 11 Oct 2026 | MIT | Free |
| Software | Python | 3.12.10 | 2025 | PSF, Python Software Foundation | Free |
| Model | ESM2 650M (facebook/esm2_t33_650M_UR50D) [4,19] (accessed 29 Oct 2026) | t33_650M_UR50D | 2023 | MIT | Free |
| Web application | SCARSE on HuggingFace Spaces (https://huggingface.co/spaces/SCARSE/scarse) | Current deployment | Accessed 4 Aug 2026 | MIT | Free |
Procedure
Sections A and B are preparatory and apply to both routes. Sections C and D are alternatives. Choose C for the no-code web application or D for the Python package. Sections E–H then apply regardless of the chosen route. Wet-lab steps appear only in section G, where the selected batch is synthesized and assayed. Those steps are deliberately generic because the assay is defined by the endpoint being optimized, not by SCARSE.
A. Establish whether the problem is within scope
1. Confirm that the endpoint is a single, consistently measured quantity. SCARSE fits one model per endpoint column and does not perform multi-task learning. If labels were produced by two different assays or in different laboratories, harmonize or discard the inconsistent subset before proceeding. Otherwise, the model will spend its limited capacity fitting batch effects.
2. Confirm that the peptides contain only the 20 canonical amino acids, written in the standard IUPAC (International Union of Pure and Applied Chemistry) one-letter code (ACDEFGHIKLMNPQRSTVWY). Sequences containing X, B, Z, U, O, gap characters, modified residues, staples, or D-amino acids are outside the scope of this protocol and are rejected by the input validator.
3. Count the labeled sequences. Twenty is the smallest number on which SCARSE has been evaluated and is enough to begin a campaign, but at least 50 were needed before the CV R2 became a reliable predictor of end-point performance in our previous study (section E) [1]. See General note 1.
4. Assemble the candidate pool. SCARSE ranks existing sequences rather than generating new ones, so a candidate pool must be defined before prediction. Three constructions are common, and all are compatible with this protocol:
a. A mutational library around one or more validated leads, for example, every single substitution or a defined set of double substitutions. This is the construction on which SCARSE performs best, because ESM2 embeddings separate closely related sequences well [1].
b. A static curated library, such as sequences drawn from a public repository like the Antimicrobial Peptide Database (APD) or an in-house collection [20,21]. Here, SCARSE acts purely as a ranking engine, and because the pool is fixed, the evaluation is highly reproducible.
c. A pool that grows between rounds, in which top-ranked sequences from one round seed new candidates by mutation or generative sampling for the next. This is supported by the protocol but was not simulated in the source article, so less predictable behavior is expected (see General note 2) [1].
5. Confirm that the endpoint is numeric. SCARSE performs regression only [for example, pMIC (the negative log10 of the MIC), a stability score, or a fitness value]. A categorical endpoint must first be converted to a meaningful numeric quantity, because binning a continuous endpoint discards ranking information, and the CV R2 criterion of section E was calibrated for regression only.
Note: A single training run may cover several numeric endpoint columns, with one independent regression model fitted per column.
B. Prepare the input files
1. Create the training file. It must contain one column of amino acid sequences and one or more endpoint columns, formatted as specified in Table 2. SCARSE accepts comma-separated, tab-separated, and Excel files. A worked example of the required layout is provided as the tutorial_data/train.csv and tutorial_data/test.csv files in the repository of SCARSE (Dataset S1) [1]; all required columns and permitted content are described in Table 2.
Table 2. Required structure of the SCARSE input files. The sequence and endpoint column names are supplied by the user through the seq_col and score_col arguments, or through the corresponding menus in the web application, so they need not carry any particular name.
| File | Column | Permitted content | Notes |
|---|---|---|---|
| Training file | Sequence column (seq_col) | Upper-case one-letter IUPAC codes drawn only from ACDEFGHIKLMNPQRSTVWY | No missing or empty values, no whitespace inside a sequence, no gap characters. Validation reports the row number of every offending sequence. |
| Training file | Endpoint column(s) (score_col) | Numeric, at least two distinct values | No missing values and only numeric values. |
| Candidate file | Sequence column (seq_col) | Upper-case one-letter IUPAC codes drawn only from ACDEFGHIKLMNPQRSTVWY | Endpoint columns are not required. If present, they are ignored, which makes it convenient to reuse a held-out file for benchmarking. |
| Both files | Any further columns | Any content | Ignored by SCARSE and not carried through to the prediction output. Keep an identifier in the sequence column itself or re-join on the sequence afterward. |
2. Remove duplicate sequences. SCARSE builds an internal mapping from sequence to endpoint value, so if the same sequence appears twice with different labels, only one of them is retained. Average or otherwise resolve replicate measurements before this point.
3. Create the candidate file containing the sequences to be ranked. Remove any sequences that have already been experimentally measured. Including previously tested peptides wastes selection slots on sequences for which the endpoint values are already known.
4. Verify the files before computing. A quick check catches the great majority of failures at zero cost:
import pandas as pddf = pd.read_csv("labelled.csv", sep=None, engine="python")VALID = set("ACDEFGHIKLMNPQRSTVWY")bad = [ i + 1 for i, s in enumerate(df["sequence"]) if pd.notna(s) and set(str(s).strip().upper()) - VALID]print("rows with invalid residues:", bad)print("missing values:", df[["sequence", "score"]].isna().sum().to_dict())print("duplicated sequences:", int(df["sequence"].duplicated().sum()))print("n labelled:", len(df), "| distinct endpoint values:", df["score"].nunique())C. Route 1: Web application (no installation)
This route requires no software beyond a browser and is the fastest way to obtain a first CV R2. Its limitations are that the trained model lives only in the browser session, so closing the tab discards it, and that runtimes are those of shared CPU hardware. The interface is laid out in Figure 1.

Figure 1. Layout of the SCARSE web application. (A) The Train Model tab. The top part holds the data controls and training settings. Results appear beneath the Train Model button once the run finishes. (B) The Predict tab, which is only usable after a model has been trained in the current session. The banner at the top reports whether a trained model is held. (C) Key to the numbered controls, which correspond to steps C2–8 of the Procedure.
1. Open https://huggingface.co/spaces/SCARSE/scarse. If the Space is asleep, it will rebuild automatically, which takes a few minutes on the first visit.
2. On the Train Model tab, upload the training file under Upload CSV/Excel (Figure 1A, control 1). The column menus populate from the file header once the upload completes.
3. Choose the Sequence Column (control 2) and tick the endpoint columns under Target Column(s) (control 3).
4. Set Random Seed (control 4). Leave it at 42 unless repeating a run under a different seed to gauge variability. The seed fixes the cross-validation splits and the hyperparameter search, so the same seed on the same file reproduces the run exactly.
5. Set CV Folds (control 5). 10 is recommended and is the value used throughout the source article [1]. The permitted range is 2–20, and the number of folds must not exceed the number of rows in the file.
6. Click Train Model (control 6) and wait. Progress is displayed under Status (control 7). Indicative runtimes are given in Table 3.
Pause point: The session must stay open, but nothing needs attention until the status box reports success. See Troubleshooting.
Table 3. Indicative runtimes. Web application figures are those reported by the deployed Space on shared CPU hardware. Note that the run time may vary beyond the specified time estimates below.
| Step | Dataset | Web application (CPU) | Comment |
|---|---|---|---|
| First use only | ESM2 650M weights | Not applicable | Locally, roughly 3 GB is downloaded once and cached. Subsequent runs skip this. |
| Training, regression | About 100 sequences | 3–4 min | Dominated by the 100 Optuna trials over 10 folds [22]. The embedding pass is a small fraction of the total. |
| Prediction | 500 candidates, 100 training sequences | 5–7 min | Both training and candidate sequences are re-embedded on every call, so batch all candidates into a single call. |
7. Read the results (control 9). The application prints a CV metrics table for each endpoint, draws a diagnostic plot for the endpoint selected in the Select Target menu (control 8), and offers a PDF report containing both. Save the PDF, as it is the only record of the run once the session closes.
8. Move to the Predict tab. Confirm the green banner reports that a model is ready (control 10), upload the candidate file (control 11), choose its sequence column (control 12), and click Predict (control 13). Download the resulting CSV file. The rows are automatically sorted by predicted value, with the highest predicted values appearing first.
D. Route 2: Python package
Note: Use this route for reproducible, scripted analysis, for candidate pools larger than a few thousand sequences, for GPU acceleration, or to automate the iterative cycle of section G.
1. Create an isolated environment and install the package. SCARSE requires Python 3.12 or later and was tested on 3.12.10.
python -m venv scarse-envsource scarse-env/bin/activate # Windows: scarse-env\Scripts\activatepython -m pip install --upgrade pippython -m pip install scarse==2.0.02. Confirm the installation and check whether a GPU will be used.
import torch, scarseprint("CUDA available:", torch.cuda.is_available())3. Train a model. scarse.train() loads and validates the file, embeds every training sequence, builds the cross-validation folds, runs the hyperparameter search, and returns the CV metrics as a nested dictionary keyed by endpoint name. We want to highlight that one can gauge the stability of the CV metric performance by training SCARSE on multiple random seeds and calculating the variation. The first call to scarse.train() downloads the ESM2 650M weights. For sequence length limitations of SCARSE, see General note 3. The arguments are given in Table 4.
import scarsecv_metrics = scarse.train( data_path="./tutorial_data/train.csv", seq_col="sequence", score_col="score", random_seed=42, folds=10, n_trials=100)print(cv_metrics)# {'score': {'MSE': 0.5514, 'RMSE': 0.7426, 'MAE': 0.5836,# 'R2': 0.6359, 'Spearman correlation': 0.8052}}Table 4. Arguments of scarse.train().
| Argument | Type and default | Meaning and practical guidance |
|---|---|---|
| data_path | str, required | Path to the training file. .csv and .tsv are read with automatic delimiter detection. Training files .xlsx and .xls are also accepted. |
| seq_col | str, required | Name of the column holding the amino acid sequences. |
| score_col | str or list of str, required | Name or names of the endpoint columns. One independent model is fitted per column, but all must be of the same problem type. |
| random_seed | int, default 42 | Seeds Python, NumPy, PyTorch, the cross-validation splits, and the Optuna sampler [22,23]. Re-running with several seeds is the simplest way to gauge how stable the reported metrics are. |
| folds | int, default 10 | Number of cross-validation folds for the shuffled K-fold cross-validation. Silently reduced to the number of samples if a larger value is requested. |
| n_trials | int, default 100 | Number of Optuna trials. Reducing it shortens runtime roughly proportionally at the cost of a less thorough search. 100 trials were used throughout the source article [1]. |
| foundation | str, default as noted | Identifier of the ESM2 checkpoint, where the default is facebook/esm2_t33_650M_UR50D. Any ESM2 checkpoint on the HuggingFace Hub is accepted. Smaller checkpoints are much faster but were not benchmarked for active learning in the source article [1]. Changing the foundation model could invalidate the calibration of section E. |
| optuna_print | bool, default True | Shows the search progress bar. Set to False in scripts and batch jobs. |
4. Predict on the candidate pool. scarse.pred() reuses the model configuration selected by the preceding train() call, re-embedding the training and candidate sequences and refitting the selected model with the stored hyperparameters on each call. It does not repeat the hyperparameter search. A full working code example is provided together with the SCARSE Python package in Code S1.
Critical: train() must be called before pred() in the same Python session, and a second train() call replaces the stored model. The output columns are listed in Table 5.
df_pred = scarse.pred(data_path="./candidate_pool.csv", seq_col="sequence")df_pred = df_pred.sort_values("pred_score", ascending=False)df_pred.head(20).to_csv("batch_round1.csv", index=False)Table 5. Columns returned by scarse.pred(). <target>
| Column | Task | Content |
|---|---|---|
| Sequence column | Both | The sequences supplied in the candidate file, in the order in which they were read. |
| pred_<target> | Regression | Predicted numeric value. Rank on this column. |
5. Batch all candidates into a single pred() call. Every call re-embeds the training set as well as the candidates and refits the selected model, so 10 calls of 100 sequences cost far more than one call of 1,000.
E. Assess model quality and apply the go or no-go criterion
1. Read the metrics returned by training. Their definitions and ranges are given in Table 6. For regression, R2 and the Spearman correlation are the two to weigh, where R2 states how much of the endpoint variance the model explains, while the Spearman correlation states how well it ranks sequences, which determines the composition of the next batch.
Table 6. Metrics returned by scarse.train(), pooled across the out-of-fold predictions of the best hyperparameter trial.
| Metric | Task | Definition/purpose | Range and interpretation |
|---|---|---|---|
| MSE (mean squared error) | Regression | Mean squared difference between predicted and experimentally measured endpoint values. Penalizes larger prediction errors more strongly than smaller errors. | 0 to ∞. A value of 0 indicates perfect prediction, with lower values indicating better performance. |
| RMSE (root mean squared error) | Regression | Square root of MSE, representing the typical magnitude of prediction error in the same units as the measured endpoint. | 0 to ∞. A value of 0 indicates perfect prediction, and lower values indicate better performance. Because it is in endpoint units, it can be compared directly with experimental or assay variability. |
| MAE (mean absolute error) | Regression | Mean absolute difference between predicted and measured endpoint values. Provides an estimate of the average prediction error without squaring individual errors. | 0 to ∞. A value of 0 indicates perfect prediction, and lower values indicate better performance. Less sensitive to large outliers than MSE or RMSE. |
| R2 (coefficient of determination) | Regression | Measures the proportion of variance in the measured endpoint explained by the predictions relative to a mean-value baseline. | -∞ to 1. A value of 1 indicates perfect prediction, 0 indicates performance equivalent to predicting the mean, and negative values indicate performance worse than the mean baseline. |
| Spearman correlation (ρ) | Regression | Measures the agreement between the rank ordering of predicted and measured endpoint values, independent of their absolute scale. | -1 to 1. A value of 1 indicates perfect rank agreement, 0 indicates no monotonic association, and −1 indicates completely reversed ranking. A random model is expected to score approximately 0. |
2. (Critical) Treat these numbers as an internal, slightly optimistic estimate rather than as held-out performance. The reported values come from the hyperparameter trial that minimized the cross-validation loss, so model selection and evaluation used the same folds. This does not undermine the criterion in step E3, because the calibration published in the source article was computed in exactly the same way, and the comparison is therefore internally consistent, but the value should not be reported as an unbiased generalization estimate [1]. Where an unbiased figure is needed, hold out a test set that is never passed to train() and evaluate on it explicitly.
3. Apply the go or no-go criterion, following Figure 2A. Locate the CV R2 on the calibration curve published as Figure 3h of [1] and as Figure S16 in its Supplementary information, choosing the panel whose data size is closest to the number of labels held. The curve reports how many times more of the true top 10% of peptides a SCARSE-guided campaign recovered relative to random sampling, after 200 peptides had been screened in simulation with a batch size of 20. The Pearson correlation between the CV R2 and the SCARSE-guided campaign end-point performance was 0.80–0.84 across datasets, and the best-performing datasets reached roughly a sevenfold advantage [1]. The bands in Figure 2A summarize the practical reading.

Figure 2. Deciding whether to commit to a SCARSE-guided campaign, and the cycle that follows. (A) Go or no-go logic. The cross-validation (CV) R2 returned by training is read against the calibration published in the source article [1]. If fewer than approximately 50 labeled peptides are available, the estimate is too variable to act on, and the spread of the estimate roughly halves between 20 and 50 labels. The three bands are indicative summaries, not thresholds derived from a formal decision analysis. (B) The iterative cycle of section G. Selection is greedy top-N with no acquisition function, so further exploration must be introduced deliberately, if desired.
More detailed relations between CV R2 of the 14 datasets in the source article and enrichment of high-performing peptide selection compared to random sampling can be seen in Table 7. This table can be used to help correlate observed CV R2 performance with possible enrichment in relation to random sampling. Further information regarding the composition of each dataset can be found in the source article [1].
Table 7. Enrichment of high-performing peptides in relation to cross-validation (CV) R2. The table shows dataset names, CV R2 performance at different dataset sizes, and enrichment of the true top 10% of peptides that a SCARSE-guided campaign recovered relative to random sampling, after 200 peptides had been screened in simulation with a batch size of 20. Mean and ± std values across 10 random seeds are reported.
| Dataset | CV R2 (Dataset size: 20) | CV R2 (Dataset size: 30) | CV R2 (Dataset size: 40) | CV R2 (Dataset size: 50) | CV R2 (Dataset size: 60) | CV R2 (Dataset size: 70) | CV R2 (Dataset size: 80) | CV R2 (Dataset size: 90) | CV R2 (Dataset size: 100) | Enrichment |
|---|---|---|---|---|---|---|---|---|---|---|
| ENVZ ECOLI | -0.08 ± 0.16 | -0.00 ± 0.09 | 0.03 ± 0.13 | 0.06 ± 0.11 | 0.09 ± 0.13 | 0.12 ± 0.14 | 0.15 ± 0.14 | 0.18 ± 0.15 | 0.17 ± 0.14 | 1.19 ± 0.25 |
| A0A247D711 LISMN | -0.01 ± 0.11 | -0.03 ± 0.07 | -0.01 ± 0.07 | 0.02 ± 0.08 | 0.02 ± 0.09 | 0.04 ± 0.14 | 0.05 ± 0.08 | 0.08 ± 0.10 | 0.09 ± 0.09 | 1.46 ± 0.22 |
| FKBP3 HUMAN | 0.10 ± 0.25 | 0.15 ± 0.24 | 0.11 ± 0.19 | 0.13 ± 0.20 | 0.13 ± 0.16 | 0.09 ± 0.13 | 0.09 ± 0.12 | 0.11 ± 0.11 | 0.12 ± 0.10 | 2.03 ± 0.27 |
| S. aureus AMPs | -0.07 ± 0.09 | 0.01 ± 0.12 | -0.02 ± 0.09 | 0.05 ± 0.10 | 0.03 ± 0.07 | 0.04 ± 0.10 | 0.04 ± 0.07 | 0.07 ± 0.08 | 0.08 ± 0.08 | 2.18 ± 0.83 |
| P. aeruginosa AMPs | -0.01 ± 0.17 | 0.03 ± 0.13 | 0.01 ± 0.07 | 0.03 ± 0.09 | 0.09 ± 0.14 | 0.11 ± 0.13 | 0.11 ± 0.10 | 0.09 ± 0.08 | 0.12 ± 0.07 | 2.63 ± 1.11 |
| HemoPI2 | -0.03 ± 0.17 | 0.09 ± 0.17 | 0.12 ± 0.13 | 0.09 ± 0.09 | 0.06 ± 0.10 | 0.08 ± 0.10 | 0.14 ± 0.09 | 0.16 ± 0.09 | 0.16 ± 0.11 | 2.86 ± 0.59 |
| SOX30 HUMAN | 0.16 ± 0.22 | 0.27 ± 0.12 | 0.37 ± 0.11 | 0.41 ± 0.15 | 0.49 ± 0.11 | 0.52 ± 0.09 | 0.53 ± 0.08 | 0.57 ± 0.09 | 0.59 ± 0.09 | 3.13 ± 0.19 |
| DN7A SACS2 | 0.18 ± 0.26 | 0.36 ± 0.21 | 0.34 ± 0.16 | 0.46 ± 0.08 | 0.51 ± 0.09 | 0.52 ± 0.12 | 0.53 ± 0.11 | 0.57 ± 0.11 | 0.59 ± 0.10 | 3.26 ± 0.22 |
| SBI STAAM | -0.01 ± 0.13 | 0.16 ± 0.14 | 0.29 ± 0.17 | 0.30 ± 0.09 | 0.34 ± 0.10 | 0.42 ± 0.07 | 0.42 ± 0.08 | 0.46 ± 0.11 | 0.48 ± 0.11 | 3.41 ± 0.42 |
| E. coli AMPs | -0.07 ± 0.08 | 0.02 ± 0.13 | 0.01 ± 0.09 | -0.00 ± 0.06 | 0.06 ± 0.10 | 0.08 ± 0.09 | 0.10 ± 0.11 | 0.12 ± 0.08 | 0.13 ± 0.07 | 3.87 ± 1.55 |
| MAFG MOUSE sub | 0.40 ± 0.23 | 0.50 ± 0.14 | 0.56 ± 0.10 | 0.61 ± 0.08 | 0.64 ± 0.05 | 0.65 ± 0.07 | 0.69 ± 0.04 | 0.72 ± 0.03 | 0.71 ± 0.04 | 4.82 ± 0.25 |
| YNZC BACSU sub | 0.50 ± 0.35 | 0.54 ± 0.28 | 0.62 ± 0.21 | 0.68 ± 0.16 | 0.69 ± 0.12 | 0.73 ± 0.11 | 0.73 ± 0.09 | 0.76 ± 0.09 | 0.76 ± 0.07 | 6.62 ± 0.35 |
| SDA BACSU | 0.70 ± 0.16 | 0.75 ± 0.12 | 0.82 ± 0.06 | 0.84 ± 0.05 | 0.84 ± 0.04 | 0.82 ± 0.06 | 0.85 ± 0.05 | 0.86 ± 0.04 | 0.85 ± 0.04 | 6.79 ± 0.48 |
| POLG PESV sub | 0.20 ± 0.21 | 0.33 ± 0.19 | 0.41 ± 0.17 | 0.46 ± 0.11 | 0.49 ± 0.12 | 0.55 ± 0.09 | 0.58 ± 0.05 | 0.59 ± 0.08 | 0.63 ± 0.05 | 6.99 ± 0.71 |
4. Run a negative control before trusting a borderline result. Shuffling the endpoint column destroys the sequence-to-function relationship while leaving everything else intact, so a model that still scores well is detecting leakage rather than biology. This is particularly important when datasets contain near-duplicate sequences, which can inflate CV performance and give an overly optimistic impression of model generalizability. A shuffled-label control can therefore help identify whether the observed performance reflects a genuine predictive signal. On the tutorial dataset, this control gives a held-out R2 of approximately -0.001, against 0.695 for the genuine labels (Table 8). See General note 4.
import numpy as np, pandas as pd, scarsedf = pd.read_csv("labelled.csv")rng = np.random.default_rng(0)df["score_shuffled"] = rng.permutation(df["score"].values)df.to_csv("labelled_shuffled.csv", index=False)null_metrics = scarse.train(data_path="labelled_shuffled.csv", seq_col="sequence", score_col="score_shuffled")print(null_metrics) # R2 should sit at or below zeroTable 8. Representative results from the tutorial dataset. The model was trained using 100 sequences and evaluated on an independent held-out set of 500 sequences. Default settings were used. score_2 is a copy of score with Gaussian noise of standard deviation 0.1 added. score_shuffled is the score with its values randomly permuted and therefore serves as a negative control.
| Endpoint | Task | CV metrics (n = 100) | Held-out metric (n = 500) |
|---|---|---|---|
| score | Regression | R2 0.636, Spearman 0.805, RMSE 0.743, MAE 0.584 | R2 0.695 |
| score_2 | Regression | R2 0.620, Spearman 0.806, RMSE 0.771, MAE 0.602 | R2 0.685 |
| score_shuffled | Negative control | R2 -0.011, Spearman -0.196, RMSE 1.237, MAE 1.039 | R2 - 0.001 |
5. Decide. If the criterion is favorable, continue to section F. If it is not, the options are to add labels, to re-examine assay noise and the definition of the endpoint, or to reconsider the candidate pool. Note that SCARSE-guided selection outperformed random sampling on every dataset tested in the source article [1], so even a weak model is preferable to random screening when no better selection strategy is available. See General note 5.
F. Rank candidates and choose the next experimental batch
1. Score the full candidate pool as in step C8 or D4 and sort by the predicted value, descending for endpoints to be maximized and ascending for endpoints to be minimized.
Critical: Check the direction of the endpoint. Optimizing an antimicrobial peptide means maximizing pMIC but minimizing MIC itself. Sorting the wrong way would instead select the worst candidates in the pool.
2. Rank on the predicted numeric value. SCARSE returns a single regression prediction per endpoint, which directly orders the candidate pool.
3. Consider reserving part of each batch for exploration (optional). Selection in SCARSE is greedy top-N without an acquisition function, so it is pure exploitation of the current model. A practical compromise could be to fill roughly 70% of each batch from the top of the ranking and the remainder with sequences chosen for diversity, for example, by selecting the sequences from the bottom of the ranking, encouraging diversity in the acquired data. This exploration strategy was evaluated in the source article but did not result in higher performance on the datasets tested [1]. We note that more principled acquisition functions exist, such as upper confidence bound (UCB) or Thompson sampling, which exploit the posterior predictive variance of the Gaussian process to balance exploration and exploitation [24,25]. The source article evaluated the UCB acquisition strategy and found that it did not improve selection performance over greedy top-N on the datasets tested. See General note 6.
4. Apply any hard filters (optional). Sequences that are unreasonable on grounds independent of the model, for example, outside a workable length range or above a hydrophobicity ceiling that would compromise synthesis, are best removed prior to step F1 or after ranking so that the filter can be documented and changed without retraining.
ranked = df_pred.sort_values("pred_score", ascending=False)# example hard filter: keep peptides of 8 to 20 residuesL = ranked["sequence"].str.len()ranked = ranked[(L >= 8) & (L <= 20)]batch = ranked.head(20)batch.to_csv("batch_round1.csv", index=False)G. Run the iterative cycle
Note: Figure 2B shows the discovery loop. One pass consists of training on everything measured so far, ranking the remaining pool, synthesizing and assaying the selected batch, and moving the new labels into the training file.
1. Train on all available labels and record the CV R2 for this round, so that the trajectory across rounds can be inspected later.
2. Rank the pool and export the batch, as in section F.
3. Synthesize and assay the selected peptides.
Critical: Use the same assay, the same units, and the same endpoint transformation as for the existing labels. Mixing, for example, pMIC values with raw MIC values, or measurements made against different bacterial strains, corrupts the training set in a way the model cannot detect. Record failed syntheses explicitly rather than dropping them silently, so that the pool can be kept accurate.
4. Append the new measurements to the training file and remove the tested sequences from the candidate pool.
import pandas as pdlabelled = pd.read_csv("labelled.csv") # sequence, scoremeasured = pd.read_csv("batch_round1_measured.csv") # sequence, scorelabelled = pd.concat([labelled, measured], ignore_index=True)labelled = labelled.drop_duplicates(subset="sequence", keep="last")labelled.to_csv("labelled.csv", index=False)pool = pd.read_csv("candidate_pool.csv")pool = pool[~pool["sequence"].isin(measured["sequence"])]pool.to_csv("candidate_pool.csv", index=False)5. Repeat from step G1 until a peptide of sufficient performance is found or the budget is exhausted. The following script automates one full round and stops at the point where laboratory work is required, where a batch size of 20 is specified, but can be adjusted to a desired batch size.
import pandas as pd, scarseBATCH, ROUND = 20, 1metrics = scarse.train(data_path="labelled.csv", seq_col="sequence", score_col="score", random_seed=42, optuna_print=False)print(f"round {ROUND}: CV R2 = {metrics['score']['R2']:.3f}")ranked = scarse.pred(data_path="candidate_pool.csv", seq_col="sequence")ranked = ranked.sort_values("pred_score", ascending=False)ranked.head(BATCH).to_csv(f"batch_round{ROUND}.csv", index=False)# --- synthesise and assay batch_round1.csv, then return to step G4 ---6. Do not expect the CV R2 to rise monotonically between rounds. Greedy selection deliberately concentrates the training set in the high-performing region of sequence space, which narrows the endpoint range and can depress R2 even while the campaign is succeeding. Judge progress by the measured values of the selected peptides, not by the metric alone. See General note 7.
H. Optimize several endpoints at once (optional)
1. Train a single model covering all numeric endpoints by passing a list to score_col. One independent model is fitted per endpoint, and pred() returns one prediction column for each.
2. Combine the predictions into a single desirability score. Because the endpoints are on different scales, standardize before weighting. The following script outlines an example of how to standardize and weight the data.
cv_metrics = scarse.train(data_path="labelled.csv", seq_col="sequence", score_col=["pMIC", "log_hemolysis"])df_pred = scarse.pred(data_path="candidate_pool.csv", seq_col="sequence")z = lambda s: (s - s.mean()) / s.std()df_pred["desirability"] = (0.7 * z(df_pred["pred_pMIC"]) - 0.3 * z(df_pred["pred_log_hemolysis"]))ranked = df_pred.sort_values("desirability", ascending=False)3. (Critical) Choose the weights deliberately and record them. Inappropriate weighting biases the whole campaign and can quietly misrepresent the properties wanted in the target peptide [1]. Inspect the ranking under two or three weightings before committing and check the CV R2 of each endpoint separately. A poorly predicted endpoint contributes noise to the combined score in proportion to its weight.
4. All endpoints are numeric, so a desirability score can combine them directly as above. If one endpoint should act as a constraint rather than an objective, rank on the primary numeric prediction among candidates whose predicted value for the secondary endpoint satisfies a chosen threshold.
Result interpretation
The immediate output of training is the cross-validation table, and the immediate output of prediction is a ranked candidate list. Both should be read with the campaign in mind rather than as end results by themselves.
Regression: An R2 of 0.6 or above on a mutational library indicates that the embeddings are separating closely related sequences well and that the ranking can be trusted to concentrate the next batch in the high-performing region. Values between 0.3 and 0.6 are common and still support a productive campaign. Below about 0.3, look at the Spearman correlation before concluding that the model is uninformative, since R2 penalizes errors in the predicted magnitude, whereas batch selection depends only on the ordering. A model with modest R2 but a good Spearman correlation could still select well.
Diagnostic plots: For regression, the true-versus-predicted scatter produced by the web application is worth inspecting even when R2 looks acceptable. Two failure patterns may be apparent in the plot even when they are obscured by summary statistics. The first is a horizontal band of predictions clustered around the training mean, suggesting that the model has learned little and is effectively hedging toward the average (see Figure 3A). The second is good agreement across most of the observed range combined with systematic compression toward the mean at the extremes, with high values underestimated and low values overestimated (see Figure 3B). This pattern indicates that the model captures the general relationship between sequence and endpoint but has difficulty distinguishing candidates at the boundaries of the observed range. This is particularly important for SCARSE because candidate selection focuses on identifying high-performing sequences. Underestimation of the upper tail can therefore reduce the model's ability to distinguish the best candidates, even when the overall R2 remains acceptable.

Figure 3. Representative diagnostic true-versus-predicted plots for evaluating SCARSE regression models. (A) Predictions collapsed around the mean. A model that has learned minimal sequence-function relationships produces a horizontal band of predicted values clustered tightly around the training mean, effectively defaulting to predicting the average endpoint value regardless of sequence input. (B) Regression to the mean at extreme values. A model that captures the general relationship across the central dataset range but suffers from systematic compression at the boundaries. Low observed values are overestimated, and high observed values are underestimated, impairing the identification and ranking of high-performing candidates in the upper tail. Dashed diagonal lines represent the ideal identity fit.
Across rounds: The behavior to expect is a roughly linear accumulation of high-performing peptides as screening proceeds. In the simulations of the source article, the selectivity for high performers stayed essentially constant over 200 screened peptides [1]. The knowledge gained from each new batch offsets the shrinking supply of good candidates left in the pool. The practical consequence is encouraging, and worth stating plainly. SCARSE is about as useful at the start of a campaign as after 200 peptides have been screened, indicating that there is no advantage in deferring its introduction until a larger dataset has accumulated.
Validation of protocol
This protocol and the SCARSE framework were developed and validated in Andrekson et al. [1], AI-guided discovery for low-resource peptide engineering using evolutionary scale modeling, bioRxiv (Figures 2 and 3, and Supplementary information Sections S4 and S6). SCARSE was further validated using the tutorial dataset, with representative results provided in Table 8 as a reproducibility check for new installations.
General notes and troubleshooting
General notes
1. On the minimum number of labels: Twenty labeled peptides are enough to start a campaign and were shown to deliver useful selection, but they are not enough to predict how the campaign will end [1]. The spread of the CV R2 across random seeds falls by roughly half between 20 and 50 labels, which is why 50 is the recommended threshold for acting on the criterion of section E rather than merely running the model.
2. On the candidate pool: The simulations drew from fixed pools of moderate size. In a real campaign, the pool may be far larger and may change between rounds, and the effect of that difference has not been characterized experimentally. Expect the published enrichment figures to be indicative under such conditions.
3. On sequence length: Sequences are truncated at 1,024 tokens by the tokenizer. This is far beyond any peptide and above the longest sequences benchmarked in [1], which reached 87 residues, but it will silently truncate genuinely long proteins.
4. On the negative control: Running the shuffled-label control of step E4 costs one extra training run and is the cheapest available protection against one of the most common silent failures in small-data modeling, namely leakage between cross-validation folds through duplicated or near-duplicated sequences.
5. On unfavorable criteria: A low CV R2 is informative rather than fatal. SCARSE beat random sampling on every dataset tested, so if no better selection strategy is available, it remains the rational choice [1]. A low value should instead influence the scale of the experimental commitment. In this situation, a small exploratory batch that expands the training set could be preferable to a large batch selected on the basis of an uncertain ranking.
6. On greedy selection: The simulations underlying this protocol used greedy top-N selection with no acquisition function, so behavior is pure exploitation. Conventional active learning would balance this against uncertainty, and the source article evaluated an uncertainty-aware UCB acquisition strategy, which did not outperform greedy top-N selection on the datasets tested. The Gaussian process used for regression does expose a predictive variance, but the packaged interface does not return it, so exploration would need to be introduced at the batch composition stage, if desired (step F3).
7. On endpoints and transferability: Validation covered activity, stability, antimicrobial potency (pMIC), and hemolytic activity, but the model's performance on other endpoints remains unknown. Therefore, the CV R2 bands shown in Figure 2A should not be interpreted as universally applicable across endpoints. A consistent relationship between training-set size and regression performance was observed across the regression-based tasks (activity, stability, pMIC, and hemolytic activity), suggesting that this relationship likely extends to other endpoints. However, this should be regarded as a hypothesis rather than a validated generalization, and the reported R2 bands should be interpreted accordingly.
Troubleshooting
Problem 1: Training stops with a message about invalid amino acid sequences, listing row numbers.
Possible cause: The sequence column contains characters outside ACDEFGHIKLMNPQRSTVWY, such as X for an unknown residue, gap characters from an alignment, trailing whitespace, or a header row read as data.
Solution: The message reports the first 10 offending rows and the invalid characters found in each. Strip whitespace, remove or resolve ambiguous residues, and confirm that the file has a proper header. Peptides with genuinely non-canonical residues cannot be modeled by SCARSE.
Problem 2: RuntimeError: You must call train() before pred().
Possible cause: The trained model configuration is held in module-level state, which is lost when the Python session restarts, when a notebook kernel is restarted, or when the browser tab holding the web application is closed.
Solution: Re-run training in the same session before predicting. For long campaigns, script training and prediction together as in step G5 so that a round always runs as a single unit.
Problem 3: The first run stalls or fails while loading the foundation model.
Possible cause: Roughly 3 GB of ESM2 650M weights are downloaded on first use, which fails behind a restrictive proxy or on a machine without network access.
Solution: Run once on a connected machine to populate ~/.cache/huggingface or set HF_HOME to a pre-populated cache directory. A report listing lm_head keys as unexpected and pooler keys as missing is printed on every load and is expected: only the encoder is used, so those layers are irrelevant.
Problem 4: The run exhausts memory during embedding.
Possible cause: Sequences are embedded in batches of 64, and all embeddings are held in memory. A very large candidate pool or unusually long sequences can exceed available RAM or GPU memory.
Solution: Split the candidate file into chunks of a few thousand sequences and concatenate the resulting prediction tables. Note that each chunk incurs the cost of re-embedding the training set, so use the largest chunk the machine will take.
Problem 5: CV R2 is negative.
Possible cause: The model is performing worse than always predicting the mean. With very few labels, this can happen by chance. It can also indicate an endpoint dominated by assay noise or a training set spanning heterogeneous conditions.
Solution: Repeat under three to five random seeds to distinguish an unlucky split from a genuine absence of signal. If negative values persist, revisit the endpoint definition and the consistency of the assay before adding more data.
Problem 6: Performance looks implausibly good.
Possible cause: Duplicated or near-duplicated sequences shared between folds, or a candidate file that overlaps the training file.
Solution: Run the shuffled-label control of step E4, deduplicate the training file, and remove tested sequences from the pool.
Problem 7: The web application reports that the dataset has fewer rows than the requested number of cross-validation folds.
Possible cause: The default of 10 folds exceeds the number of labeled sequences.
Solution: Reduce CV Folds to at most the number of rows. Note that the Python interface silently reduces the fold count instead of raising an error, so check the value actually used when working with very small files.
Supplementary information
The following supporting information can be downloaded here:
1. Dataset S1. tutorial_data/train.csv and tutorial_data/test.csv, the 100-sequence and 500-sequence subsets of POLG_PESV used in Table 8, together with the derived binary, multi-class, and randomized label columns.
2. Code S1. tutorial.ipynb, a notebook reproducing every training and prediction call in sections D and E for one and two regression endpoints.
The supporting material is distributed with the SCARSE Python package rather than with this protocol and is available from https://github.com/LeoAnd00/scarse.
Acknowledgments
This work was funded by the Swedish Research Council (grant number 2024-02040 to M.W.).
This work made use of large language model (LLM)-based artificial intelligence tools, more specifically ChatGPT-4o, Claude Sonnet 4.6 and Opus 4.8, and Gemini 3.1 Flash-Lite, 3.5 Flash, and 3.1 Pro, for support in text editing, image editing, and coding. These tools were used to assist with improving clarity, grammar, and overall readability of the written content, to improve conceptual figures, and to provide suggestions and guidance in the development and refinement of code.
Author contributions
L.A.: Conceptualization, Investigation, Methodology, Software, Validation, Data Curation, Writing—Original Draft, Visualization. M.W.: Conceptualization, Investigation, Writing—Review & Editing, Supervision, Resources, Funding acquisition, Project administration.
Competing interests
The authors declare no conflicts of interest.
Ethical considerations
Not applicable. This protocol is entirely computational, except for the generic synthesis and assay steps of section G, and involves no human participants, human data, human tissue, or animal experiments.
References
Article Information
Publication history
Received: Aug 28, 2026
Accepted: Nov 8, 2026
Available online: Nov 26, 2026
Published: Dec 5, 2026
Copyright
© 2026 The Author(s); This is an open access article under the CC BY license (https://creativecommons.org/licenses/by/4.0/).
How to cite
Andrekson, L. and Wenzel, M. (2026). AI-Guided Peptide Engineering From Small Experimental Datasets Using SCARSE. Bio-protocol 16(23): e5909. DOI: 10.21769/BioProtoc.5909.
Do you have any questions about this protocol?
Post your question to gather feedback from the community. We will also invite the authors of this article to respond.
Share
Bluesky
X
Copy link

