Introduction to ampir

Legana Fingerhut

2021-06-29

Background

The ampir (short for antimicrobial peptide prediction in r ) package was designed to be a fast and user-friendly method to predict antimicrobial peptides (AMPs) from any given size protein dataset. ampir uses a supervised statistical machine learning approach to predict AMPs. It incorporates two support vector machine classification models, “precursor” and “mature” that have been trained on publicly available antimicrobial peptide data. The default model, “precursor” is best suited for full length proteins and the “mature” model is best suited for small mature proteins (<60 amino acids). ampir also accepts custom (user trained) models based on the caret package. Please see the ampir “How to train your model” vignette for details.

Usage

Standard input to ampir is a data.frame with sequence names in the first column and protein sequences in the second column.

library(ampir)

Read in a FASTA formatted file as a data.frame with read_faa()

my_protein_df <- read_faa(system.file("extdata/little_test.fasta", package = "ampir"))
seq_name seq_aa
tr|G1P6H5|G1P6H5_MYOLU MALTVRIQAACLLLLLLASLTSYSLLLSQTTQLADLQTQDTAGAT…
tr|L5L3D0|L5L3D0_PTEAL MKPLLIVFVFLIFWDPALAGLNPISSEMYKKCYGNGICRLECYTS…
tr|A0A183U1F1|A0A183U1F1_TOXCA LLRLYSPLVMFATRRVLLCLLVIYLLAQPIHSSWLKKTYKKLENS…
tr|Q5F4I1|Q5F4I1_DROPS MNFYKIFIFVALILAISVGQSEAGWLKKLGKRLERVGQHTRDATI…
tr|A7S075|A7S075_NEMVE MFLKVVVVLLAVELSVAQSARQRVRPLDRKAGRKRFAPIFPRQCS…
tr|F1DFM9|F1DFM9_9CNID MKVLVILFGAMLVLMEFQKASAATLLEDFDDDDDLLDDGGDFDLE…
tr|Q5XV93|Q5XV93_ARATH MSKREYERQLANEEDEQLRNFQAAVAARSAILHEPKEAALPPPAP…
tr|Q2XXN9|Q2XXN9_POGBA MRFLYLLFAVAFLFSVQAEDAELEQEQQGDPWEGLDEFQDQPPDD…

Calculate the probability that each protein is an antimicrobial peptide with predict_amps() using the default “precursor” model.

Note that amino acid sequences that are shorter than 10 amino acids long and/or contain anything other than the standard 20 amino acids are not evaluated and will contain an NA as their prob_AMP value.

my_prediction <- predict_amps(my_protein_df, model = "precursor")
seq_name seq_aa prob_AMP
tr|G1P6H5|G1P6H5_MYOLU MALTVRIQAACLLLLLLASLTSYSLLLSQTTQLADLQTQDTAGAT… 0.612
tr|L5L3D0|L5L3D0_PTEAL MKPLLIVFVFLIFWDPALAGLNPISSEMYKKCYGNGICRLECYTS… 0.945
tr|A0A183U1F1|A0A183U1F1_TOXCA LLRLYSPLVMFATRRVLLCLLVIYLLAQPIHSSWLKKTYKKLENS… 0.088
tr|Q5F4I1|Q5F4I1_DROPS MNFYKIFIFVALILAISVGQSEAGWLKKLGKRLERVGQHTRDATI… 0.998
tr|A7S075|A7S075_NEMVE MFLKVVVVLLAVELSVAQSARQRVRPLDRKAGRKRFAPIFPRQCS… 0.032
tr|F1DFM9|F1DFM9_9CNID MKVLVILFGAMLVLMEFQKASAATLLEDFDDDDDLLDDGGDFDLE… 0.223
tr|Q5XV93|Q5XV93_ARATH MSKREYERQLANEEDEQLRNFQAAVAARSAILHEPKEAALPPPAP… 0.009
tr|Q2XXN9|Q2XXN9_POGBA MRFLYLLFAVAFLFSVQAEDAELEQEQQGDPWEGLDEFQDQPPDD… 0.733

Predicted proteins with a specified predicted probability value could then be extracted and written to a FASTA file:

my_predicted_amps <- my_protein_df[my_prediction$prob_AMP > 0.8,]
seq_name seq_aa
2 tr|L5L3D0|L5L3D0_PTEAL MKPLLIVFVFLIFWDPALAGLNPISSEMYKKCYGNGICRLECYTS…
4 tr|Q5F4I1|Q5F4I1_DROPS MNFYKIFIFVALILAISVGQSEAGWLKKLGKRLERVGQHTRDATI…

Write the data.frame with sequence names in the first column and protein sequences in the second column to a FASTA formatted file with df_to_faa()

df_to_faa(my_predicted_amps, tempfile("my_predicted_amps.fasta", tempdir()))