## Antimicrobial Resistance

Using [Abricate](https://github.com/tseemann/abricate#abricate), the assemblies are scanned for known resistance genes in the NCBI, CARD, Plasmidfinder and VFDB antimicrobial resistance and virulence factor databases. Here only the results from Card and VFDB are shown.

#### CARD

```{r abricate-card, echo = F, message = F, warning = F, error = T}

# I know there is a summary, but making sure that everything is parsed as numbers is just easier if I do my own pivot.
abricate_card = read_tsv(glob_list$abricate[grepl("card_", glob_list$abricate)], na = ".") %>%
    #rename(file_long = `#FILE`) #%>%
    mutate(file = basename(`#FILE`)) %>%
    select(file, GENE, `%COVERAGE`) %>%


    # Count number of genes in each sample
    group_by(file) %>%
    mutate(n = n()) %>%
    ungroup() %>%

    # Finally pivot to summarize
    pivot_wider(id_cols = c(file, n), names_from = GENE, values_from = `%COVERAGE`)



metadata_translate %>% 
    select(sample, file) %>%
    left_join(abricate_card, by = "file") %>%
    select(-file) %>%
    mutate(n = coalesce(n, 0)) %>% # the count will be empty for samples without matches otherwise
    custom_dt("abricate_card")

```

*Table `r tableno()`: Table of [CARD](https://card.mcmaster.ca/) (Comprehensive Antibiotic Resistance Database) results*

---

#### VFDB

```{r abricate-vfdb, echo = F, message = F, warning = F, error = T}

# I know there is a summary, but making sure that everything is parsed as numbers is just easier if I do my own pivot.
abricate_vfdb = read_tsv(glob_list$abricate[grepl("vfdb_", glob_list$abricate)], na = ".") %>%
    #rename(file_long = `#FILE`) #%>%
    mutate(file = basename(`#FILE`)) %>%
    select(file, GENE, `%COVERAGE`) %>%


    # Count number of genes in each sample
    group_by(file) %>%
    mutate(n = n()) %>%
    ungroup() %>%

    # Finally pivot to summarize
    pivot_wider(id_cols = c(file, n), names_from = GENE, values_from = `%COVERAGE`)



metadata_translate %>% 
    select(sample, file) %>%
    left_join(abricate_vfdb, by = "file") %>%
    select(-file) %>%
    mutate(n = coalesce(n, 0)) %>% # the count will be empty for samples without matches otherwise
    custom_dt("abricate_vfdb")


```

*Table `r tableno()`: Table of [VFDB](http://www.mgc.ac.cn/VFs/main.htm) virulence factor calls: "An integrated and comprehensive online resource for curating information about virulence factors of bacterial pathogens".*



---