diff --git a/docs/amr.md b/docs/amr.md index a9e563d..c3da738 100644 --- a/docs/amr.md +++ b/docs/amr.md @@ -16,7 +16,7 @@ of the metagenome. First, install the software. Run: ``` -mamba create -n amrfinder -y ncbi-amrfinderplus megahit prodigal csvtk +mamba create -n amrfinder -y ncbi-amrfinderplus megahit prodigal csvtk matplotlib seaborn pandas conda activate amrfinder ``` @@ -102,3 +102,11 @@ reads to it to get the abundance. This is because assembly collapses the abundance of the output contigs, and you have to recover it through other means. + +Now we can plot the abundances of the AMRs we found: +``` +../scripts/plot_amr.py CD136.amrfinder.tsv -o CD136.amrfinder.pdf +``` +![CD136 amrfinder](https://github.com/AnneliektH/2024-pig-paradigm-workshop/blob/main/docs/images/CD136.amrfinder.png) + + diff --git a/docs/images/CD136.amrfinder.png b/docs/images/CD136.amrfinder.png new file mode 100644 index 0000000..6880371 Binary files /dev/null and b/docs/images/CD136.amrfinder.png differ diff --git a/scripts/plot_amr.py b/scripts/plot_amr.py new file mode 100644 index 0000000..9f8e67d --- /dev/null +++ b/scripts/plot_amr.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python +import pandas as pd +import matplotlib.pyplot as plt +import seaborn as sns +import sys +import argparse + + +def main(): + p = argparse.ArgumentParser() + p.add_argument('df') + p.add_argument('-o', '--output-figure', required=True) + args = p.parse_args() + + df = pd.read_csv(args.df, sep = '\t') + df_all = df.Class.value_counts().to_frame().reset_index() + figure = sns.barplot(data=df_all, x="count", y="Class", hue="Class", legend=False) + figure.figure.set_size_inches(15,5) + figure.figure.savefig(args.output_figure) + + + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file