Basic pLAST usage
Imports and configuration
[1]:
import logging
from pathlib import Path
import pandas as pd
from plast.data import PLASTData
from plast.plast import PLAST
from examples.configuration import config
Load configuration to PLASTData object
[2]:
pl_data = PLASTData(config)
Loading pLAST data...
Set logger to “warning” to not print too much informations
[3]:
logger = logging.getLogger("plast")
logger.setLevel(logging.WARNING)
Analyze sequence using MMseqs2 model
Initialize PLAST object - load config, choose model and add logger
[4]:
plast = PLAST(data=pl_data, model="mmseqs2_model", logger=logger)
Load example plasmid sequence from .fasta file and annotate with prodigal
[5]:
plast = plast.load_nt_fasta(open("examples/NZ_AP018444.1.fasta").read())
print("Plasmid of langth", plast.length, "has the following annotation:")
display(plast.parsed)
Plasmid of langth 181607 has the following annotation:
| locus_tag | start | end | strand | type | gene | product | translation | |
|---|---|---|---|---|---|---|---|---|
| 0 | NZ_AP018444.1_1 | 3 | 410 | 1 | CDS | FLIGTLLLFGLAACDSIKSVASDVTVGKVIEEFKAAGLEAEQPSDL... | ||
| 1 | NZ_AP018444.1_2 | 561 | 776 | -1 | CDS | MKNKRDRLAILPAIDSFINFISITLTINARNNGINSTMASLIAMSF... | ||
| 2 | NZ_AP018444.1_3 | 848 | 937 | -1 | CDS | MLQKEEKVMGKTLFIAEKLKVANEIIKSL* | ||
| 3 | NZ_AP018444.1_4 | 1127 | 1765 | -1 | CDS | MEVLIFELILIAVLIPLNSVVKKHVPKWKGKAGEKLVKRMLSKLDP... | ||
| 4 | NZ_AP018444.1_5 | 1782 | 2015 | -1 | CDS | MGTVKNVEKRLPTWANFGVIEKPVNRRVTRPFQFRGGLLVSLALGF... | ||
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 187 | NZ_AP018444.1_188 | 175616 | 176212 | -1 | CDS | MSACSSSAQTKNDSRPAQAVQNGIQQHVEGKDIVDIPEAYKRKLKG... | ||
| 188 | NZ_AP018444.1_189 | 176689 | 179352 | -1 | CDS | MGKTLFIAEKPKVANEIMKSPRFRHSQKYIGSKPYYGYYENDHYIV... | ||
| 189 | NZ_AP018444.1_190 | 179919 | 180323 | -1 | CDS | MQQCLKYNCGTIQLEDLQGISKEQAFLKNWTYFDLQEKIKNQANQY... | ||
| 190 | NZ_AP018444.1_191 | 180464 | 181204 | -1 | CDS | MKYIYVHFHYHFRTIGNRTIQKLWEYDNQSLKHFKDTGQYPSAQQL... | ||
| 191 | NZ_AP018444.1_192 | 181546 | 181605 | 1 | CDS | MISKDLSTVGGTHKYVKKII |
192 rows × 8 columns
Assign cluster identifiers to the plasmid proteins
[6]:
plast = plast.assign_mmseqs_clusters(use_gpu=False, threads=16)
print("Number of assigned clusters:", len(plast.vector))
print("Assigned clusters:")
print(plast.vector)
Number of assigned clusters: 192
Assigned clusters:
['1726383', '148937', None, '1728687', '1448965', '965893', '1352966', '274635', '1329213', '937429', '58827', '1125732', '125058', '397664', '1309585', '849139', '1608308', '1774255', '1305808', '823963', '914165', '424635', '1962137', '1604810', '1180630', '95863', '693312', '32114', '1023247', '162059', '1592724', '117164', '1125732', '1817959', '242486', '980376', '292496', '1116255', '292496', '593498', '88330', '348526', '1162655', '1758823', '380840', '418057', '38255', '272555', '1407794', '1323801', '1845834', '418057', '418057', '65429', '713699', '1581456', '1492243', '755590', '1927622', '744391', '181159', '443359', '1035554', '726077', '778536', '252085', '1465232', '526994', '680046', '1080639', '760499', '1095998', '173906', '1525104', '501114', '1121675', '1307378', '1587438', '1590278', '1590278', '284942', '1026005', '561496', '1332624', '641459', '22307', '1289793', '1414715', '220900', '556593', '861431', '776119', '1482033', '41154', '483741', '517033', '1348503', '1408017', '1231094', '1477873', '418422', '686309', '15465', '438928', '871872', '722568', '139193', '1677282', '1725518', '1084212', '1715426', '272556', '330209', '1018788', '495705', '353724', '1517740', '1242764', '1054904', '1005010', '1080454', '1080454', '1222282', '1587200', '1145217', '1934657', '1722622', '564115', '1411678', '1005296', '1059403', '1578105', '631709', '886150', '655315', '858156', '1975252', '569631', '126985', '1375233', '1785719', '978057', '694260', '1092372', '1817518', '421882', '968129', '1548607', '1489993', '288264', '126476', '980684', '1910602', '954653', '186797', '714481', '424239', '1371363', '548390', '1857899', '345043', '969528', '481490', '1289102', None, '693232', '724871', '16603', '645079', '1080454', '1080454', '1145984', '1145984', '1080454', '1529217', '434562', '1829014', '1926563', '1493192', '908054', '567172', '1011689', '914407', '56100', '288264', '1331321', '1147133', '593027', '205985', '664352', '564116', None]
Pass data through pLAST model and receive embeddings
[7]:
plast = plast.encode()
print("Plasmid embedding:")
print(plast.embedding)
Plasmid embedding:
[ 0.16471866 -0.08894535 0.11579394 -0.01732706 -0.11079773 -0.01380745
-0.04653129 -0.12210099 -0.12558307 0.18801463 -0.07162381 0.04096976
-0.01991154 -0.04585328 -0.15146436 0.14647095 0.03018236 0.28174242
-0.0978851 0.14704888 0.00766877 -0.07863601 -0.01845692 -0.01584697
0.17130908 -0.3024303 0.07048776 0.04974978 -0.09092903 0.10596259
0.09919997 0.00148555 -0.02341652 0.06497296 0.00272284 0.07149697
0.25530246 0.05554739 -0.01458314 0.1768556 -0.07046866 -0.09388541
0.02164434 -0.02105708 0.13358366 0.3737567 0.09823149 -0.00990677
-0.0734854 -0.11207584 0.01302719 0.24148823 -0.01188859 -0.13840665
-0.18913814 -0.07030325 0.19642639 -0.06978988 -0.03530707 -0.0896187
0.13096678 0.07975508 -0.01628163 0.19070303]
Whole-plasmid comparison (global search)
get_most_similar() compares the embedding of the complete query plasmid against complete plasmid embeddings stored in the selected pLAST model.
[8]:
results = plast.get_most_similar(maxret=15)
[9]:
df = pd.DataFrame.from_dict(results, orient="index")
for c in ("pLAST_distance", "gc"):
if c in df.columns:
df[c] = pd.to_numeric(df[c], errors="coerce").round(6)
preferred = [
"pLAST_distance",
"length",
"gc",
"taxid",
"organism",
"definition",
"taxonomy",
"rep_type(s)",
"AMR",
"relaxase_type(s)",
"mpf_type",
"orit_type(s)",
"predicted_mobility",
]
cols = [c for c in preferred if c in df.columns] + [
c for c in df.columns if c not in preferred
]
display(df[cols])
| pLAST_distance | length | gc | taxid | organism | definition | taxonomy | rep_type(s) | AMR | relaxase_type(s) | mpf_type | orit_type(s) | predicted_mobility | accession | database | topology | primary_cluster_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| IMGPR_plasmid_3300008282_000245 | 1.0 | 11117 | 0.234776 | NaN | - | NaN | NaN | - | ACR,CIP,ERY,FOS,MIN,NOR,OTC,TEC,TET,VAN | - | - | - | non-mobilizable | IMGPR_plasmid_3300008282_000245 | IMG-PR | linear | AG673 |
| COMPASS_NC_013208.1 | 1.0 | 7907 | 0.543443 | 521098.0 | Alicyclobacillus acidocaldarius | Alicyclobacillus acidocaldarius subsp. acidoca... | Bacteria;Bacillota;Bacilli;Caryophanales;Alicy... | - | - | - | - | - | non-mobilizable | COMPASS_NC_013208.1,GenBank_CP001730.1,PLSDB_N... | COMPASS,GenBank,PLDSB,RefSeq | circular | AB250 |
| GenBank_CP065945.1 | 1.0 | 27165 | 0.551224 | 1402.0 | Bacillus licheniformis | Bacillus licheniformis strain H2 plasmid unnam... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | - | - | - | - | - | non-mobilizable | GenBank_CP065945.1,PLSDB_NZ_CP065945.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA379 |
| IMGPR_plasmid_3300053491_097066 | 1.0 | 3991 | 0.324981 | NaN | - | NaN | NaN | - | AMK,AZM,CLI,CLR,CST,DAL,DIR,ERY,GEN,GSV,ISP,KA... | - | - | - | non-mobilizable | IMGPR_plasmid_3300053491_097066 | IMG-PR | direct terminal repeat | AA379 |
| IMGPR_plasmid_3300022690_000377 | 1.0 | 5177 | 0.378018 | NaN | - | NaN | NaN | - | AMX,CEF,CRO,FOX,RFB,RFX,RIF,RPT,SPT,STR,TIC,TMO | - | - | - | non-mobilizable | IMGPR_plasmid_3300022690_000377 | IMG-PR | direct terminal repeat | AA379 |
| IMGPR_plasmid_2836988040_000027 | 1.0 | 10449 | 0.615178 | NaN | Paracraurococcus ruber | NaN | NaN | - | SPT,TET,THA,TIA | - | - | - | non-mobilizable | IMGPR_plasmid_2836988040_000027 | IMG-PR | direct terminal repeat | AA379 |
| IMGPR_plasmid_3300031708_000567 | 1.0 | 7984 | 0.587675 | NaN | - | NaN | NaN | - | ABK,AMK,CIP,CST,ERY,GEN,MEM,NOR,OFX,PMB,TET,TG... | - | - | - | non-mobilizable | IMGPR_plasmid_3300031708_000567 | IMG-PR | linear | AA379 |
| GenBank_CP110135.1 | 1.0 | 11389 | 0.328563 | 450367.0 | Peribacillus frigoritolerans | Peribacillus frigoritolerans strain Q2H1 plasm... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | - | - | - | - | - | non-mobilizable | GenBank_CP110135.1,PLSDB_NZ_CP110135.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA379 |
| IMGPR_plasmid_3300005933_000174 | 1.0 | 7700 | 0.534935 | NaN | - | NaN | NaN | - | AMK,CHL,CIP,DAL,DBK,ERY,GAT,GEN,GSV,LVX,MDM,MX... | - | - | - | non-mobilizable | IMGPR_plasmid_3300005933_000174 | IMG-PR | direct terminal repeat | AA379 |
| mMGEs_k141_157016_r14~1324711 | 1.0 | 1636 | 0.579462 | NaN | - | NaN | NaN | - | AMP,CAZ,SPT | - | - | - | non-mobilizable | mMGEs_k141_157016_r14~1324711 | mMGE | linear | AA379 |
| mMGEs_k141_406140_r14~378905 | 1.0 | 1535 | 0.568078 | NaN | - | NaN | NaN | - | ATM,ERY,KIT,LVX,NAL,NOV,ROK,TET | - | - | - | non-mobilizable | mMGEs_k141_406140_r14~378905 | mMGE | linear | AA379 |
| IMGPR_plasmid_3300007766_000506 | 1.0 | 6447 | 0.273476 | NaN | - | NaN | NaN | - | AMP,CFZ,CLI,CST,FOX,LIN,RET,TIA,TMP,VGM | - | - | - | non-mobilizable | IMGPR_plasmid_3300007766_000506 | IMG-PR | direct terminal repeat | AG435 |
| mMGEs_k141_269674_r14~2763926 | 1.0 | 1732 | 0.538106 | NaN | - | NaN | NaN | - | ACR,AMK,CHL,CIP,CLX,CST,ERY,GEN,IPM,MEM,NOR,OF... | - | - | - | non-mobilizable | mMGEs_k141_269674_r14~2763926 | mMGE | linear | AA379 |
| mMGEs_k141_1568014_r14~1295310 | 1.0 | 1876 | 0.386994 | NaN | - | NaN | NaN | - | CLI,HYG,IBX,RET,TET | - | - | - | non-mobilizable | mMGEs_k141_1568014_r14~1295310 | mMGE | linear | AA379 |
| IMGPR_plasmid_3300010965_000027 | 1.0 | 4348 | 0.487810 | NaN | - | NaN | NaN | - | AZM,CLR,DIR,ERY,OLD,ROX,SPI,TEL,TYL,VAN | - | - | - | non-mobilizable | IMGPR_plasmid_3300010965_000027 | IMG-PR | linear | AA379 |
Local cassette/module search
module_search() looks for the query architecture as a sliding window inside database plasmids. The example below uses Tn1548_armA_pCTX_M3.fasta, a Tn1548/armA multidrug-resistance module from plasmid pCTX-M3. pLAST is well suited for finding such functional modules because it compares ordered protein-cluster architectures, not only complete plasmid-to-complete plasmid similarity.
[10]:
cassette = PLAST(data=pl_data, model="mmseqs2_model", logger=logger)
cassette = cassette.load_nt_fasta(Path("examples/Tn1548_armA_pCTX_M3.fasta").read_text())
print("Resistance module length:", cassette.length, "bp")
display(cassette.parsed)
Resistance module length: 13362 bp
| locus_tag | start | end | strand | type | gene | product | translation | |
|---|---|---|---|---|---|---|---|---|
| 0 | Tn1548_armA_pCTX_M3_1 | 1 | 705 | 1 | CDS | MNPFKGRHFQRDIILWAVRWYCKYGISYRELQEMLAERGVNVDHST... | ||
| 1 | Tn1548_armA_pCTX_M3_2 | 980 | 1993 | -1 | CDS | MKTATAPLPPLRSVKVLDQLRERIRYLHYSLPTEQAYVHWVRAFIR... | ||
| 2 | Tn1548_armA_pCTX_M3_3 | 2138 | 2635 | 1 | CDS | MNSESVRIYLVAAMGANRVIGNGPNIPWKIPGEQKIFRRLTEGKVV... | ||
| 3 | Tn1548_armA_pCTX_M3_4 | 3055 | 3834 | 1 | CDS | MTIEISNQLSEVLSVIERHLESTLLAVHLYGSAVDGGLKPYSDIDL... | ||
| 4 | Tn1548_armA_pCTX_M3_5 | 3998 | 4345 | 1 | CDS | MKGWLFLVIAIVGEVIATSALKSSEGFTKLAPSAVVIIGYGIAFYF... | ||
| 5 | Tn1548_armA_pCTX_M3_6 | 4339 | 5178 | 1 | CDS | MVTVFGILNLTEDSFFDESRRLDPAGAVTAAIEMLRVGSDVVDVGP... | ||
| 6 | Tn1548_armA_pCTX_M3_7 | 5583 | 7124 | 1 | CDS | MSLARNATASQSPTQTNGYERHQPDQTLLYQLVEQHYPAFKASLEA... | ||
| 7 | Tn1548_armA_pCTX_M3_8 | 7361 | 8197 | 1 | CDS | MDEQAIKQWHCLVHHGRRGRGFHYSDTAIETALMLKGLFKLPLRAL... | ||
| 8 | Tn1548_armA_pCTX_M3_9 | 8280 | 8372 | 1 | CDS | MASWGSYVFELCRINANQGLTAEMDWNYTS* | ||
| 9 | Tn1548_armA_pCTX_M3_10 | 8523 | 9296 | 1 | CDS | MDKNDVVKKILESKKYENLDSDIVEKVVSISEKKYKLKEVENYSKK... | ||
| 10 | Tn1548_armA_pCTX_M3_11 | 9778 | 9963 | -1 | CDS | MFPNQLTFYFNYRISGDTSGGLQLFGLIGLIYGPIIFALTMVLLRL... | ||
| 11 | Tn1548_armA_pCTX_M3_12 | 10021 | 11196 | 1 | CDS | MNVKAMLADFLTFVTPKSMHKARFSVLLDAVTALAKDACCTVTAIG... | ||
| 12 | Tn1548_armA_pCTX_M3_13 | 11595 | 13070 | 1 | CDS | MSLIIKARNIRLDYAGRDVLDIDELEIHSYDRIGLVGDNGAGKSSL... | ||
| 13 | Tn1548_armA_pCTX_M3_14 | 13126 | 13362 | 1 | CDS | MTIQDIQSLAEAHGLLLTDKMNFNEMGIDFKVVFALDTKGQQWLLR... |
[11]:
cassette = cassette.assign_mmseqs_clusters(use_gpu=False, threads=16)
print("Number of assigned cassette clusters:", len(cassette.vector))
print("Assigned cassette clusters:")
print(cassette.vector)
Number of assigned cassette clusters: 14
Assigned cassette clusters:
['1281006', '747980', '577471', '709541', '1403434', '1328189', '947673', '158253', '1504072', '1890956', '1289284', '854564', '592301', '718297']
[12]:
cassette = cassette.encode()
print("Cassette size:", len(cassette.vector), "protein clusters")
print("Cassette embedding:")
print(cassette.embedding)
Cassette size: 14 protein clusters
Cassette embedding:
[ 0.1647186 -0.08894517 0.11579407 -0.01732701 -0.11079746 -0.01380743
-0.0465313 -0.12210111 -0.12558283 0.18801425 -0.07162375 0.04096967
-0.01991155 -0.04585331 -0.15146409 0.14647077 0.03018233 0.28174305
-0.09788493 0.14704868 0.00766878 -0.07863592 -0.01845689 -0.01584694
0.17130946 -0.30243087 0.07048763 0.0497498 -0.09092891 0.10596228
0.09919997 0.00148555 -0.02341649 0.06497304 0.00272284 0.07149696
0.25530222 0.05554735 -0.01458317 0.17685558 -0.07046853 -0.0938853
0.0216443 -0.02105702 0.13358389 0.37375715 0.09823133 -0.00990677
-0.07348545 -0.11207592 0.01302719 0.24148794 -0.01188857 -0.13840638
-0.18913803 -0.0703034 0.19642618 -0.06978977 -0.03530712 -0.08961868
0.13096692 0.07975519 -0.01628166 0.19070293]
[13]:
if not hasattr(cassette, "module_search"):
print("module_search() is available in the current pLAST development version.")
cassette_results = {}
elif "gbfeatures" not in pl_data.config:
print(
"Local cassette search requires ordered database features. "
)
cassette_results = {}
else:
cassette_results = cassette.module_search(
maxret=15,
window_size=len(cassette.vector),
)
[14]:
if cassette_results:
cassette_df = pd.DataFrame.from_dict(cassette_results, orient="index")
for c in ("pLAST_distance", "gc"):
if c in cassette_df.columns:
cassette_df[c] = pd.to_numeric(cassette_df[c], errors="coerce").round(6)
preferred = [
"pLAST_distance",
"window_start",
"window_end",
"window_size",
"window_wraps",
"target_orf_count",
"module_fallback_vectors",
"length",
"gc",
"taxid",
"organism",
"definition",
"taxonomy",
"rep_type(s)",
"AMR",
"relaxase_type(s)",
"mpf_type",
"orit_type(s)",
"predicted_mobility",
]
cols = [c for c in preferred if c in cassette_df.columns] + [
c for c in cassette_df.columns if c not in preferred
]
display(cassette_df[cols])
| pLAST_distance | window_start | window_end | window_size | window_wraps | target_orf_count | module_fallback_vectors | length | gc | taxid | ... | rep_type(s) | AMR | relaxase_type(s) | mpf_type | orit_type(s) | predicted_mobility | accession | database | topology | primary_cluster_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DDBJ_AP024100.1 | 1.0 | 1562 | 1575 | 14 | False | 1737 | 1737 | 2131108 | 0.668237 | NaN | ... | - | - | MOBP | - | - | mobilizable | DDBJ_AP024100.1,PLSDB_AP024100.1 | DDBJ,PLDSB | circular | AG445 |
| DDBJ_AP024102.1 | 1.0 | 1559 | 1572 | 14 | False | 1687 | 1687 | 2094349 | 0.668026 | NaN | ... | - | - | MOBP | - | - | mobilizable | DDBJ_AP024102.1,PLSDB_AP024102.1 | DDBJ,PLDSB | circular | AG445 |
| DDBJ_AP026896.1 | 1.0 | 3689 | 3702 | 14 | False | 4529 | 4529 | 4944632 | 0.608921 | 648.0 | ... | - | - | - | - | - | non-mobilizable | DDBJ_AP026896.1,PLSDB_NZ_AP026896.1,RefSeq_NZ_... | DDBJ,PLDSB,RefSeq | circular | AC542 |
| DDBJ_AP029011.1 | 1.0 | 1558 | 1571 | 14 | False | 1641 | 1641 | 2060108 | 0.669470 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | DDBJ_AP029011.1 | DDBJ | circular | AG445 |
| DDBJ_AP029015.1 | 1.0 | 1557 | 11 | 14 | True | 1559 | 1559 | 1988610 | 0.664401 | NaN | ... | - | A201A,ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,... | - | - | - | non-mobilizable | DDBJ_AP029015.1 | DDBJ | circular | AG445 |
| GenBank_CP015960.1 | 1.0 | 1558 | 1571 | 14 | False | 1641 | 1641 | 1913088 | 0.624831 | 75105.0 | ... | - | - | - | - | - | non-mobilizable | GenBank_CP015960.1,PLSDB_NZ_CP015960.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA400 |
| COMPASS_CP021765.1 | 1.0 | 1556 | 1569 | 14 | False | 1827 | 1827 | 2094523 | 0.666784 | NaN | ... | - | A201A,ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,... | MOBP | - | - | mobilizable | COMPASS_CP021765.1 | COMPASS | circular | AG445 |
| GenBank_CP022781.1 | 1.0 | 1555 | 1568 | 14 | False | 1597 | 1597 | 2134808 | 0.668189 | 305.0 | ... | - | - | MOBP | - | - | mobilizable | GenBank_CP022781.1,PLSDB_CP022781.1 | GenBank,PLDSB | circular | AG445 |
| GenBank_CP049317.1 | 1.0 | 1561 | 1574 | 14 | False | 1832 | 1832 | 1990521 | 0.596952 | 2705547.0 | ... | - | - | MOBP | - | - | mobilizable | GenBank_CP049317.1,PLSDB_NZ_CP049317.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AD868 |
| GenBank_CP049318.1 | 1.0 | 1558 | 1571 | 14 | False | 1641 | 1641 | 1831039 | 0.599465 | 2705547.0 | ... | - | - | MOBP | - | - | mobilizable | GenBank_CP049318.1,PLSDB_NZ_CP049318.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AC301 |
| PLSDB_CP052071.1 | 1.0 | 1560 | 1573 | 14 | False | 1735 | 1735 | 2074832 | 0.669338 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | PLSDB_CP052071.1 | PLDSB | circular | AG445 |
| PLSDB_CP052075.1 | 1.0 | 1560 | 1573 | 14 | False | 1735 | 1735 | 2074757 | 0.669341 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | PLSDB_CP052075.1 | PLDSB | circular | AG445 |
| PLSDB_CP052077.1 | 1.0 | 1559 | 1572 | 14 | False | 1687 | 1687 | 1981426 | 0.671087 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | PLSDB_CP052077.1 | PLDSB | circular | AG445 |
| PLSDB_CP052079.1 | 1.0 | 1557 | 1570 | 14 | False | 1685 | 1685 | 1982075 | 0.671096 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | PLSDB_CP052079.1 | PLDSB | circular | AG445 |
| PLSDB_CP052081.1 | 1.0 | 1557 | 1570 | 14 | False | 1685 | 1685 | 1981451 | 0.671083 | NaN | ... | - | ABK,ACR,AMK,AMP,AMX,APR,AST,ATM,AZD,AZM,BCT,BU... | MOBP | - | - | mobilizable | PLSDB_CP052081.1 | PLDSB | circular | AG445 |
15 rows × 23 columns
Analyze sequence using eggNOG model
Initialize PLAST object - load config, choose model and add logger
[15]:
plast = PLAST(data=pl_data, model="eggnog_model", logger=logger)
Load example plasmid sequence and GenBank annotation from .gb file
[16]:
plast = plast.load_gbff(Path("examples/NZ_AP018444.1.gb"))
print("Plasmid of langth", plast.length, "has the following annotation:")
display(plast.parsed)
Plasmid of langth 181607 has the following annotation:
| start | end | strand | partial | type | coordinates | locus_tag | old_locus_tag | inference | note | ... | product | protein_id | translation | GO_function | pseudo | gene | EC_number | GO_process | GO_component | gene_synonym | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 598 | 807 | 1 | 0 | CDS | 598..807 | BAZ_RS27670 | NaN | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_003171438.1 | MYIIINFEPLSPVMNDIAIKLAMVLFIPLFLALIVKVILMKFMKES... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 2 | 1127 | 1765 | -1 | 0 | CDS | complement(1127..1765) | BAZ_RS27675 | BAZ_pXO1_00003 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | nuclease-related domain-containing protein | WP_000453400.1 | MEVLIFELILIAVLIPLNSVVKKHVPKWKGKAGEKLVKRMLSKLDP... | GO:0003677 - DNA binding [Evidence IEA];GO:000... | NaN | NaN | NaN | NaN | NaN | NaN |
| 3 | 1782 | 2165 | -1 | 0 | CDS | complement(1782..2165) | BAZ_RS27680 | BAZ_pXO1_00004 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_003159741.1 | MNRNREYIALRNSISIGWLLTCIVIGLSIYFSSVVYLLIGCFILSL... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 4 | 2291 | 2875 | 1 | 0 | CDS | 2291..2875 | BAZ_RS27685 | BAZ_pXO1_00005 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_000916417.1 | MLKLVVNNTGTEPEGDSAFSNYFTCKDCVYYLSKSDSCSLQLAADS... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 5 | 2895 | 3473 | 1 | 0 | CDS | 2895..3473 | BAZ_RS27690 | BAZ_pXO1_00006 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_002194483.1 | MLEHTILFSLVQLVPLIVSTGIIYILLELTDTEWKTWFSYEGIFAI... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 161 | 175000 | 175287 | -1 | 0 | CDS | complement(175000..175287) | BAZ_RS28520 | BAZ_pXO1_00191 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_000084556.1 | MSQVPGFLKFVLAKERRYVYLAVAEKKNKRILTHIVYRFGPLEKAL... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 162 | 175364 | 175564 | -1 | 0 | CDS | complement(175364..175564) | BAZ_RS28525 | BAZ_pXO1_00192 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_000344165.1 | MDENKRNMLLSFIISILFIFTSLLPFSNNEYVYVISKIGAAAGVIN... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 163 | 175616 | 176260 | -1 | 0 | CDS | complement(175616..176260) | BAZ_RS28530 | BAZ_pXO1_00193 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | thermonuclease family protein | WP_000708136.1 | MKIWIKAICITSFVIQMSACSSSAQTKNDSRPAQAVQNGIQQHVEG... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 164 | 176689 | 179352 | -1 | 0 | CDS | complement(176689..179352) | BAZ_RS28540 | BAZ_pXO1_00195 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | type IA DNA topoisomerase | WP_000520727.1 | MGKTLFIAEKPKVANEIMKSPRFRHSQKYIGSKPYYGYYENDHYIV... | GO:0003677 - DNA binding [Evidence IEA];GO:000... | NaN | NaN | 5.6.2.1 | GO:0006265 - DNA topological change [EvidenceIEA] | NaN | NaN |
| 0 | 181589 | 181607 | 1 | 0 | CDS | join(181589..181607,1..410) | BAZ_RS27665 | BAZ_pXO1_00001 | COORDINATES: similar to AAsequence:RefSeq:WP_0... | Derived by automated computational analysis us... | ... | hypothetical protein | WP_000914414.1 | MLKKLSVFLIGTLLLFGLAACDSIKSVASDVTVGKVIEEFKAAGLE... | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
136 rows × 22 columns
Assign cluster identifiers to the plasmid proteins
[17]:
plast = plast.assign_eggnog_annot(processes=16)
print("Number of assigned clusters:", len(plast.vector))
print("Assigned clusters:")
print(plast.vector)
Number of assigned clusters: 136
Assigned clusters:
[nan, '31K0D', nan, '30DG3', nan, '32907', nan, nan, 'COG3344', 'COG0553', nan, 'COG0827', nan, '2ZFG1', nan, '2Z9QM', '2Z9QM', '30AUC', '32EU5', '33QRF', 'COG4973', 'COG0675', 'COG2250', 'COG3344', 'COG1708', nan, nan, nan, 'COG3950', 'COG2865', '2ZWMK', 'COG0539', '30VTJ', 'COG1309.used_alg.fa', nan, 'COG4823', 'COG0454', 'COG3385', 'COG3385', nan, 'COG1476', '33G6F', '308XQ', 'COG3505', nan, '30DRN', '349HH', '2ZM2H', '30JG6', nan, '33PUD', '32AWE', 'COG4963', nan, nan, 'COG2866', nan, nan, nan, 'COG3745', 'COG4963', 'COG4962', 'COG4965', '3294H', '3294H', '30JM3', 'COG4072', 'COG4960', nan, 'COG5464', '30EMT', nan, '30D9P', '30EJP', '336S4', 'COG3451', nan, nan, '33KVR', '33F95', 'COG1266', 'COG2311', '307WB', 'COG5386', nan, '345N2', 'COG2866', 'COG0671', nan, 'COG1210', '2Z8KQ', '33354', nan, nan, nan, '2ZJNR', 'COG3711', nan, nan, nan, 'COG4644', 'COG1961', '2ZAZ1', nan, '2ZA3G', nan, nan, '32ZBI', 'COG0640', '30AH4', nan, nan, 'COG4973', nan, '33Y12', nan, nan, '33ZVC', '32U5N', '332Y6', 'COG3443', 'COG2357', 'COG4973', 'COG3410', nan, '319NK', '33JGE', nan, nan, 'COG1923', 'COG0640', '30EJD', nan, 'COG1525', 'COG0550', '331IF']
Pass data through pLAST model and receive embeddings
[18]:
plast = plast.encode()
print("Plasmid embedding:")
print(plast.embedding)
Plasmid embedding:
[-0.01628306 -0.01295302 -0.2643657 0.12566526 0.0786413 0.07343284
-0.10592642 0.05117363 -0.15185057 -0.0917705 -0.1749777 -0.04378572
0.04284062 -0.01780606 0.10390937 -0.03507463 0.12917799 0.22014977
-0.09011716 -0.26449004 0.1578369 0.23005912 -0.12079659 -0.16868664
0.08776087 0.14757568 0.08944128 0.03609036 0.02073304 0.06742117
-0.03507506 0.04188536 -0.14262943 -0.0101757 0.07670277 -0.05125343
0.135285 -0.28171447 -0.05007815 0.02647007 -0.03667818 0.26045159
-0.25092968 -0.12784135 0.02631533 0.0357714 0.06894967 0.01984254
-0.10920736 -0.14962453 -0.1685642 0.05777118 -0.0179081 0.03834559
-0.03849267 0.1128887 0.17922303 -0.08803956 -0.075794 0.10746881
-0.01048282 0.11445606 0.12085333 0.21659563]
Find similar plasmids in the database
[19]:
results = plast.get_most_similar(maxret=15)
[20]:
df = pd.DataFrame.from_dict(results, orient="index")
for c in ("pLAST_distance", "gc"):
if c in df.columns:
df[c] = pd.to_numeric(df[c], errors="coerce").round(6)
preferred = [
"pLAST_distance",
"length",
"gc",
"taxid",
"organism",
"definition",
"taxonomy",
"rep_type(s)",
"AMR",
"relaxase_type(s)",
"mpf_type",
"orit_type(s)",
"predicted_mobility",
]
cols = [c for c in preferred if c in df.columns] + [
c for c in df.columns if c not in preferred
]
display(df[cols])
| pLAST_distance | length | gc | taxid | organism | definition | taxonomy | rep_type(s) | AMR | relaxase_type(s) | mpf_type | orit_type(s) | predicted_mobility | accession | database | topology | primary_cluster_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| RefSeq_NZ_CP096828.1 | 0.972781 | 181633 | 0.325293 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain CVCC40205 plasmid un... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP096828.1,PLSDB_NZ_CP096828.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP096825.1 | 0.972509 | 181710 | 0.325277 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain CVCC40202 plasmid un... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP096825.1,PLSDB_NZ_CP096825.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP029324.1 | 0.972365 | 181932 | 0.325391 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain 17OD930 plasmid pXO1... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP029324.1,PLSDB_NZ_CP029324.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP076223.1 | 0.972279 | 181467 | 0.325359 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain A159 plasmid pXO1, c... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP076223.1,PLSDB_NZ_CP076223.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP076171.1 | 0.972061 | 181758 | 0.325312 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain A168 plasmid pXO1, c... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP076165.1,GenBank_CP076171.1,PLSDB_NZ... | GenBank,GenBank,PLDSB,RefSeq,RefSeq | circular | AA800 |
| RefSeq_NZ_CP076165.1 | 0.972061 | 181758 | 0.325312 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain A168 plasmid pXO1, c... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP076165.1,GenBank_CP076171.1,PLSDB_NZ... | GenBank,GenBank,PLDSB,RefSeq,RefSeq | circular | AA800 |
| RefSeq_NZ_CP009340.1 | 0.972014 | 181369 | 0.325149 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain Ohio ACB plasmid 1, ... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | COMPASS_NZ_CP009340.1,GenBank_CP009340.1,PLSDB... | COMPASS,GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP009324.1 | 0.971804 | 181754 | 0.325319 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain PAK-1 plasmid 1, com... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | COMPASS_NZ_CP009324.1,GenBank_CP009324.1,PLSDB... | COMPASS,GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP010814.1 | 0.971517 | 181682 | 0.325325 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain Pollino plasmid pXO1 | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP010814.1,RefSeq_NZ_CP010814.1 | GenBank,RefSeq | circular | AA800 |
| RefSeq_NZ_CP081176.1 | 0.971426 | 181677 | 0.325303 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain P04210076 plasmid pX... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP081176.1,PLSDB_NZ_CP081176.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP076211.1 | 0.971414 | 181708 | 0.325176 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain A1074 plasmid pXO1, ... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP076211.1,PLSDB_NZ_CP076211.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP076214.1 | 0.971295 | 181743 | 0.325350 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain A0777 plasmid pXO1, ... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP076214.1,PLSDB_NZ_CP076214.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP047132.1 | 0.971293 | 181933 | 0.325389 | 1213182.0 | Bacillus anthracis | Bacillus anthracis str. BF1 plasmid pXO1, comp... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP047132.1,PLSDB_NZ_CP047132.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP116890.1 | 0.971292 | 181782 | 0.325313 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain AN17-384_2 plasmid p... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP116890.1,PLSDB_NZ_CP116890.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |
| RefSeq_NZ_CP110280.1 | 0.971256 | 181633 | 0.325293 | 1392.0 | Bacillus anthracis | Bacillus anthracis strain 7702 plasmid pXO1, c... | Bacteria;Bacillota;Bacilli;Caryophanales;Bacil... | rc125 | - | MOBP | MPF_T | - | conjugative | GenBank_CP110280.1,PLSDB_NZ_CP110280.1,RefSeq_... | GenBank,PLDSB,RefSeq | circular | AA800 |