forked from interpretAMR/datacuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATB_ESGEM_orgs.Rmd
167 lines (136 loc) · 3.72 KB
/
ATB_ESGEM_orgs.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
title: "Extract AMRfinderplus results for all ESGEM-AMR organisms"
output: html_document
date: "2024-10-24"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(dev = 'png', echo = TRUE, message = FALSE, warning = FALSE,
cache = FALSE, fig.align = 'center')
knitr::opts_knit$set(root.dir = getwd())
# Data wrangling
library(tidyverse)
library(dplyr)
source("AllTheBacteria_functions.R")
```
# set path to file of AMRFinderPlus from AllTheBacteria, downlaoded from https://osf.io/zgexh (0.5GB)
``` {r}
ATB_amrfp <- "AMRFP_results.tsv.gz"
```
# extract AMRfp data for a given species
``` {r}
# for a given species:
# extract amrfp results
# report number of rows, number of samples
# write out file
getAMRfp <- function(species) {
amrfp <- atb_amrfp_filter_by_taxa(user_taxa=species, atb_armfp_results_path=ATB_amrfp)
write_tsv(amrfp, file=paste0("AllTheBacteria/ATB_",species,"_AFP.tsv.gz"))
as.data.frame(paste(species, dim(amrfp)[1], length(unique(amrfp$Name)))) %>%
write_tsv(file=paste0("AllTheBacteria/ATB_",species,"_AFP_info.tsv"), col_names = F)
}
```
``` {r}
getAMRfp("Enterococcus")
```
``` {r}
getAMRfp("Enterobacter")
```
``` {r}
getAMRfp("Staphylococcus")
```
``` {r}
getAMRfp("Acinetobacter baumannii")
```
``` {r}
getAMRfp("Serratia")
```
``` {r}
getAMRfp("Neisseria gonorrhoeae")
getAMRfp("Streptococcus")
```
``` {r}
getAMRfp("Campylobacter")
getAMRfp("Haemophilus influenzae")
```
``` {r}
getAMRfp("Achromobacter")
getAMRfp("Aeromonas")
getAMRfp("Bordetella")
getAMRfp("Brucella")
getAMRfp("Burkholderia cepacia")
getAMRfp("Burkholderia pseudomallei")
```
``` {r}
getAMRfp("Chryseobacterium")
getAMRfp("Corynebacterium diphtheriae")
getAMRfp("Chryseobacterium")
getAMRfp("Edwardsiella")
getAMRfp("Legionella")
getAMRfp("Listeria")
```
``` {r}
getAMRfp("Mycoplasma")
getAMRfp("Ureaplasma")
getAMRfp("Neisseria meningitidis")
```
``` {r}
getAMRfp("Pasteurella")
getAMRfp("Proteus mirabilis")
getAMRfp("Shewanella")
getAMRfp("Stenotrophomonas")
```
``` {r}
getAMRfp("Treponema")
getAMRfp("Vibrio")
```
``` {r}
getAMRfp("Yersinia")
```
``` {r}
getAMRfp("Burkholderia mallei") # GTDB has mallei rather than pseudomallei
```
``` {r}
getAMRfp("Clostridioides difficile")
```
``` {r}
getAMRfp("Mycobacterium tuberculosis")
```
``` {r}
getAMRfp("Pseudomonas aeruginosa")
getAMRfp("Klebsiella pneumoniae")
getAMRfp("Klebsiella quasipneumoniae")
getAMRfp("Klebsiella variicola")
```
``` {r}
getAMRfp("Escherichia coli")
```
``` {r}
getAMRfp("Salmonella")
```
``` {r}
read_tsv("AllTheBacteria/ATB_Salmonella_AFP.tsv.gz") %>%
filter(`Element type`=="AMR") %>%
select(Name, `Gene symbol`, `Hierarchy node`, `Element type`, `Element subtype`, Class, Subclass, `% Coverage of reference sequence`, `% Identity to reference sequence`, `Accession of closest sequence`, Species) %>%
write_tsv("AllTheBacteria/ATB_Salmonella_AFP.tsv.gz")
```
``` {r}
read_tsv("AllTheBacteria/ATB_Escherichia coli_AFP.tsv.gz") %>%
filter(`Element type`=="AMR") %>%
select(Name, `Gene symbol`, `Hierarchy node`, `Element type`, `Element subtype`, Class, Subclass, `% Coverage of reference sequence`, `% Identity to reference sequence`, `Accession of closest sequence`, Species) %>%
write_tsv("AllTheBacteria/ATB_Escherichia coli_AFP.tsv.gz")
```
# get sample info for existing files
``` {r}
# for a given species:
# read in amrfp results
# report number of rows, number of samples
# write out file
getAMRfpinfo <- function(filepath) {
amrfp <- read_tsv(filepath)
infofile <- gsub("AFP.tsv.gz", "AFP_info.tsv", filepath)
species <- gsub("_AFP.tsv.gz", "", filepath)
species <- gsub("AllTheBacteria/ATB_","",species)
as.data.frame(paste(species, dim(amrfp)[1], length(unique(amrfp$Name)))) %>%
write_tsv(file=infofile, col_names = F)
}
```