Package: chAMReDb
CharmeDb(pronounced 'charmed'/tʃɑː(r)md/)Previously known as Project(Abandoned for obvious trademark issues and the fact that the joke may be lost on non-Brits)ContributorsAdam WitneyAlex ManueleInês MendesThanh Le VietTrestan PillonelVarun ShamannaIntroductionThis project originated from the dilemma a scientist faces when choosing a database that stores antimicrobial resistance determinants. Multiple databases exist with comparative strengths and weaknesses. This project builds on the concepts of thehaAMRonizationproject aiming to aggeregate and combine the information contained within the metadata associated with each project. The problem is exacerbated by the fact that the equivalent antimicrobial resistance genes (ARGs) can be named differently in each database.The hypothesis for the project is as follows:given a match in one databasefind the matches in other databasesaggregate the combined descriptive information pertaining to antimicrobial resistance contained in the union of the metadatareport this to user for them to make intelligent informed choicesMethodologyDownload sequences and associated metadata of ARGs from 3 databasesCARD(Manuscript)NCBI AMR Reference Gene CatalogResfinder 4(Manuscipt)Details can be found in theappendicesParse the data toextract the protein sequences and write into fasta format with the gene identifiers as the record ids.extract the associated metadata and convert to a consistentJSONformatDetails can be found in theappendicesFind best matches of each gene from one source database against the other two target databasesWhere a reciprocal best hit (RBH) exists, report this.Details can be found in theappendices.A summary of the results can be foundhereIf a RBH does not exist, report the best match as long as thresholds for coverage and indentity are met.
A summary of the results can be foundhereFor this purpose theMMseqs2search tool was used that in its most sensitive mode is 100x faster than blastp and almost as sensitive. In acomparative manuscriptdemonstrated that even in the worst cases MMseqs2 would not miss more than 10% of the RBH produced by blastp. MMseqs2 also contains a convenient wrapper to perform the all-by-all search necessary to find RBHs.From the outputs of the MMseqs2 searches the RBHs or best matches of each gene from one database against the other two databases can be parsed to produce aDirected Graph. This network was constructed using thenetworkxpython package.Details of the method can be foundhereIn this graphthe nodes represent a protein from one databaseNode attributes contain the phenotype from the JSON metadatathe edges link nodes and represent the matches and attributes includetype, either RBH or OWH (one way hit)coverage, (alignment length/query length)identity, (percent identity of match)See the image below for a pictoral example using made up dataAssessing the graphIn order to look at the 19132 matches within the database and assess the effectiveness of the methodology the database names for matches were compared with theNormalized Levensthein algorithm.
Before calculating the name similarity between the source and target of a match the name was cleaned using the following stepsRemoving species names from database names (exclusively in the CARD database) e.gStaphylococcus aureus mupB conferring resistance to mupirocinCoversion to lower caseRemoving the bla prefixRemoving parenthesesRemoving hyphensN.B blaPAO-N and blaPDC matches are the source of 562 low name similarities so were skippedThe resulting data is plotted below showing
A: distribution of levenshtein smilarities between the database names of the best matches
B: distribution sequence identities for the best matches
C: plot of the levenshtein smilarity versus the sequence identity for each matchThe red line shows the correlation including 95% confidence intervals.Based on this regression the expected name similarity for a sequence identity of 0.95 can be calculated (0.69)linear_fit = np.polyfit(
    distance_dataframe['sequence_identity'],
    distance_dataframe['name_similarity'],
    1
)
np.polyval(linear_fit, 0.95)
0.6898250936869554To examine data matches where the sequence identity is > 0.95BUTthe name similarity is less than the predicted 0.69 was created and explored, aCSV filewas created.In this data, many of the differences in the names are due to matches with the same gene family but different alleles e.gblaADC-125in thencbidatabase andblaADC-25in theresfinder 4database.Therefore data calculating name smilarities ignoring alleles was created.A second series of plots explores this data by plotting the distributions of the name smilarities.
In the top panel the violin plots show the distribution of the name similarity differences for those matches where the sequence identity is greater than 0.95. In A: this name similarities are based on complete cleaned locus names and in B: they are based on names where the alleles are ignored.
The lower panel of the figure contains violin plots showing the distribution of thedifferencebetween theobserved name similarityand thatpredictedby a linear regression model fitting name smilarity to sequence identity. The right hand 2 plots are data where the name simialrities were calculated excluding alleles.The data was filtered for those matches where the sequence identity is > 0.95 but the name similarity is less than the predicted value of 0.86 based on the linear regression model.To examine these anomalous results aCSV sheetwas created.Exploring this data some of these are clearly related genes but the databases have different nomneclature e.gvanAincardandVanHAXinresfinder 4.0orcatA15inncbiorClostridium butyricum catBincardN.BThe species names are removed in the name cleaning function.In other cases the names are completely different, e.ggimAincardandmgtinncbibut the sequences are 99.5% identical.gimAis a macrolide glycosyltransferase and may confer resistance to spiramycin.mgtin thencbidatabase stands formacrolide-inactivating glycosyltransferase. Clearly the genes are likely to have the same function but have been assigned different names in the two databases.Querying the graphusage: chamredb query
  [-h]
  [-d {card,ncbi,resfinder}]
  [-ct COVERAGE_THRESHOLD] [-it IDENTITY_THRESHOLD]
  (-i ID | -f ID_FILE | -j HAMRONIZATION_JSON_FILE)
  [-o OUTFILE_PATH]The graph can be queried in one of 3 ways1. Querying an individualRequires specifying the identifier-iand database-dchamredb query -d ncbi -i WP_012695489.1Alternatively the gene name can be usedchamredb query -d ncbi -i qnrB2The output reports the matches and metadata from the other databasesAnother example where the matches are one way hits not RBHschamredb query -d resfinder -i "aac(3)-IIIb"In these outputs ↔ means a RBH, and ➡ a search hit2. Providing a list of identifiers from a single databaseRequires specifying the database-d, the text file containing the ids-f, and a path for the tsv output file-ochamredb query -d card -f docs/data/card_ids.txt  -o docs/data/card_ids.tsvThis will produce aTSV filecontaining the matches and associated metadata with one row per id in the text file3. Use hAMRonization summary outputUse thehAMRonization softareto convert the outputs from antimicrobial resistance gene detection tools into a unified format. Concatenate and summarize AMR detection reports into a single summary JSON file using thehamronize summarizecommand from this package. The JSON output from this step can be used to query ChamreDb.Use-jto specify the json summary file and-othe path for the TSV outputPlease NoteOnly outputs using data derived from AMR detection tools that have searched either theCARD,NCBIorResfinder 4databases can be used.chamredb query -j docs/data/hamronize_summary.json -o docs/data/hamronize_summary.tsvThis will produce aTSV filecontaining the matches and associated metadata with one row per id in the text file