Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 107 additions & 100 deletions tutorials/Acinetobacter_baumannii/amrfinder_result.tsv

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions tutorials/Acinetobacter_baumannii/commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

pangbank search-pangenomes --collection GTDB_refseq --taxon "s__Acinetobacter baumannii" --download --release-version 2.0.0

ppanggolin info -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --content

ppanggolin fasta -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 \
-f --compress --prot_families all -o families_faa_output

amrfinder -p families_faa_output/all_protein_families.faa.gz --plus --threads 8 -o amrfinder_result.tsv

ppanggolin rgp_cluster -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 \
--grr_metric max_grr -o rgp_cluster -f --add_metadata

ppanggolin write_pangenome --spots --regions --families_tsv --partitions \
--regions_families --output ppanggolin_output \
--modules --spot_modules \
-p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 -f

sed -i 's/\%/Prct/g' amrfinder_result.tsv
sed -i '1s/ /_/g' amrfinder_result.tsv
sed -i '1s/\<Protein id\>/families/' amrfinder_result.tsv

ppanggolin metadata --pangenome ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --metadata amrfinder_result.tsv --source amrfinder --assign families

ppanggolin write_genomes -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --genomes GCF_000069245.1 --gff --add_metadata -o ppanggolin_genome_output
51 changes: 36 additions & 15 deletions tutorials/Acinetobacter_baumannii/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "f2325173",
"metadata": {},
"source": [
"# PanGBank Tutorial: Analyzing AMR Genes in Pangenomes\n",
"# PanGBank Tutorial: Analyzing AMR Genes in *Acinetobacter baumannii* pangenomes\n",
"\n",
"This tutorial demonstrates how to:\n",
"1. Retrieve pangenomes from [PanGBank](https://pangbank.genoscope.cns.fr/)\n",
Expand Down Expand Up @@ -58,9 +58,9 @@
"\n",
"#### Commands\n",
"```bash\n",
"pangbank search-pangenomes --collection GTDB_refseq --taxon \"s__Acinetobacter baumannii\" --download --release-version 1.0.0\n",
"pangbank search-pangenomes --collection GTDB_refseq --taxon \"s__Acinetobacter baumannii\" --download --release-version 2.0.0\n",
"\n",
"ppanggolin info -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id29.h5 --content\n",
"ppanggolin info -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --content\n",
"```"
]
},
Expand All @@ -76,7 +76,7 @@
"#### Commands\n",
"\n",
"```bash\n",
"ppanggolin fasta -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id29.h5 \\\n",
"ppanggolin fasta -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 \\\n",
" -f --compress --prot_families all -o families_faa_output\n",
"```"
]
Expand Down Expand Up @@ -109,7 +109,7 @@
"#### Commands\n",
"\n",
"```bash\n",
"ppanggolin rgp_cluster -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id29.h5 \\\n",
"ppanggolin rgp_cluster -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 \\\n",
" --grr_metric max_grr -o rgp_cluster -f --add_metadata\n",
"```\n"
]
Expand All @@ -129,7 +129,7 @@
"ppanggolin write_pangenome --spots --regions --families_tsv --partitions \\\n",
" --regions_families --output ppanggolin_output \\\n",
" --modules --spot_modules \\\n",
" -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id29.h5 -f \n",
" -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 -f \n",
"```"
]
},
Expand Down Expand Up @@ -509,6 +509,26 @@
"fig.show()"
]
},
{
"cell_type": "markdown",
"id": "5c877ce1-54f9-4f61-9b4a-a393f60b6bea",
"metadata": {},
"source": [
"#### Annotate the pangenome graph with AMR metadata\n",
"\n",
"```bash\n",
"sed -i 's/\\%/Prct/g' amrfinder_result.tsv\n",
"sed -i '1s/ /_/g' amrfinder_result.tsv\n",
"sed -i '1s/\\<Protein id\\>/families/' amrfinder_result.tsv\n",
"ppanggolin metadata --pangenome ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --metadata amrfinder_result.tsv --source amrfinder --assign families\n",
"```\n",
"\n",
"#### Extract the annotated gff for `GCF_000069245.1`\n",
"```bash\n",
"ppanggolin write_genomes -p ./pangbank/GTDB_refseq_s__Acinetobacter_baumannii_id10832.h5 --genomes GCF_000069245.1 --gff --add_metadata -o ppanggolin_genome_output\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -521,7 +541,7 @@
"\n",
"def find_spot(spot_name: str, gff):\n",
" for i in gff.all_records:\n",
" if \"spot\" in i.attrs and \"15\" in i.attrs[\"spot\"]:\n",
" if \"spot\" in i.attrs and \"47\" in i.attrs[\"spot\"]:\n",
" return i\n",
"\n",
"def extract_features(features, partition, with_amr):\n",
Expand All @@ -538,7 +558,7 @@
" \n",
"def show_spot(path, spot, label = \"\"):\n",
" gff = Gff(\"ppanggolin_genome_output/gff/GCF_000069245.1.gff\")\n",
" spot_regions = find_spot(\"15\", gff)\n",
" spot_regions = find_spot(\"47\", gff)\n",
" seq_id = spot_regions.seqid\n",
" gff = Gff(\"ppanggolin_genome_output/gff/GCF_000069245.1.gff\", target_seqid=seq_id)\n",
" features = gff.extract_features(feature_type=\"CDS\", target_range=((spot_regions.start-1000, spot_regions.end+1000)))\n",
Expand Down Expand Up @@ -567,7 +587,7 @@
" gv = GenomeViz()\n",
" \n",
" gv.set_scale_bar(ymargin=0.5)\n",
" target_ranges = ((spot_regions.start-1000, spot_regions.end+1000))\n",
" target_ranges = ((spot_regions.start-2500, spot_regions.end+500))\n",
" track = gv.add_feature_track(name=gff.name, segments=target_ranges)\n",
"\n",
" data = []\n",
Expand Down Expand Up @@ -617,7 +637,7 @@
"metadata": {},
"outputs": [],
"source": [
"fig, df_amr, df_no_amr = show_spot(\"ppanggolin_genome_output/gff/GCF_000069245.1.gff\", \"15\")"
"fig, df_amr, df_no_amr = show_spot(\"ppanggolin_genome_output/gff/GCF_000069245.1.gff\", \"47\")"
]
},
{
Expand Down Expand Up @@ -727,13 +747,13 @@
"from pyvis.network import Network\n",
"\n",
"def amr_connected_components(graph):\n",
" ccs = [c for c in nx.connected_components(graph) if any(graph.nodes[node].get(\"has_family_with_amrfinder\") for node in c)]\n",
" ccs = [c for c in nx.connected_components(graph)]\n",
" return {\n",
" graph.nodes[list(cc)[0]][\"max_grr_cluster\"]: cc for cc in ccs\n",
" }\n",
"\n",
"def construct_network_for_cluster(cluster, graph, ccs):\n",
" net = Network(notebook=True, cdn_resources=\"remote\")\n",
" net = Network(notebook=True)\n",
" cc = ccs[cluster]\n",
" sub = graph.subgraph(cc).copy()\n",
"\n",
Expand All @@ -743,7 +763,8 @@
"\n",
" for u, v in sub.edges():\n",
" net.add_edge(u, v)\n",
" return net"
" return net\n",
" "
]
},
{
Expand Down Expand Up @@ -773,7 +794,7 @@
"metadata": {},
"outputs": [],
"source": [
"cluster_id = \"cluster_4260\"\n",
"cluster_id = \"cluster_84\" # Containing the spot_47\n",
"net = construct_network_for_cluster(cluster_id, graph, ccs)\n",
"net.force_atlas_2based()\n",
"net.show_buttons(filter_=[\"physics\"])\n",
Expand Down Expand Up @@ -808,7 +829,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.19"
"version": "3.10.20"
}
},
"nbformat": 4,
Expand Down
2 changes: 0 additions & 2 deletions tutorials/Acinetobacter_baumannii/pangenomes_information.tsv

This file was deleted.

Loading