Skip to content

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AB_SA — Source attribution based on accessory genes

DOI

AB_SA (Accessory-Based Source Attribution) is an R-based approach for attributing bacterial strains of unknown origin to potential sources using source-associated accessory genes.

AB_SA combines pangenome analysis and gene enrichment with multinomial logistic regression. Source-associated genes identified from strains of known origin are used to train and evaluate a classification model. The fitted model can then estimate source-membership probabilities for strains of unknown origin, such as strains isolated from human cases or environmental samples.

Overview

The AB_SA method consists of four main steps:

  1. Identify accessory genes associated with each potential source.
  2. Select source-associated genes and prepare the input for multinomial logistic regression.
  3. Evaluate model performance using repeated train/test splits and select an appropriate model.
  4. Fit the selected model to the complete reference dataset and estimate source-membership probabilities for strains of unknown origin.

The repository contains the R functions implementing the method as well as case studies illustrating its application to published datasets.

Input data

AB_SA requires two main types of input: (i) a gene presence/absence matrix obtained from pangenome analysis and (ii) a list of accessory genes associated with each potential source.

Pangenome

AB_SA uses a gene presence/absence matrix to determine the accessory gene profiles of the strains. The pangenome should therefore be constructed using all strains included in the analysis, including reference strains from known sources and strains of unknown origin to be attributed. Additional strains may also be included when relevant to better characterize the genomic diversity of the bacterial population. The method was originally developed using the .Rtab output produced by Roary ; equivalent outputs generated by Panaroo should also be compatible. The pangenome of the strains included in the analysis should first be determined. This includes both the reference strains of known origin used to build the source attribution model and the strains of unknown origin to be attributed.

Identification of source-associated genes

Genes associated with each source are identified using Scoary. Scoary uses the gene_presence_absence.csv file generated by Roary together with a trait file indicating the source associated with each reference strain.

For example, the following Scoary command was used in the original AB_SA case study:

scoary -g ./DE_pangenome_default/gene_presence_absence.csv \
       -t ./DE_scoary/DE_scoary_trait.csv \
       -p 1E-2 -c I --no_pairwise --collapse

The --no_pairwise option is used to perform the gene enrichment analysis without pairwise comparisons. The --collapse option groups genes sharing identical presence/absence patterns across strains. AB_SA uses the first gene reported for each collapsed group.

In the original implementation, genes were ranked according to their association p-values, with a threshold of 0.01. This threshold should be adapted to the dataset and should not be considered a default recommendation. Depending on the number of strains and the genomic diversity of the dataset, it may result in a very large number of significant gene–source associations, which may not be suitable for subsequent multinomial logistic regression. The maximum number of source-associated genes subsequently included in the attribution model is controlled through the maxGenes argument of CreateInputMNL.

Running AB_SA

Preparing input files

The CreateInputMNL() function prepares the input files required for model training and source prediction.

The user provides:

  • the Scoary output file containing the source-associated genes;
  • the gene presence/absence .Rtab file;
  • the maximum number of source-associated genes to retain per source (maxGenes).

For each source, genes are ranked according to their association p-values, and up to maxGenes genes are retained as predictors. Testing different values of maxGenes allows the user to explore the trade-off between model complexity and predictive performance.

For example:

CreateInputMNL(
  traitfile = "DE_scoary_trait.csv",
  roary_Rtab = "gene_presence_absence.Rtab",
  maxGenes = 10
)

The function produces two files:

  • mnl_input_0.csv, containing the source information and gene presence/absence profiles used to train and fit the multinomial logistic model;
  • predict_sporadic.csv, containing the gene presence/absence profiles of strains of unknown origin for which source-membership probabilities will subsequently be estimated.

The value of maxGenes should be explored rather than fixed a priori. Increasing maxGenes provides additional predictors but also increases model complexity and may lead to overfitting, particularly when the number of reference strains is limited.

Training and testing the multinomial logistic model

The predictive performance of the multinomial logistic model is assessed using repeated random train/test splits. At each iteration, a proportion of the reference strains is randomly assigned to the training set and the remaining strains are used as an independent test set. Sampling is stratified by source to preserve source representation in the training set.

The proportion of strains used for training is defined by percent_cross (default: 0.70), and the procedure is repeated nboot times (default: 100).

testedMNL <- MNLTrainTest(
  "mnl_input_0.csv",
  percent_cross = 0.70,
  nboot = 100
)

Model performance is evaluated on the test sets using overall accuracy. Balanced accuracy is also reported for each source and can be explored to assess whether predictive performance is consistent across sources, particularly when source groups are unbalanced.

The main outputs can be explored as follows:

# Quantiles of overall accuracy across repeated train/test splits
testedMNL[[1]]

# Median balanced accuracy for each source
testedMNL[[2]]

# Distribution of overall accuracy
testedMNL[[3]]

Testing different values of maxGenes allows the predictive performance of models of increasing complexity to be compared. This information can subsequently be combined with model-fit criteria, such as AIC, to select an appropriate set of source-associated genes.

Fitting the multinomial logistic model

Once an appropriate value of maxGenes has been selected based on predictive performance, balanced accuracies across sources and model parsimony, the final multinomial logistic model is fitted using the complete reference dataset with MNLFit():

final.trained <- MNLFit("mnl_input_0.csv")

The fitted model can then be used to predict the source-membership probabilities of strains of unknown origin.

The AIC of the fitted model can also be retrieved:

final.trained$AIC

AIC can be useful when comparing models with different numbers of predictors, with lower values favouring more parsimonious models for a comparable fit.

Predicting the source of strains of unknown origin

Once the final model has been fitted, MNLPredict() can be used to estimate the source-membership probabilities of strains of unknown origin:

predict.unknown <- MNLPredict(
  "predict_sporadic.csv",
  final.trained
)

For each strain, the function returns a probability of membership for each source included in the model. These probabilities can be used to identify the most likely source and to assess the strength of the attribution.

The results can be exported for further analysis:

write.table(
  predict.unknown,
  file = "predicted_sources.csv",
  sep = ";"
)

Source-membership probabilities can also be visualized to explore attribution patterns across strains.

Case studies

Applications of AB_SA to specific datasets are provided in the case_studies directory.

Salmonella Typhimurium environment

The salmonella_environment case study corresponds to the first application of AB_SA and to the analysis presented in the publication describing the method.

AB_SA was applied to Salmonella enterica Typhimurium and its monophasic variant to predict the animal source of strains isolated from the environment. The case study illustrates the complete AB_SA workflow, from the identification and selection of source-associated accessory genes to model evaluation, fitting and source attribution.

Clostridium perfringens reservoir markers

The clostridium_perfringens case study illustrates a second application of AB_SA, focused on the identification of reservoir-associated genomic markers in Clostridium perfringens.

Accessory genes associated with cattle, pig and poultry reservoirs are first identified through pangenome-wide enrichment analysis. AB_SA is then used to select a reduced set of informative markers and evaluate their ability to discriminate strains according to their reservoir of origin. This case study illustrates how the AB_SA framework can be used not only for source attribution of strains of unknown origin, but also to identify and evaluate genomic signatures associated with specific reservoirs.

Citation

If you use AB_SA in your work, please cite the publication describing the method:

Guillier L, Gourmelon M, Lozach S, Cadel-Six S, Vignaud M-L, Munck NSM, Hald T, Palma F. (2020). AB_SA: Accessory genes-Based Source Attribution – tracing the source of Salmonella enterica Typhimurium environmental strains. Microbial Genomics, 6(7), 000366.

DOI: 10.1099/mgen.0.000366

Software

AB_SA releases are archived on Zenodo:

DOI

Licence

AB_SA is freely available under the GPLv3 licence.

About

Accessory Based Source Attribution

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages