# FAERS-Pharmacovigilance

#### 3 July 2024

# Contents

## 0.1 Introduction

The FDA Adverse Event Reporting System (FAERS) stands as a database dedicated to the monitoring of post-marketing drug safety and exercises a notable influence over FDA safety guidance documents, including the modification of drug labels. The quantity of cases stored within FAERS has experienced an exponential surge due to the refinement of submission techniques and adherence to standardized data protocols, making it a pivotal asset for the realm of regulatory science. While FAERS has predominantly focused on safety signal detection, the faers package acts as the intermediary, seamlessly bridging the gap between the FAERS database and the programming language R. Moreover, the faers package provides a unified methodology for the seamless execution of pharmacovigilance analysis, facilitating the integration of genetic tools in R. With an ultimate ambition towards precision medicine, it aspires to scrutinize the vast expanse of the human genome, revealing drug pathways that may be intricately tied to potentially functional, population-differentiated polymorphisms.

## 0.2 Installation

To install from Bioconductor, use the following code:

    if (!requireNamespace("BiocManager", quietly = TRUE)) {
        install.packages("BiocManager")
    }
    BiocManager::install("faers")

You can install the development version of `faers` from GitHub with:

    if (!requireNamespace("pak")) {
        install.packages("pak",
            repos = sprintf(
                "https://r-lib.github.io/p/pak/devel/%s/%s/%s",
                .Platform$pkgType, R.Version()$os, R.Version()$arch
            )
        )
    }
    pak::pkg_install("Yunuuuu/faers")

## 0.3 Pharmacovigilance Analysis using FAERS

FAERS is a database for the spontaneous reporting of adverse events and medication errors involving human drugs and therapeutic biological products. This package accelarate the process of Pharmacovigilance Analysis using FAERS.

    library(faers)

### 0.3.1 Check metadata of FAERS

This will return a data.table reporting years, period, quarter, and file urls and file sizes. By default, this will use the cached file in `tools::R_user_dir("faers", "cache")`. If it doesn’t exist, the internal will parse metadata in https://fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html

    faers_meta()
    #> → Reading html:
    #>   <https://fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html>
    #> → Writing FAERS metadata into cache file
    #>   'C:\Users\biocbuild\AppData\Local/R/cache/R/faers/faers/metadata/faers_meta_data.rds'
    #>      year quarter             period
    #>     <int>  <char>             <char>
    #>  1:  2024      q1    January - March
    #>  2:  2023      q4 October - December
    #>  3:  2023      q3   July - September
    #>  4:  2023      q2       April - June
    #>  5:  2023      q1    January - March
    #>  6:  2022      q4 October - December
    #>  7:  2022      q3   July - September
    #>  8:  2022      q2       April - June
    #>  9:  2022      q1    January - March
    #> 10:  2021      q4 October - December
    #> 11:  2021      q3   July - September
    #> 12:  2021      q2       April - June
    #> 13:  2021      q1    January - March
    #> 14:  2020      q4 October - December
    #> 15:  2020      q3   July - September
    #> 16:  2020      q2       April - June
    #> 17:  2020      q1    January - March
    #> 18:  2019      q4 October - December
    #> 19:  2019      q3   July - September
    #> 20:  2019      q2       April - June
    #> 21:  2019      q1    January - March
    #> 22:  2018      q4 October - December
    #> 23:  2018      q3   July - September
    #> 24:  2018      q2       April - June
    #> 25:  2018      q1    January - March
    #> 26:  2017      q4 October - December
    #> 27:  2017      q3   July - September
    #> 28:  2017      q2       April - June
    #> 29:  2017      q1    January - March
    #> 30:  2016      q4 October - December
    #> 31:  2016      q3   July - September
    #> 32:  2016      q2       April - June
    #> 33:  2016      q1    January - March
    #> 34:  2015      q4 October - December
    #> 35:  2015      q3   July - September
    #> 36:  2015      q2       April - June
    #> 37:  2015      q1    January - March
    #> 38:  2014      q4 October - December
    #> 39:  2014      q3   July - September
    #> 40:  2014      q2       April - June
    #> 41:  2014      q1    January - March
    #> 42:  2013      q4 October - December
    #> 43:  2013      q3   July - September
    #> 44:  2013      q2       April - June
    #> 45:  2013      q1    January - March
    #> 46:  2012      q4 October - December
    #> 47:  2012      q3   July - September
    #> 48:  2012      q2       April - June
    #> 49:  2012      q1    January - March
    #> 50:  2011      q4 October - December
    #> 51:  2011      q3   July - September
    #> 52:  2011      q2       April - June
    #> 53:  2011      q1    January - March
    #> 54:  2010      q4 October - December
    #> 55:  2010      q3   July - September
    #> 56:  2010      q2       April - June
    #> 57:  2010      q1    January - March
    #> 58:  2009      q4 October - December
    #> 59:  2009      q3   July - September
    #> 60:  2009      q2       April - June
    #> 61:  2009      q1    January - March
    #> 62:  2008      q4 October - December
    #> 63:  2008      q3   July - September
    #> 64:  2008      q2       April - June
    #> 65:  2008      q1    January - March
    #> 66:  2007      q4 October - December
    #> 67:  2007      q3   July - September
    #> 68:  2007      q2       April - June
    #> 69:  2007      q1    January - March
    #> 70:  2006      q4 October - December
    #> 71:  2006      q3   July - September
    #> 72:  2006      q2       April - June
    #> 73:  2006      q1    January - March
    #> 74:  2005      q4 October - December
    #> 75:  2005      q3   July - September
    #> 76:  2005      q2       April - June
    #> 77:  2005      q1    January - March
    #> 78:  2004      q4 October - December
    #> 79:  2004      q3   July - September
    #> 80:  2004      q2       April - June
    #> 81:  2004      q1    January - March
    #>      year quarter             period
    #>                                                     ascii_urls ascii_file_size
    #>                                                         <char>          <char>
    #>  1: https://fis.fda.gov/content/Exports/faers_ascii_2024q1.zip          63.1MB
    #>  2: https://fis.fda.gov/content/Exports/faers_ascii_2023Q4.zip          69.1MB
    #>  3: https://fis.fda.gov/content/Exports/faers_ascii_2023Q3.zip          60.1MB
    #>  4: https://fis.fda.gov/content/Exports/faers_ascii_2023q2.zip          64.5MB
    #>  5: https://fis.fda.gov/content/Exports/faers_ascii_2023q1.zip          64.3MB
    #>  6: https://fis.fda.gov/content/Exports/faers_ascii_2022Q4.zip            69MB
    #>  7: https://fis.fda.gov/content/Exports/faers_ascii_2022Q3.zip          63.2MB
    #>  8: https://fis.fda.gov/content/Exports/faers_ascii_2022q2.zip            63MB
    #>  9: https://fis.fda.gov/content/Exports/faers_ascii_2022q1.zip          64.7MB
    #> 10: https://fis.fda.gov/content/Exports/faers_ascii_2021Q4.zip            59MB
    #> 11: https://fis.fda.gov/content/Exports/faers_ascii_2021Q3.zip            70MB
    #> 12: https://fis.fda.gov/content/Exports/faers_ascii_2021Q2.zip            66MB
    #> 13: https://fis.fda.gov/content/Exports/faers_ascii_2021Q1.zip            69MB
    #> 14: https://fis.fda.gov/content/Exports/faers_ascii_2020Q4.zip            71MB
    #> 15: https://fis.fda.gov/content/Exports/faers_ascii_2020Q3.zip            64MB
    #> 16: https://fis.fda.gov/content/Exports/faers_ascii_2020Q2.zip            66MB
    #> 17: https://fis.fda.gov/content/Exports/faers_ascii_2020Q1.zip            65MB
    #> 18: https://fis.fda.gov/content/Exports/faers_ascii_2019Q4.zip            60MB
    #> 19: https://fis.fda.gov/content/Exports/faers_ascii_2019Q3.zip            62MB
    #> 20: https://fis.fda.gov/content/Exports/faers_ascii_2019Q2.zip            62MB
    #> 21: https://fis.fda.gov/content/Exports/faers_ascii_2019Q1.zip            56MB
    #> 22: https://fis.fda.gov/content/Exports/faers_ascii_2018q4.zip            60MB
    #> 23: https://fis.fda.gov/content/Exports/faers_ascii_2018q3.zip            60MB
    #> 24: https://fis.fda.gov/content/Exports/faers_ascii_2018q2.zip            60MB
    #> 25: https://fis.fda.gov/content/Exports/faers_ascii_2018q1.zip            52MB
    #> 26: https://fis.fda.gov/content/Exports/faers_ascii_2017q4.zip            41MB
    #> 27: https://fis.fda.gov/content/Exports/faers_ascii_2017q3.zip            48MB
    #> 28: https://fis.fda.gov/content/Exports/faers_ascii_2017q2.zip            46MB
    #> 29: https://fis.fda.gov/content/Exports/faers_ascii_2017q1.zip            48MB
    #> 30: https://fis.fda.gov/content/Exports/faers_ascii_2016q4.zip            44MB
    #> 31: https://fis.fda.gov/content/Exports/faers_ascii_2016q3.zip            46MB
    #> 32: https://fis.fda.gov/content/Exports/faers_ascii_2016q2.zip            44MB
    #> 33: https://fis.fda.gov/content/Exports/faers_ascii_2016q1.zip            46MB
    #> 34: https://fis.fda.gov/content/Exports/faers_ascii_2015q4.zip            42MB
    #> 35: https://fis.fda.gov/content/Exports/faers_ascii_2015q3.zip            47MB
    #> 36: https://fis.fda.gov/content/Exports/faers_ascii_2015q2.zip            38MB
    #> 37: https://fis.fda.gov/content/Exports/faers_ascii_2015q1.zip            39MB
    #> 38: https://fis.fda.gov/content/Exports/faers_ascii_2014q4.zip            28MB
    #> 39: https://fis.fda.gov/content/Exports/faers_ascii_2014q3.zip            28MB
    #> 40: https://fis.fda.gov/content/Exports/faers_ascii_2014q2.zip            25MB
    #> 41: https://fis.fda.gov/content/Exports/faers_ascii_2014q1.zip            30MB
    #> 42: https://fis.fda.gov/content/Exports/faers_ascii_2013q4.zip            26MB
    #> 43: https://fis.fda.gov/content/Exports/faers_ascii_2013q3.zip            22MB
    #> 44: https://fis.fda.gov/content/Exports/faers_ascii_2013q2.zip            21MB
    #> 45: https://fis.fda.gov/content/Exports/faers_ascii_2013q1.zip            25MB
    #> 46: https://fis.fda.gov/content/Exports/faers_ascii_2012q4.zip            28MB
    #> 47:  https://fis.fda.gov/content/Exports/aers_ascii_2012q3.zip            16MB
    #> 48:  https://fis.fda.gov/content/Exports/aers_ascii_2012q2.zip            25MB
    #> 49:  https://fis.fda.gov/content/Exports/aers_ascii_2012q1.zip            26MB
    #> 50:  https://fis.fda.gov/content/Exports/aers_ascii_2011q4.zip            23MB
    #> 51:  https://fis.fda.gov/content/Exports/aers_ascii_2011q3.zip            23MB
    #> 52:  https://fis.fda.gov/content/Exports/aers_ascii_2011q2.zip            23MB
    #> 53:  https://fis.fda.gov/content/Exports/aers_ascii_2011q1.zip            21MB
    #> 54:  https://fis.fda.gov/content/Exports/aers_ascii_2010q4.zip            20MB
    #> 55:  https://fis.fda.gov/content/Exports/aers_ascii_2010q3.zip            22MB
    #> 56:  https://fis.fda.gov/content/Exports/aers_ascii_2010q2.zip            17MB
    #> 57:  https://fis.fda.gov/content/Exports/aers_ascii_2010q1.zip            16MB
    #> 58:  https://fis.fda.gov/content/Exports/aers_ascii_2009q4.zip            16MB
    #> 59:  https://fis.fda.gov/content/Exports/aers_ascii_2009q3.zip            16MB
    #> 60:  https://fis.fda.gov/content/Exports/aers_ascii_2009q2.zip            14MB
    #> 61:  https://fis.fda.gov/content/Exports/aers_ascii_2009q1.zip            13MB
    #> 62:  https://fis.fda.gov/content/Exports/aers_ascii_2008q4.zip            13MB
    #> 63:  https://fis.fda.gov/content/Exports/aers_ascii_2008q3.zip            13MB
    #> 64:  https://fis.fda.gov/content/Exports/aers_ascii_2008q2.zip            12MB
    #> 65:  https://fis.fda.gov/content/Exports/aers_ascii_2008q1.zip            12MB
    #> 66:  https://fis.fda.gov/content/Exports/aers_ascii_2007q4.zip            12MB
    #> 67:  https://fis.fda.gov/content/Exports/aers_ascii_2007q3.zip           9.9MB
    #> 68:  https://fis.fda.gov/content/Exports/aers_ascii_2007q2.zip           9.5MB
    #> 69:  https://fis.fda.gov/content/Exports/aers_ascii_2007q1.zip           9.6MB
    #> 70:  https://fis.fda.gov/content/Exports/aers_ascii_2006q4.zip           9.1MB
    #> 71:  https://fis.fda.gov/content/Exports/aers_ascii_2006q3.zip           8.5MB
    #> 72:  https://fis.fda.gov/content/Exports/aers_ascii_2006q2.zip           9.7MB
    #> 73:  https://fis.fda.gov/content/Exports/aers_ascii_2006q1.zip            11MB
    #> 74:  https://fis.fda.gov/content/Exports/aers_ascii_2005q4.zip           9.7MB
    #> 75:  https://fis.fda.gov/content/Exports/aers_ascii_2005q3.zip           9.3MB
    #> 76:  https://fis.fda.gov/content/Exports/aers_ascii_2005q2.zip           9.5MB
    #> 77:  https://fis.fda.gov/content/Exports/aers_ascii_2005q1.zip           8.5MB
    #> 78:  https://fis.fda.gov/content/Exports/aers_ascii_2004q4.zip           8.1MB
    #> 79:  https://fis.fda.gov/content/Exports/aers_ascii_2004q3.zip           8.2MB
    #> 80:  https://fis.fda.gov/content/Exports/aers_ascii_2004q2.zip           7.1MB
    #> 81:  https://fis.fda.gov/content/Exports/aers_ascii_2004q1.zip           7.3MB
    #>                                                     ascii_urls ascii_file_size
    #>                                                     xml_urls xml_file_size
    #>                                                       <char>        <char>
    #>  1: https://fis.fda.gov/content/Exports/faers_xml_2024q1.zip         128MB
    #>  2: https://fis.fda.gov/content/Exports/faers_xml_2023Q4.zip         140MB
    #>  3: https://fis.fda.gov/content/Exports/faers_xml_2023Q3.zip         123MB
    #>  4: https://fis.fda.gov/content/Exports/faers_xml_2023q2.zip         130MB
    #>  5: https://fis.fda.gov/content/Exports/faers_xml_2023q1.zip         133MB
    #>  6: https://fis.fda.gov/content/Exports/faers_xml_2022Q4.zip         144MB
    #>  7: https://fis.fda.gov/content/Exports/faers_xml_2022Q3.zip         132MB
    #>  8: https://fis.fda.gov/content/Exports/faers_xml_2022q2.zip         140MB
    #>  9: https://fis.fda.gov/content/Exports/faers_xml_2022q1.zip         136MB
    #> 10: https://fis.fda.gov/content/Exports/faers_xml_2021Q4.zip         123MB
    #> 11: https://fis.fda.gov/content/Exports/faers_xml_2021Q3.zip         132MB
    #> 12: https://fis.fda.gov/content/Exports/faers_xml_2021Q2.zip         123MB
    #> 13: https://fis.fda.gov/content/Exports/faers_xml_2021Q1.zip         130MB
    #> 14: https://fis.fda.gov/content/Exports/faers_xml_2020Q4.zip         131MB
    #> 15: https://fis.fda.gov/content/Exports/faers_xml_2020Q3.zip         121MB
    #> 16: https://fis.fda.gov/content/Exports/faers_xml_2020Q2.zip         123MB
    #> 17: https://fis.fda.gov/content/Exports/faers_xml_2020Q1.zip         125MB
    #> 18: https://fis.fda.gov/content/Exports/faers_xml_2019Q4.zip         113MB
    #> 19: https://fis.fda.gov/content/Exports/faers_xml_2019Q3.zip         118MB
    #> 20: https://fis.fda.gov/content/Exports/faers_xml_2019Q2.zip         118MB
    #> 21: https://fis.fda.gov/content/Exports/faers_xml_2019Q1.zip         103MB
    #> 22: https://fis.fda.gov/content/Exports/faers_xml_2018q4.zip         112MB
    #> 23: https://fis.fda.gov/content/Exports/faers_xml_2018q3.zip         112MB
    #> 24: https://fis.fda.gov/content/Exports/faers_xml_2018q2.zip         112MB
    #> 25: https://fis.fda.gov/content/Exports/faers_xml_2018q1.zip          94MB
    #> 26: https://fis.fda.gov/content/Exports/faers_xml_2017q4.zip          76MB
    #> 27: https://fis.fda.gov/content/Exports/faers_xml_2017q3.zip          91MB
    #> 28: https://fis.fda.gov/content/Exports/faers_xml_2017q2.zip          86MB
    #> 29: https://fis.fda.gov/content/Exports/faers_xml_2017q1.zip          91MB
    #> 30: https://fis.fda.gov/content/Exports/faers_xml_2016q4.zip          82MB
    #> 31: https://fis.fda.gov/content/Exports/faers_xml_2016q3.zip          87MB
    #> 32: https://fis.fda.gov/content/Exports/faers_xml_2016q2.zip          81MB
    #> 33: https://fis.fda.gov/content/Exports/faers_xml_2016q1.zip          84MB
    #> 34: https://fis.fda.gov/content/Exports/faers_xml_2015q4.zip          77MB
    #> 35: https://fis.fda.gov/content/Exports/faers_xml_2015q3.zip          88MB
    #> 36: https://fis.fda.gov/content/Exports/faers_xml_2015q2.zip          70MB
    #> 37: https://fis.fda.gov/content/Exports/faers_xml_2015q1.zip          72MB
    #> 38: https://fis.fda.gov/content/Exports/faers_xml_2014q4.zip          53MB
    #> 39: https://fis.fda.gov/content/Exports/faers_xml_2014q3.zip          54MB
    #> 40: https://fis.fda.gov/content/Exports/faers_xml_2014q2.zip          44MB
    #> 41: https://fis.fda.gov/content/Exports/faers_xml_2014q1.zip          52MB
    #> 42: https://fis.fda.gov/content/Exports/faers_xml_2013q4.zip          46MB
    #> 43: https://fis.fda.gov/content/Exports/faers_xml_2013q3.zip          40MB
    #> 44: https://fis.fda.gov/content/Exports/faers_xml_2013q2.zip          38MB
    #> 45: https://fis.fda.gov/content/Exports/faers_xml_2013q1.zip          44MB
    #> 46: https://fis.fda.gov/content/Exports/faers_xml_2012q4.zip          50MB
    #> 47: https://fis.fda.gov/content/Exports/aers_sgml_2012q3.zip          21MB
    #> 48: https://fis.fda.gov/content/Exports/aers_sgml_2012q2.zip          32MB
    #> 49: https://fis.fda.gov/content/Exports/aers_sgml_2012q1.zip          33MB
    #> 50: https://fis.fda.gov/content/Exports/aers_sgml_2011q4.zip          29MB
    #> 51: https://fis.fda.gov/content/Exports/aers_sgml_2011q3.zip          29MB
    #> 52: https://fis.fda.gov/content/Exports/aers_sgml_2011q2.zip          29MB
    #> 53: https://fis.fda.gov/content/Exports/aers_sgml_2011q1.zip          26MB
    #> 54: https://fis.fda.gov/content/Exports/aers_sgml_2010q4.zip          25MB
    #> 55: https://fis.fda.gov/content/Exports/aers_sgml_2010q3.zip          28MB
    #> 56: https://fis.fda.gov/content/Exports/aers_sgml_2010q2.zip          22MB
    #> 57: https://fis.fda.gov/content/Exports/aers_sgml_2010q1.zip          20MB
    #> 58: https://fis.fda.gov/content/Exports/aers_sgml_2009q4.zip          20MB
    #> 59: https://fis.fda.gov/content/Exports/aers_sgml_2009q3.zip          19MB
    #> 60: https://fis.fda.gov/content/Exports/aers_sgml_2009q2.zip          18MB
    #> 61: https://fis.fda.gov/content/Exports/aers_sgml_2009q1.zip          16MB
    #> 62: https://fis.fda.gov/content/Exports/aers_sgml_2008q4.zip          16MB
    #> 63: https://fis.fda.gov/content/Exports/aers_sgml_2008q3.zip          16MB
    #> 64: https://fis.fda.gov/content/Exports/aers_sgml_2008q2.zip          16MB
    #> 65: https://fis.fda.gov/content/Exports/aers_sgml_2008q1.zip          15MB
    #> 66: https://fis.fda.gov/content/Exports/aers_sgml_2007q4.zip          14MB
    #> 67: https://fis.fda.gov/content/Exports/aers_sgml_2007q3.zip          13MB
    #> 68: https://fis.fda.gov/content/Exports/aers_sgml_2007q2.zip          12MB
    #> 69: https://fis.fda.gov/content/Exports/aers_sgml_2007q1.zip          12MB
    #> 70: https://fis.fda.gov/content/Exports/aers_sgml_2006q4.zip          12MB
    #> 71: https://fis.fda.gov/content/Exports/aers_sgml_2006q3.zip          11MB
    #> 72: https://fis.fda.gov/content/Exports/aers_sgml_2006q2.zip          13MB
    #> 73: https://fis.fda.gov/content/Exports/aers_sgml_2006q1.zip          13MB
    #> 74: https://fis.fda.gov/content/Exports/aers_sgml_2005q4.zip          12MB
    #> 75: https://fis.fda.gov/content/Exports/aers_sgml_2005q3.zip          12MB
    #> 76: https://fis.fda.gov/content/Exports/aers_sgml_2005q2.zip          12MB
    #> 77: https://fis.fda.gov/content/Exports/aers_sgml_2005q1.zip          11MB
    #> 78: https://fis.fda.gov/content/Exports/aers_sgml_2004q4.zip         9.8MB
    #> 79: https://fis.fda.gov/content/Exports/aers_sgml_2004q3.zip         9.7MB
    #> 80: https://fis.fda.gov/content/Exports/aers_sgml_2004q2.zip         8.6MB
    #> 81: https://fis.fda.gov/content/Exports/aers_sgml_2004q1.zip         8.8MB
    #>                                                     xml_urls xml_file_size

An metadata copy was associated with the package, just set `internal = TRUE`. However, this copy will only be used if the cached file on your computer cannot be found as the cached file on your computer should be more up-to-date than this metadata copy.

    faers_clearcache("metadata")
    #> ✔ Removing 'C:\Users\biocbuild\AppData\Local/R/cache/R/faers/faers/metadata' successfully

    faers_meta(internal = TRUE)
    #> → Using internal FAERS metadata
    #>   Snapshot time: 2023-11-08 00:06:35.726011
    #>      year quarter             period
    #>     <int>  <char>             <char>
    #>  1:  2023      q3   July - September
    #>  2:  2023      q2       April - June
    #>  3:  2023      q1    January - March
    #>  4:  2022      q4 October - December
    #>  5:  2022      q3   July - September
    #>  6:  2022      q2       April - June
    #>  7:  2022      q1    January - March
    #>  8:  2021      q4 October - December
    #>  9:  2021      q3   July - September
    #> 10:  2021      q2       April - June
    #> 11:  2021      q1    January - March
    #> 12:  2020      q4 October - December
    #> 13:  2020      q3   July - September
    #> 14:  2020      q2       April - June
    #> 15:  2020      q1    January - March
    #> 16:  2019      q4 October - December
    #> 17:  2019      q3   July - September
    #> 18:  2019      q2       April - June
    #> 19:  2019      q1    January - March
    #> 20:  2018      q4 October - December
    #> 21:  2018      q3   July - September
    #> 22:  2018      q2       April - June
    #> 23:  2018      q1    January - March
    #> 24:  2017      q4 October - December
    #> 25:  2017      q3   July - September
    #> 26:  2017      q2       April - June
    #> 27:  2017      q1    January - March
    #> 28:  2016      q4 October - December
    #> 29:  2016      q3   July - September
    #> 30:  2016      q2       April - June
    #> 31:  2016      q1    January - March
    #> 32:  2015      q4 October - December
    #> 33:  2015      q3   July - September
    #> 34:  2015      q2       April - June
    #> 35:  2015      q1    January - March
    #> 36:  2014      q4 October - December
    #> 37:  2014      q3   July - September
    #> 38:  2014      q2       April - June
    #> 39:  2014      q1    January - March
    #> 40:  2013      q4 October - December
    #> 41:  2013      q3   July - September
    #> 42:  2013      q2       April - June
    #> 43:  2013      q1    January - March
    #> 44:  2012      q4 October - December
    #> 45:  2012      q3   July - September
    #> 46:  2012      q2       April - June
    #> 47:  2012      q1    January - March
    #> 48:  2011      q4 October - December
    #> 49:  2011      q3   July - September
    #> 50:  2011      q2       April - June
    #> 51:  2011      q1    January - March
    #> 52:  2010      q4 October - December
    #> 53:  2010      q3   July - September
    #> 54:  2010      q2       April - June
    #> 55:  2010      q1    January - March
    #> 56:  2009      q4 October - December
    #> 57:  2009      q3   July - September
    #> 58:  2009      q2       April - June
    #> 59:  2009      q1    January - March
    #> 60:  2008      q4 October - December
    #> 61:  2008      q3   July - September
    #> 62:  2008      q2       April - June
    #> 63:  2008      q1    January - March
    #> 64:  2007      q4 October - December
    #> 65:  2007      q3   July - September
    #> 66:  2007      q2       April - June
    #> 67:  2007      q1    January - March
    #> 68:  2006      q4 October - December
    #> 69:  2006      q3   July - September
    #> 70:  2006      q2       April - June
    #> 71:  2006      q1    January - March
    #> 72:  2005      q4 October - December
    #> 73:  2005      q3   July - September
    #> 74:  2005      q2       April - June
    #> 75:  2005      q1    January - March
    #> 76:  2004      q4 October - December
    #> 77:  2004      q3   July - September
    #> 78:  2004      q2       April - June
    #> 79:  2004      q1    January - March
    #>      year quarter             period
    #>                                                     ascii_urls ascii_file_size
    #>                                                         <char>          <char>
    #>  1: https://fis.fda.gov/content/Exports/faers_ascii_2023Q3.zip          60.1MB
    #>  2: https://fis.fda.gov/content/Exports/faers_ascii_2023q2.zip          64.5MB
    #>  3: https://fis.fda.gov/content/Exports/faers_ascii_2023q1.zip          64.3MB
    #>  4: https://fis.fda.gov/content/Exports/faers_ascii_2022Q4.zip            69MB
    #>  5: https://fis.fda.gov/content/Exports/faers_ascii_2022Q3.zip          63.2MB
    #>  6: https://fis.fda.gov/content/Exports/faers_ascii_2022q2.zip            63MB
    #>  7: https://fis.fda.gov/content/Exports/faers_ascii_2022q1.zip          64.7MB
    #>  8: https://fis.fda.gov/content/Exports/faers_ascii_2021Q4.zip            59MB
    #>  9: https://fis.fda.gov/content/Exports/faers_ascii_2021Q3.zip            70MB
    #> 10: https://fis.fda.gov/content/Exports/faers_ascii_2021Q2.zip            66MB
    #> 11: https://fis.fda.gov/content/Exports/faers_ascii_2021Q1.zip            69MB
    #> 12: https://fis.fda.gov/content/Exports/faers_ascii_2020Q4.zip            71MB
    #> 13: https://fis.fda.gov/content/Exports/faers_ascii_2020Q3.zip            64MB
    #> 14: https://fis.fda.gov/content/Exports/faers_ascii_2020Q2.zip            66MB
    #> 15: https://fis.fda.gov/content/Exports/faers_ascii_2020Q1.zip            65MB
    #> 16: https://fis.fda.gov/content/Exports/faers_ascii_2019Q4.zip            60MB
    #> 17: https://fis.fda.gov/content/Exports/faers_ascii_2019Q3.zip            62MB
    #> 18: https://fis.fda.gov/content/Exports/faers_ascii_2019Q2.zip            62MB
    #> 19: https://fis.fda.gov/content/Exports/faers_ascii_2019Q1.zip            56MB
    #> 20: https://fis.fda.gov/content/Exports/faers_ascii_2018q4.zip            60MB
    #> 21: https://fis.fda.gov/content/Exports/faers_ascii_2018q3.zip            60MB
    #> 22: https://fis.fda.gov/content/Exports/faers_ascii_2018q2.zip            60MB
    #> 23: https://fis.fda.gov/content/Exports/faers_ascii_2018q1.zip            52MB
    #> 24: https://fis.fda.gov/content/Exports/faers_ascii_2017q4.zip            41MB
    #> 25: https://fis.fda.gov/content/Exports/faers_ascii_2017q3.zip            48MB
    #> 26: https://fis.fda.gov/content/Exports/faers_ascii_2017q2.zip            46MB
    #> 27: https://fis.fda.gov/content/Exports/faers_ascii_2017q1.zip            48MB
    #> 28: https://fis.fda.gov/content/Exports/faers_ascii_2016q4.zip            44MB
    #> 29: https://fis.fda.gov/content/Exports/faers_ascii_2016q3.zip            46MB
    #> 30: https://fis.fda.gov/content/Exports/faers_ascii_2016q2.zip            44MB
    #> 31: https://fis.fda.gov/content/Exports/faers_ascii_2016q1.zip            46MB
    #> 32: https://fis.fda.gov/content/Exports/faers_ascii_2015q4.zip            42MB
    #> 33: https://fis.fda.gov/content/Exports/faers_ascii_2015q3.zip            47MB
    #> 34: https://fis.fda.gov/content/Exports/faers_ascii_2015q2.zip            38MB
    #> 35: https://fis.fda.gov/content/Exports/faers_ascii_2015q1.zip            39MB
    #> 36: https://fis.fda.gov/content/Exports/faers_ascii_2014q4.zip            28MB
    #> 37: https://fis.fda.gov/content/Exports/faers_ascii_2014q3.zip            28MB
    #> 38: https://fis.fda.gov/content/Exports/faers_ascii_2014q2.zip            25MB
    #> 39: https://fis.fda.gov/content/Exports/faers_ascii_2014q1.zip            30MB
    #> 40: https://fis.fda.gov/content/Exports/faers_ascii_2013q4.zip            26MB
    #> 41: https://fis.fda.gov/content/Exports/faers_ascii_2013q3.zip            22MB
    #> 42: https://fis.fda.gov/content/Exports/faers_ascii_2013q2.zip            21MB
    #> 43: https://fis.fda.gov/content/Exports/faers_ascii_2013q1.zip            25MB
    #> 44: https://fis.fda.gov/content/Exports/faers_ascii_2012q4.zip            28MB
    #> 45:  https://fis.fda.gov/content/Exports/aers_ascii_2012q3.zip            16MB
    #> 46:  https://fis.fda.gov/content/Exports/aers_ascii_2012q2.zip            25MB
    #> 47:  https://fis.fda.gov/content/Exports/aers_ascii_2012q1.zip            26MB
    #> 48:  https://fis.fda.gov/content/Exports/aers_ascii_2011q4.zip            23MB
    #> 49:  https://fis.fda.gov/content/Exports/aers_ascii_2011q3.zip            23MB
    #> 50:  https://fis.fda.gov/content/Exports/aers_ascii_2011q2.zip            23MB
    #> 51:  https://fis.fda.gov/content/Exports/aers_ascii_2011q1.zip            21MB
    #> 52:  https://fis.fda.gov/content/Exports/aers_ascii_2010q4.zip            20MB
    #> 53:  https://fis.fda.gov/content/Exports/aers_ascii_2010q3.zip            22MB
    #> 54:  https://fis.fda.gov/content/Exports/aers_ascii_2010q2.zip            17MB
    #> 55:  https://fis.fda.gov/content/Exports/aers_ascii_2010q1.zip            16MB
    #> 56:  https://fis.fda.gov/content/Exports/aers_ascii_2009q4.zip            16MB
    #> 57:  https://fis.fda.gov/content/Exports/aers_ascii_2009q3.zip            16MB
    #> 58:  https://fis.fda.gov/content/Exports/aers_ascii_2009q2.zip            14MB
    #> 59:  https://fis.fda.gov/content/Exports/aers_ascii_2009q1.zip            13MB
    #> 60:  https://fis.fda.gov/content/Exports/aers_ascii_2008q4.zip            13MB
    #> 61:  https://fis.fda.gov/content/Exports/aers_ascii_2008q3.zip            13MB
    #> 62:  https://fis.fda.gov/content/Exports/aers_ascii_2008q2.zip            12MB
    #> 63:  https://fis.fda.gov/content/Exports/aers_ascii_2008q1.zip            12MB
    #> 64:  https://fis.fda.gov/content/Exports/aers_ascii_2007q4.zip            12MB
    #> 65:  https://fis.fda.gov/content/Exports/aers_ascii_2007q3.zip           9.9MB
    #> 66:  https://fis.fda.gov/content/Exports/aers_ascii_2007q2.zip           9.5MB
    #> 67:  https://fis.fda.gov/content/Exports/aers_ascii_2007q1.zip           9.6MB
    #> 68:  https://fis.fda.gov/content/Exports/aers_ascii_2006q4.zip           9.1MB
    #> 69:  https://fis.fda.gov/content/Exports/aers_ascii_2006q3.zip           8.5MB
    #> 70:  https://fis.fda.gov/content/Exports/aers_ascii_2006q2.zip           9.7MB
    #> 71:  https://fis.fda.gov/content/Exports/aers_ascii_2006q1.zip            11MB
    #> 72:  https://fis.fda.gov/content/Exports/aers_ascii_2005q4.zip           9.7MB
    #> 73:  https://fis.fda.gov/content/Exports/aers_ascii_2005q3.zip           9.3MB
    #> 74:  https://fis.fda.gov/content/Exports/aers_ascii_2005q2.zip           9.5MB
    #> 75:  https://fis.fda.gov/content/Exports/aers_ascii_2005q1.zip           8.5MB
    #> 76:  https://fis.fda.gov/content/Exports/aers_ascii_2004q4.zip           8.1MB
    #> 77:  https://fis.fda.gov/content/Exports/aers_ascii_2004q3.zip           8.2MB
    #> 78:  https://fis.fda.gov/content/Exports/aers_ascii_2004q2.zip           7.1MB
    #> 79:  https://fis.fda.gov/content/Exports/aers_ascii_2004q1.zip           7.3MB
    #>                                                     ascii_urls ascii_file_size
    #>                                                     xml_urls xml_file_size
    #>                                                       <char>        <char>
    #>  1: https://fis.fda.gov/content/Exports/faers_xml_2023Q3.zip         123MB
    #>  2: https://fis.fda.gov/content/Exports/faers_xml_2023q2.zip         130MB
    #>  3: https://fis.fda.gov/content/Exports/faers_xml_2023q1.zip         133MB
    #>  4: https://fis.fda.gov/content/Exports/faers_xml_2022Q4.zip         144MB
    #>  5: https://fis.fda.gov/content/Exports/faers_xml_2022Q3.zip         132MB
    #>  6: https://fis.fda.gov/content/Exports/faers_xml_2022q2.zip         140MB
    #>  7: https://fis.fda.gov/content/Exports/faers_xml_2022q1.zip         136MB
    #>  8: https://fis.fda.gov/content/Exports/faers_xml_2021Q4.zip         123MB
    #>  9: https://fis.fda.gov/content/Exports/faers_xml_2021Q3.zip         132MB
    #> 10: https://fis.fda.gov/content/Exports/faers_xml_2021Q2.zip         123MB
    #> 11: https://fis.fda.gov/content/Exports/faers_xml_2021Q1.zip         130MB
    #> 12: https://fis.fda.gov/content/Exports/faers_xml_2020Q4.zip         131MB
    #> 13: https://fis.fda.gov/content/Exports/faers_xml_2020Q3.zip         121MB
    #> 14: https://fis.fda.gov/content/Exports/faers_xml_2020Q2.zip         123MB
    #> 15: https://fis.fda.gov/content/Exports/faers_xml_2020Q1.zip         125MB
    #> 16: https://fis.fda.gov/content/Exports/faers_xml_2019Q4.zip         113MB
    #> 17: https://fis.fda.gov/content/Exports/faers_xml_2019Q3.zip         118MB
    #> 18: https://fis.fda.gov/content/Exports/faers_xml_2019Q2.zip         118MB
    #> 19: https://fis.fda.gov/content/Exports/faers_xml_2019Q1.zip         103MB
    #> 20: https://fis.fda.gov/content/Exports/faers_xml_2018q4.zip         112MB
    #> 21: https://fis.fda.gov/content/Exports/faers_xml_2018q3.zip         112MB
    #> 22: https://fis.fda.gov/content/Exports/faers_xml_2018q2.zip         112MB
    #> 23: https://fis.fda.gov/content/Exports/faers_xml_2018q1.zip          94MB
    #> 24: https://fis.fda.gov/content/Exports/faers_xml_2017q4.zip          76MB
    #> 25: https://fis.fda.gov/content/Exports/faers_xml_2017q3.zip          91MB
    #> 26: https://fis.fda.gov/content/Exports/faers_xml_2017q2.zip          86MB
    #> 27: https://fis.fda.gov/content/Exports/faers_xml_2017q1.zip          91MB
    #> 28: https://fis.fda.gov/content/Exports/faers_xml_2016q4.zip          82MB
    #> 29: https://fis.fda.gov/content/Exports/faers_xml_2016q3.zip          87MB
    #> 30: https://fis.fda.gov/content/Exports/faers_xml_2016q2.zip          81MB
    #> 31: https://fis.fda.gov/content/Exports/faers_xml_2016q1.zip          84MB
    #> 32: https://fis.fda.gov/content/Exports/faers_xml_2015q4.zip          77MB
    #> 33: https://fis.fda.gov/content/Exports/faers_xml_2015q3.zip          88MB
    #> 34: https://fis.fda.gov/content/Exports/faers_xml_2015q2.zip          70MB
    #> 35: https://fis.fda.gov/content/Exports/faers_xml_2015q1.zip          72MB
    #> 36: https://fis.fda.gov/content/Exports/faers_xml_2014q4.zip          53MB
    #> 37: https://fis.fda.gov/content/Exports/faers_xml_2014q3.zip          54MB
    #> 38: https://fis.fda.gov/content/Exports/faers_xml_2014q2.zip          44MB
    #> 39: https://fis.fda.gov/content/Exports/faers_xml_2014q1.zip          52MB
    #> 40: https://fis.fda.gov/content/Exports/faers_xml_2013q4.zip          46MB
    #> 41: https://fis.fda.gov/content/Exports/faers_xml_2013q3.zip          40MB
    #> 42: https://fis.fda.gov/content/Exports/faers_xml_2013q2.zip          38MB
    #> 43: https://fis.fda.gov/content/Exports/faers_xml_2013q1.zip          44MB
    #> 44: https://fis.fda.gov/content/Exports/faers_xml_2012q4.zip          50MB
    #> 45: https://fis.fda.gov/content/Exports/aers_sgml_2012q3.zip          21MB
    #> 46: https://fis.fda.gov/content/Exports/aers_sgml_2012q2.zip          32MB
    #> 47: https://fis.fda.gov/content/Exports/aers_sgml_2012q1.zip          33MB
    #> 48: https://fis.fda.gov/content/Exports/aers_sgml_2011q4.zip          29MB
    #> 49: https://fis.fda.gov/content/Exports/aers_sgml_2011q3.zip          29MB
    #> 50: https://fis.fda.gov/content/Exports/aers_sgml_2011q2.zip          29MB
    #> 51: https://fis.fda.gov/content/Exports/aers_sgml_2011q1.zip          26MB
    #> 52: https://fis.fda.gov/content/Exports/aers_sgml_2010q4.zip          25MB
    #> 53: https://fis.fda.gov/content/Exports/aers_sgml_2010q3.zip          28MB
    #> 54: https://fis.fda.gov/content/Exports/aers_sgml_2010q2.zip          22MB
    #> 55: https://fis.fda.gov/content/Exports/aers_sgml_2010q1.zip          20MB
    #> 56: https://fis.fda.gov/content/Exports/aers_sgml_2009q4.zip          20MB
    #> 57: https://fis.fda.gov/content/Exports/aers_sgml_2009q3.zip          19MB
    #> 58: https://fis.fda.gov/content/Exports/aers_sgml_2009q2.zip          18MB
    #> 59: https://fis.fda.gov/content/Exports/aers_sgml_2009q1.zip          16MB
    #> 60: https://fis.fda.gov/content/Exports/aers_sgml_2008q4.zip          16MB
    #> 61: https://fis.fda.gov/content/Exports/aers_sgml_2008q3.zip          16MB
    #> 62: https://fis.fda.gov/content/Exports/aers_sgml_2008q2.zip          16MB
    #> 63: https://fis.fda.gov/content/Exports/aers_sgml_2008q1.zip          15MB
    #> 64: https://fis.fda.gov/content/Exports/aers_sgml_2007q4.zip          14MB
    #> 65: https://fis.fda.gov/content/Exports/aers_sgml_2007q3.zip          13MB
    #> 66: https://fis.fda.gov/content/Exports/aers_sgml_2007q2.zip          12MB
    #> 67: https://fis.fda.gov/content/Exports/aers_sgml_2007q1.zip          12MB
    #> 68: https://fis.fda.gov/content/Exports/aers_sgml_2006q4.zip          12MB
    #> 69: https://fis.fda.gov/content/Exports/aers_sgml_2006q3.zip          11MB
    #> 70: https://fis.fda.gov/content/Exports/aers_sgml_2006q2.zip          13MB
    #> 71: https://fis.fda.gov/content/Exports/aers_sgml_2006q1.zip          13MB
    #> 72: https://fis.fda.gov/content/Exports/aers_sgml_2005q4.zip          12MB
    #> 73: https://fis.fda.gov/content/Exports/aers_sgml_2005q3.zip          12MB
    #> 74: https://fis.fda.gov/content/Exports/aers_sgml_2005q2.zip          12MB
    #> 75: https://fis.fda.gov/content/Exports/aers_sgml_2005q1.zip          11MB
    #> 76: https://fis.fda.gov/content/Exports/aers_sgml_2004q4.zip         9.8MB
    #> 77: https://fis.fda.gov/content/Exports/aers_sgml_2004q3.zip         9.7MB
    #> 78: https://fis.fda.gov/content/Exports/aers_sgml_2004q2.zip         8.6MB
    #> 79: https://fis.fda.gov/content/Exports/aers_sgml_2004q1.zip         8.8MB
    #>                                                     xml_urls xml_file_size

### 0.3.2 Download and Parse quarterly data files from FAERS

The FAERS Quarterly Data files contain raw data extracted from the AERS database for the indicated time ranges. The quarterly data files, which are available in ASCII or SGML formats, include:

- `demo`: demographic and administrative information
- `drug`: drug information from the case reports
- `reac`: reaction information from the reports
- `outc`: patient outcome information from the reports
- `rpsr`: information on the source of the reports
- `ther`: drug therapy start dates and end dates for the reported drugs
- `indi`: contains all “Medical Dictionary for Regulatory Activities” (MedDRA) terms coded for the indications for use (diagnoses) for the reported drugs

Generally, we can use `faers()` function to download and parse all quarterly data files from FAERS. Internally, the `faers()` function seamlessly utilizes `faers_download()` and `faers_parse()` to preprocess each quarterly data file from the FAERS repository. The default `format` was `ascii` and will return a `FAERSascii` object. (xml format would also be okay , but presently, the XML file receives only minimal support in the following process.)

Some variables has been added into specific field. See `?faers_parse` for details.

    # # you must change `dir`, as the file included in the package is sampled
    data1 <- faers(2004, "q1",
        dir = system.file("extdata", package = "faers"),
        compress_dir = tempdir()
    )
    #> Finding 1 file already downloaded: 'aers_ascii_2004q1.zip'

    data1
    #> FAERS data from 1 Quarterly ascii file
    #>   Total reports: 100 (with duplicates)

Furthermore, in cases where multiple quarterly data files are requisite, the `faers_combine()` function is judiciously employed.

    data2 <- faers(c(2004, 2017), c("q1", "q2"),
        dir = system.file("extdata", package = "faers"),
        compress_dir = tempdir()
    )
    #> Finding 2 files already downloaded: 'aers_ascii_2004q1.zip' and
    #> 'faers_ascii_2017q2.zip'
    #> → Combining all 2 <FAERS> Datas

    data2
    #> FAERS data from 2 Quarterly ascii files
    #>   Total reports: 200 (with duplicates)

You can use `faers_get()` to get specific field data, a data.table will be returned.

    faers_get(data2, "demo")
    #>       year quarter primaryid   caseid i_f_code foll_seq     image event_dt
    #>      <int>  <char>    <char>   <char>   <char>    <int>    <char>    <int>
    #>   1:  2004      q1   4263742  4061110        I       NA 4263742-7 20031115
    #>   2:  2004      q1   4264028  4064419        I       NA 4264028-7 20031127
    #>   3:  2004      q1   4265584  4057482        I       NA 4265584-5 20031029
    #>   4:  2004      q1   4268593  4066346        I       NA 4268593-5 20031009
    #>   5:  2004      q1   4268863  4066975        I       NA 4268863-0 20031228
    #>  ---
    #> 196:  2017      q2 136878411 13687841        I       NA      <NA>   201704
    #> 197:  2017      q2 136932671 13693267        I       NA      <NA>     2016
    #> 198:  2017      q2 136959401 13695940        I       NA      <NA>       NA
    #> 199:  2017      q2 136970751 13697075        I       NA      <NA> 20170623
    #> 200:  2017      q2  93588412  9358841        F       NA      <NA> 20120407
    #>        mfr_dt   fda_dt rept_cod                      mfr_num
    #>         <int>    <int>   <char>                       <char>
    #>   1: 20031218 20040102      EXP               DSA_23619_2003
    #>   2: 20031216 20040102      EXP                 GBT031201111
    #>   3:       NA 20040107      DIR                         <NA>
    #>   4: 20031225 20040108      EXP                   K200301940
    #>   5: 20031230 20040108      EXP                  2003UW17317
    #>  ---
    #> 196: 20170616 20170626      EXP     US-AMGEN-USASL2017093163
    #> 197: 20170621 20170627      EXP CA-ABBVIE-17K-028-2017994-00
    #> 198: 20170616 20170628      PER     US-AMGEN-USASP2017095323
    #> 199: 20170626 20170628      EXP US-ABBVIE-17K-163-2020858-00
    #> 200: 20170518 20170522      EXP     CN-PFIZER INC-2013181479
    #>                          mfr_sndr   age age_cod    sex  e_sub    wt wt_cod
    #>                            <char> <num>  <char> <char> <char> <num> <char>
    #>   1: BIOVAIL PHARMACEUTICALS INC.    42      YR      F      N    NA   <NA>
    #>   2:        ELI LILLY AND COMPANY    43      YR      F      N    71     KG
    #>   3:                         <NA>    44      YR      F      N   152    LBS
    #>   4:   KING PHARMACEUTICALS, INC.    75      YR      M      N    NA   <NA>
    #>   5:  ASTRAZENECA PHARMACEUTICALS    72      YR      F      N   109    LBS
    #>  ---
    #> 196:                        AMGEN    64      YR      M      Y    NA   <NA>
    #> 197:                       ABBVIE    NA    <NA>      F      Y    NA   <NA>
    #> 198:                        AMGEN    NA    <NA>   <NA>      Y    NA   <NA>
    #> 199:                       ABBVIE    71      YR      F      Y    NA   <NA>
    #> 200:                       PFIZER    16      YR      M      Y    40     KG
    #>       rept_dt occp_cod death_dt to_mfr confid    v23 caseversion age_in_years
    #>         <int>   <char>   <lgcl> <char> <char> <lgcl>       <int>        <num>
    #>   1: 20031231       OT       NA   <NA>   <NA>     NA           0           42
    #>   2: 20031223       MD       NA   <NA>   <NA>     NA           0           43
    #>   3: 20040106       MD       NA      N      N     NA           0           44
    #>   4: 20040107       OT       NA   <NA>   <NA>     NA           0           75
    #>   5: 20040107     <NA>       NA   <NA>   <NA>     NA           0           72
    #>  ---
    #> 196: 20170625       OT       NA   <NA>   <NA>     NA           1           64
    #> 197: 20170627       CN       NA   <NA>   <NA>     NA           1           NA
    #> 198: 20170627       MD       NA   <NA>   <NA>     NA           1           NA
    #> 199: 20170628       CN       NA   <NA>   <NA>     NA           1           71
    #> 200: 20170522       OT       NA   <NA>   <NA>     NA           2           16
    #>      country_code gender init_fda_dt auth_num lit_ref age_grp reporter_country
    #>            <char> <char>       <int>   <char>  <char>  <char>           <char>
    #>   1:         <NA>      F          NA     <NA>    <NA>    <NA>             <NA>
    #>   2:         <NA>      F          NA     <NA>    <NA>    <NA>             <NA>
    #>   3:         <NA>      F          NA     <NA>    <NA>    <NA>             <NA>
    #>   4:         <NA>      M          NA     <NA>    <NA>    <NA>             <NA>
    #>   5:         <NA>      F          NA     <NA>    <NA>    <NA>             <NA>
    #>  ---
    #> 196:           US      M    20170626     <NA>    <NA>       A               US
    #> 197:           CA      F    20170627     <NA>    <NA>    <NA>               CA
    #> 198:           US   <NA>    20170628     <NA>    <NA>    <NA>               US
    #> 199:           US      F    20170628     <NA>    <NA>    <NA>               US
    #> 200:           CN      M    20130620     <NA>    <NA>    <NA>               CN
    #>      occr_country
    #>            <char>
    #>   1:         <NA>
    #>   2:         <NA>
    #>   3:         <NA>
    #>   4:         <NA>
    #>   5:         <NA>
    #>  ---
    #> 196:           US
    #> 197:           CA
    #> 198:           US
    #> 199:           US
    #> 200:           CN

### 0.3.3 Standardize and De-duplication

The `reac` file provides the adverse drug reactions, where it includes the “P.T.” field or the “Preferred Term” level terminology from the Medical Dictionary for Regulatory Activities (MedDRA). The `indi` file contains the drug indications, which also uses the “P.T.” level of MedDRA as a descriptor for the drug indication. In this way, `MedDRA` was necessary to standardize this field and add additional informations, such as `System Organ Classes`.

    # you must replace `meddra_path` with the path of uncompressed meddra data
    data <- faers_standardize(data2, meddra_path)

To proceed following steps, we just read a standardized data.

    data <- readRDS(system.file("extdata", "standardized_data.rds",
        package = "faers"
    ))
    data
    #> Standardized FAERS data from 2 Quarterly ascii files
    #>   Total reports: 200 (with duplicates)

The internal will save the complete MedDRA data in the `@meddra` slot, MedDRA consists of two components: hierarchy and SMQ data. We can specify these components using the use argument.

    faers_meddra(data)
    #> Hierarchy data for MedDRA (version 26.1)

    faers_meddra(data, use = "hierarchy")
    #>        llt_code
    #>           <int>
    #>     1: 10000001
    #>     2: 10000002
    #>     3: 10000003
    #>     4: 10000004
    #>     5: 10000005
    #>    ---
    #> 87588: 10089903
    #> 87589: 10089904
    #> 87590: 10089905
    #> 87591: 10089906
    #> 87592: 10089907
    #>                                                                llt_name
    #>                                                                  <char>
    #>     1:                                        "Ventilation" pneumonitis
    #>     2:                                   11-beta-hydroxylase deficiency
    #>     3:                                      11-oxysteroid activity incr
    #>     4:                                 11-oxysteroid activity increased
    #>     5:                                            17 ketosteroids urine
    #>    ---
    #> 87588:                                Unintentional exposure to product
    #> 87589:                       Unintentional exposure to product by child
    #> 87590:                                Smouldering systemic mastocytosis
    #> 87591: Systemic mastocytosis with an associated haematological neoplasm
    #> 87592:                                              Smouldering myeloma
    #>         pt_code                                 pt_name hlt_code
    #>           <int>                                  <char>    <int>
    #>     1: 10081988            Hypersensitivity pneumonitis 10024972
    #>     2: 10000002          11-beta-hydroxylase deficiency 10021608
    #>     3: 10033315            Oxycorticosteroids increased 10001339
    #>     4: 10033315            Oxycorticosteroids increased 10001339
    #>     5: 10000005                   17 ketosteroids urine 10038589
    #>    ---
    #> 87588: 10073317          Accidental exposure to product 10073316
    #> 87589: 10073318 Accidental exposure to product by child 10073316
    #> 87590: 10089905       Smouldering systemic mastocytosis 10018845
    #> 87591: 10089805          Advanced systemic mastocytosis 10018845
    #> 87592: 10035226                     Plasma cell myeloma 10074470
    #>                                                               hlt_name
    #>                                                                 <char>
    #>     1: Lower respiratory tract inflammatory and immunologic conditions
    #>     2:                              Inborn errors of steroid synthesis
    #>     3:                                            Adrenal cortex tests
    #>     4:                                            Adrenal cortex tests
    #>     5:                                   Reproductive hormone analyses
    #>    ---
    #> 87588:                                 Accidental exposures to product
    #> 87589:                                 Accidental exposures to product
    #> 87590:                                      Haematologic neoplasms NEC
    #> 87591:                                      Haematologic neoplasms NEC
    #> 87592:                                            Plasma cell myelomas
    #>        hlgt_code
    #>            <int>
    #>     1:  10024967
    #>     2:  10027424
    #>     3:  10014706
    #>     4:  10014706
    #>     5:  10014706
    #>    ---
    #> 87588:  10079145
    #> 87589:  10079145
    #> 87590:  10018865
    #> 87591:  10018865
    #> 87592:  10035227
    #>                                                                 hlgt_name
    #>                                                                    <char>
    #>     1: Lower respiratory tract disorders (excl obstruction and infection)
    #>     2:                     Metabolic and nutritional disorders congenital
    #>     3:                       Endocrine investigations (incl sex hormones)
    #>     4:                       Endocrine investigations (incl sex hormones)
    #>     5:                       Endocrine investigations (incl sex hormones)
    #>    ---
    #> 87588:          Medication errors and other product use errors and issues
    #> 87589:          Medication errors and other product use errors and issues
    #> 87590:           Haematopoietic neoplasms (excl leukaemias and lymphomas)
    #> 87591:           Haematopoietic neoplasms (excl leukaemias and lymphomas)
    #> 87592:                                              Plasma cell neoplasms
    #>        soc_code
    #>           <int>
    #>     1: 10038738
    #>     2: 10010331
    #>     3: 10022891
    #>     4: 10022891
    #>     5: 10022891
    #>    ---
    #> 87588: 10022117
    #> 87589: 10022117
    #> 87590: 10029104
    #> 87591: 10029104
    #> 87592: 10029104
    #>                                                                   soc_name
    #>                                                                     <char>
    #>     1:                     Respiratory, thoracic and mediastinal disorders
    #>     2:                          Congenital, familial and genetic disorders
    #>     3:                                                      Investigations
    #>     4:                                                      Investigations
    #>     5:                                                      Investigations
    #>    ---
    #> 87588:                      Injury, poisoning and procedural complications
    #> 87589:                      Injury, poisoning and procedural complications
    #> 87590: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #> 87591: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #> 87592: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #>        soc_abbrev primary_soc_fg
    #>            <char>         <char>
    #>     1:       Resp              Y
    #>     2:       Cong              Y
    #>     3:        Inv              Y
    #>     4:        Inv              Y
    #>     5:        Inv              Y
    #>    ---
    #> 87588:      Inj&P              Y
    #> 87589:      Inj&P              Y
    #> 87590:      Neopl              Y
    #> 87591:      Neopl              Y
    #> 87592:      Neopl              Y

The internal will include a `meddra_hierarchy_idx` column that represents the index of the MedDRA hierarchy data in the `indi` and `reac` field when standardized. Additionally, the columns `meddra_hierarchy_from`, `meddra_code`, and `meddra_pt` will also be added which provide standardized names of the original PT (indi: indi_pt; reac: pt) (refer to `ASC_NTS.pdf` or `ASC_NTS.docx` in the FAERS quarterly file for the meanings of the original names, most original names will remain unchanged except for some names different between FAERS quarterly files, see `?faers_parse` for details). We can retrieve this data using the `faers_meddra()` function. When we use `faers_get()` to retrieve `indi` or `reac` data from the standardized `FAERSascii` object, the meddra hierarchy columns are automatically added to the returned data.table.

    faers_get(data, "indi")
    #>       year quarter primaryid indi_drug_seq
    #>      <int>  <char>    <char>         <int>
    #>   1:  2004      q1   4264028    1004493847
    #>   2:  2004      q1   4264028    1004530015
    #>   3:  2004      q1   4264028    1004530020
    #>   4:  2004      q1   4264028    1004530025
    #>   5:  2004      q1   4265584    1004498166
    #>  ---
    #> 352:  2017      q2 136932671             1
    #> 353:  2017      q2 136959401             1
    #> 354:  2017      q2 136970751             1
    #> 355:  2017      q2  93588412             1
    #> 356:  2017      q2  93588412             2
    #>                                       indi_pt   caseid meddra_hierarchy_from
    #>                                        <char>   <char>                <char>
    #>   1:                            BREAST CANCER     <NA>                   llt
    #>   2:                            BREAST CANCER     <NA>                   llt
    #>   3:                            BREAST CANCER     <NA>                   llt
    #>   4:                            BREAST CANCER     <NA>                   llt
    #>   5: ATTENTION DEFICIT/HYPERACTIVITY DISORDER     <NA>                   llt
    #>  ---
    #> 352:                    Psoriatic arthropathy 13693267                   llt
    #> 353:      Product used for unknown indication 13695940                   llt
    #> 354:                          Crohn's disease 13697075                   llt
    #> 355:                   Anti-infective therapy  9358841                   llt
    #> 356:                   Anti-infective therapy  9358841                   llt
    #>      meddra_code                                meddra_pt llt_code
    #>           <char>                                   <char>    <int>
    #>   1:    10006187                            Breast cancer 10006187
    #>   2:    10006187                            Breast cancer 10006187
    #>   3:    10006187                            Breast cancer 10006187
    #>   4:    10006187                            Breast cancer 10006187
    #>   5:    10003736 Attention deficit/hyperactivity disorder 10003736
    #>  ---
    #> 352:    10037162                    Psoriatic arthropathy 10037162
    #> 353:    10070592      Product used for unknown indication 10070592
    #> 354:    10011401                          Crohn's disease 10011401
    #> 355:    10058316                   Anti-infective therapy 10058316
    #> 356:    10058316                   Anti-infective therapy 10058316
    #>                                      llt_name  pt_code
    #>                                        <char>    <int>
    #>   1:                            Breast cancer 10006187
    #>   2:                            Breast cancer 10006187
    #>   3:                            Breast cancer 10006187
    #>   4:                            Breast cancer 10006187
    #>   5: Attention deficit/hyperactivity disorder 10083622
    #>  ---
    #> 352:                    Psoriatic arthropathy 10037162
    #> 353:      Product used for unknown indication 10070592
    #> 354:                          Crohn's disease 10011401
    #> 355:                   Anti-infective therapy 10058316
    #> 356:                   Anti-infective therapy 10058316
    #>                                       pt_name hlt_code
    #>                                        <char>    <int>
    #>   1:                            Breast cancer 10006290
    #>   2:                            Breast cancer 10006290
    #>   3:                            Breast cancer 10006290
    #>   4:                            Breast cancer 10006290
    #>   5: Attention deficit hyperactivity disorder 10003730
    #>  ---
    #> 352:                    Psoriatic arthropathy 10037163
    #> 353:      Product used for unknown indication 10027700
    #> 354:                          Crohn's disease 10009888
    #> 355:                   Anti-infective therapy 10002790
    #> 356:                   Anti-infective therapy 10002790
    #>                                                  hlt_name hlgt_code
    #>                                                    <char>     <int>
    #>   1:                Breast and nipple neoplasms malignant  10006291
    #>   2:                Breast and nipple neoplasms malignant  10006291
    #>   3:                Breast and nipple neoplasms malignant  10006291
    #>   4:                Breast and nipple neoplasms malignant  10006291
    #>   5: Attention deficit and disruptive behaviour disorders  10009841
    #>  ---
    #> 352:                              Psoriatic arthropathies  10023213
    #> 353:                           Therapeutic procedures NEC  10043413
    #> 354:                             Colitis (excl infective)  10017969
    #> 355:                              Antiinfective therapies  10043413
    #> 356:                              Antiinfective therapies  10043413
    #>                                                     hlgt_name soc_code
    #>                                                        <char>    <int>
    #>   1: Breast neoplasms malignant and unspecified (incl nipple) 10029104
    #>   2: Breast neoplasms malignant and unspecified (incl nipple) 10029104
    #>   3: Breast neoplasms malignant and unspecified (incl nipple) 10029104
    #>   4: Breast neoplasms malignant and unspecified (incl nipple) 10029104
    #>   5:       Cognitive and attention disorders and disturbances 10037175
    #>  ---
    #> 352:                                          Joint disorders 10028395
    #> 353:           Therapeutic procedures and supportive care NEC 10042613
    #> 354:                 Gastrointestinal inflammatory conditions 10017947
    #> 355:           Therapeutic procedures and supportive care NEC 10042613
    #> 356:           Therapeutic procedures and supportive care NEC 10042613
    #>                                                                 soc_name
    #>                                                                   <char>
    #>   1: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #>   2: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #>   3: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #>   4: Neoplasms benign, malignant and unspecified (incl cysts and polyps)
    #>   5:                                               Psychiatric disorders
    #>  ---
    #> 352:                     Musculoskeletal and connective tissue disorders
    #> 353:                                     Surgical and medical procedures
    #> 354:                                          Gastrointestinal disorders
    #> 355:                                     Surgical and medical procedures
    #> 356:                                     Surgical and medical procedures
    #>      soc_abbrev primary_soc_fg
    #>          <char>         <char>
    #>   1:      Neopl              Y
    #>   2:      Neopl              Y
    #>   3:      Neopl              Y
    #>   4:      Neopl              Y
    #>   5:      Psych              Y
    #>  ---
    #> 352:       Musc              Y
    #> 353:       Surg              Y
    #> 354:      Gastr              Y
    #> 355:       Surg              Y
    #> 356:       Surg              Y

    faers_get(data, "reac")
    #>       year quarter primaryid                               pt     v3   caseid
    #>      <int>  <char>    <char>                           <char> <lgcl>   <char>
    #>   1:  2004      q1   4263742                        DIARRHOEA     NA     <NA>
    #>   2:  2004      q1   4263742             INTENTIONAL OVERDOSE     NA     <NA>
    #>   3:  2004      q1   4263742                        MYDRIASIS     NA     <NA>
    #>   4:  2004      q1   4263742                           NAUSEA     NA     <NA>
    #>   5:  2004      q1   4263742         PLATELET COUNT INCREASED     NA     <NA>
    #>  ---
    #> 698:  2017      q2 136959401          Injection site reaction     NA 13695940
    #> 699:  2017      q2 136970751           Intestinal obstruction     NA 13697075
    #> 700:  2017      q2  93588412 Generalised tonic-clonic seizure     NA  9358841
    #> 701:  2017      q2  93588412               Petit mal epilepsy     NA  9358841
    #> 702:  2017      q2  93588412                              Tic     NA  9358841
    #>      drug_rec_act meddra_hierarchy_from meddra_code
    #>            <lgcl>                <char>      <char>
    #>   1:           NA                   llt    10012735
    #>   2:           NA                   llt    10022523
    #>   3:           NA                   llt    10028521
    #>   4:           NA                   llt    10028813
    #>   5:           NA                   llt    10051608
    #>  ---
    #> 698:           NA                   llt    10022095
    #> 699:           NA                   llt    10022687
    #> 700:           NA                   llt    10018100
    #> 701:           NA                   llt    10034759
    #> 702:           NA                   llt    10043833
    #>                             meddra_pt llt_code                         llt_name
    #>                                <char>    <int>                           <char>
    #>   1:                        Diarrhoea 10012735                        Diarrhoea
    #>   2:             Intentional overdose 10022523             Intentional overdose
    #>   3:                        Mydriasis 10028521                        Mydriasis
    #>   4:                           Nausea 10028813                           Nausea
    #>   5:         Platelet count increased 10051608         Platelet count increased
    #>  ---
    #> 698:          Injection site reaction 10022095          Injection site reaction
    #> 699:           Intestinal obstruction 10022687           Intestinal obstruction
    #> 700: Generalised tonic-clonic seizure 10018100 Generalised tonic-clonic seizure
    #> 701:               Petit mal epilepsy 10034759               Petit mal epilepsy
    #> 702:                              Tic 10043833                              Tic
    #>       pt_code                          pt_name hlt_code
    #>         <int>                           <char>    <int>
    #>   1: 10012735                        Diarrhoea 10012736
    #>   2: 10022523             Intentional overdose 10076292
    #>   3: 10028521                        Mydriasis 10037514
    #>   4: 10028813                           Nausea 10028817
    #>   5: 10051608         Platelet count increased 10035523
    #>  ---
    #> 698: 10022095          Injection site reaction 10022097
    #> 699: 10022687           Intestinal obstruction 10018009
    #> 700: 10018100 Generalised tonic-clonic seizure 10018101
    #> 701: 10034759               Petit mal epilepsy 10000332
    #> 702: 10043833                              Tic 10043835
    #>                                           hlt_name hlgt_code
    #>                                             <char>     <int>
    #>   1:                    Diarrhoea (excl infective)  10017977
    #>   2:                                 Overdoses NEC  10079159
    #>   3:                               Pupil disorders  10030061
    #>   4:                  Nausea and vomiting symptoms  10018012
    #>   5:                             Platelet analyses  10018851
    #>  ---
    #> 698:                      Injection site reactions  10001316
    #> 699: Gastrointestinal stenosis and obstruction NEC  10018008
    #> 700:             Generalised tonic-clonic seizures  10039911
    #> 701:                              Absence seizures  10039911
    #> 702:                                 Tic disorders  10008401
    #>                                                 hlgt_name soc_code
    #>                                                    <char>    <int>
    #>   1: Gastrointestinal motility and defaecation conditions 10017947
    #>   2:                         Overdoses and underdoses NEC 10022117
    #>   3:                       Ocular neuromuscular disorders 10015919
    #>   4:                  Gastrointestinal signs and symptoms 10017947
    #>   5:       Haematology investigations (incl blood groups) 10022891
    #>  ---
    #> 698:                        Administration site reactions 10018065
    #> 699:            Gastrointestinal stenosis and obstruction 10017947
    #> 700:                             Seizures (incl subtypes) 10029205
    #> 701:                             Seizures (incl subtypes) 10029205
    #> 702:                         Changes in physical activity 10037175
    #>                                                  soc_name soc_abbrev
    #>                                                    <char>     <char>
    #>   1:                           Gastrointestinal disorders      Gastr
    #>   2:       Injury, poisoning and procedural complications      Inj&P
    #>   3:                                        Eye disorders        Eye
    #>   4:                           Gastrointestinal disorders      Gastr
    #>   5:                                       Investigations        Inv
    #>  ---
    #> 698: General disorders and administration site conditions      Genrl
    #> 699:                           Gastrointestinal disorders      Gastr
    #> 700:                             Nervous system disorders       Nerv
    #> 701:                             Nervous system disorders       Nerv
    #> 702:                                Psychiatric disorders      Psych
    #>      primary_soc_fg
    #>              <char>
    #>   1:              Y
    #>   2:              Y
    #>   3:              Y
    #>   4:              Y
    #>   5:              Y
    #>  ---
    #> 698:              Y
    #> 699:              Y
    #> 700:              Y
    #> 701:              Y
    #> 702:              Y

One limitation of FAERS database is duplicate and incomplete reports. There are many instances of duplicative reports and some reports do not contain all the necessary information. We deemed two cases to be identical if they exhibited a full concordance across drugs administered, and adverse reactions and but showed discrepancies in one or none of the following fields: gender, age, reporting country, event date, start date, and drug indications.

    data <- faers_dedup(data)
    #> → deduplication from the same source by retain the most recent report
    #> → merging `drug`, `indi`, `ther`, and `reac` data
    #> → deduplication from multiple sources by matching gender, age, reporting country, event date, start date, drug indications, drugs administered, and adverse reactions

    data
    #> Standardized and De-duplicated FAERS data from 2 Quarterly ascii files
    #>   Total unique reports: 200

### 0.3.4 Pharmacovigilance analysis

Pharmacovigilance is the science and activities relating to the detection, assessment, understanding and prevention of adverse effects or any other medicine/vaccine related problem.

To mine the signals of “insulin”, we start by using the `faers_filter()` function. In this function, the `.fn` argument should be a function that accepts data specified in `.field`. It is important to note that `.fn` should always return the `primaryid` that you want to keep.

To enhance our analysis, it would be advantageous to include all drug synonym names for `insulin`. These synonyms can be obtained by querying sources such as https://go.drugbank.com/ or alternative databases. Furthermore, we extract the brand names of insulin from the Drugs@FDA dataset, which can be easily obtained using the `fda_drugs()` function.

    insulin_names <- "insulin"
    insulin_pattern <- paste(insulin_names, collapse = "|")
    fda_insulin <- fda_drugs()[
        grepl(insulin_pattern, ActiveIngredient, ignore.case = TRUE)
    ]
    #> → Reading html:
    #>   <https://www.fda.gov/drugs/drug-approvals-and-databases/drugsfda-data-files>
    #> Downloading 1 file from: <https://www.fda.gov/media/89850/download?attachment>
    #> Warning: One or more parsing issues, call `problems()` on your data frame for details,
    #> e.g.:
    #>   dat <- vroom(...)
    #>   problems(dat)

    insulin_pattern <- paste0(
        unique(tolower(c(insulin_names, fda_insulin$DrugName))),
        collapse = "|"
    )
    insulin_data <- faers_filter(data, .fn = function(x) {
        idx <- grepl(insulin_pattern, x$drugname, ignore.case = TRUE) |
            grepl(insulin_pattern, x$prod_ai, ignore.case = TRUE)
        x[idx, primaryid]
    }, .field = "drug")
    insulin_data
    #> Standardized and De-duplicated FAERS data from 2 Quarterly ascii files
    #>   Total unique reports: 3

Then, signal can be easily obtained with `faers_phv_signal()` which internally use `faers_phv_table()` to create a contingency table and use `phv_signal()` to do signal analysis specified in `.methods` argument. By default, all supported signal analysis methods will be run, including “ror”, “prr”, “chisq”, “bcpnn_norm”, “bcpnn_mcmc”, “obsexp_shrink”, “fisher”, and “ebgm”.

The most important argument for this function is `.object`, which should be a de-duplicated FAERSascii object containing the data for the drugs or traits of interest. Additionally, you must specify either `.full`, which represents the background distributions data (usually the entire FAERS data), or you can specify `.object2`, which should be the control data or another drug of interest for comparison.

    insulin_signals <- faers_phv_signal(insulin_data,
        .full = data,
        BPPARAM = BiocParallel::SerialParam(RNGseed = 1L)
    )
    #> ℹ Running `phv_ror()`
    #> ℹ Running `phv_prr()`
    #> ℹ Running `phv_chisq()`
    #> ℹ Running `phv_bcpnn_norm()`
    #> ℹ Running `phv_bcpnn_mcmc()`
    #> ℹ Running `phv_obsexp_shrink()`
    #> ℹ Running `phv_fisher()`
    #> ℹ Running `phv_ebgm()`

    insulin_signals
    #> Key: <soc_name>
    #>                                                                soc_name     a
    #>                                                                  <char> <int>
    #>  1:                                Blood and lymphatic system disorders     0
    #>  2:                                                   Cardiac disorders     1
    #>  3:                          Congenital, familial and genetic disorders     0
    #>  4:                                         Ear and labyrinth disorders     0
    #>  5:                                                 Endocrine disorders     0
    #>  6:                                                       Eye disorders     1
    #>  7:                                          Gastrointestinal disorders     1
    #>  8:                General disorders and administration site conditions     1
    #>  9:                                             Hepatobiliary disorders     0
    #> 10:                                             Immune system disorders     0
    #> 11:                                         Infections and infestations     2
    #> 12:                      Injury, poisoning and procedural complications     1
    #> 13:                                                      Investigations     2
    #> 14:                                  Metabolism and nutrition disorders     2
    #> 15:                     Musculoskeletal and connective tissue disorders     0
    #> 16: Neoplasms benign, malignant and unspecified (incl cysts and polyps)     0
    #> 17:                                            Nervous system disorders     2
    #> 18:                                                      Product issues     0
    #> 19:                                               Psychiatric disorders     1
    #> 20:                                         Renal and urinary disorders     1
    #> 21:                            Reproductive system and breast disorders     0
    #> 22:                     Respiratory, thoracic and mediastinal disorders     1
    #> 23:                              Skin and subcutaneous tissue disorders     0
    #> 24:                                                Social circumstances     1
    #> 25:                                     Surgical and medical procedures     0
    #> 26:                                                  Vascular disorders     0
    #>                                                                soc_name     a
    #>         b     c     d expected        ror ror_ci_low ror_ci_high        prr
    #>     <int> <int> <int>    <num>      <num>      <num>       <num>      <num>
    #>  1:     3    14   183    0.210  0.0000000 0.00000000         NaN  0.0000000
    #>  2:     2     7   190    0.120 13.5714286 1.09612571  168.031524  9.3809524
    #>  3:     3     1   196    0.015  0.0000000 0.00000000         NaN  0.0000000
    #>  4:     3     4   193    0.060  0.0000000 0.00000000         NaN  0.0000000
    #>  5:     3     1   196    0.015  0.0000000 0.00000000         NaN  0.0000000
    #>  6:     2     9   188    0.150 10.4444444 0.86432480  126.209985  7.2962963
    #>  7:     2    33   164    0.510  2.4848485 0.21888790   28.208376  1.9898990
    #>  8:     2    79   118    1.200  0.7468354 0.06658895    8.376212  0.8312236
    #>  9:     3     9   188    0.135  0.0000000 0.00000000         NaN  0.0000000
    #> 10:     3     4   193    0.060  0.0000000 0.00000000         NaN  0.0000000
    #> 11:     1    30   167    0.480 11.1333333 0.97846354  126.679335  4.3777778
    #> 12:     2    30   167    0.465  2.7833333 0.24461589   31.669834  2.1888889
    #> 13:     1    30   167    0.480 11.1333333 0.97846354  126.679335  4.3777778
    #> 14:     1    10   187    0.180 37.4000000 3.12161662  448.088336 13.1333333
    #> 15:     3    19   178    0.285  0.0000000 0.00000000         NaN  0.0000000
    #> 16:     3    10   187    0.150  0.0000000 0.00000000         NaN  0.0000000
    #> 17:     1    39   158    0.615  8.1025641 0.71625332   91.659672  3.3675214
    #> 18:     3     8   189    0.120  0.0000000 0.00000000         NaN  0.0000000
    #> 19:     2    31   166    0.480  2.6774194 0.23550079   30.439704  2.1182796
    #> 20:     2    11   186    0.180  8.4545455 0.71063496  100.585171  5.9696970
    #> 21:     3     9   188    0.135  0.0000000 0.00000000         NaN  0.0000000
    #> 22:     2    19   178    0.300  4.6842105 0.40558572   54.099114  3.4561404
    #> 23:     3    21   176    0.315  0.0000000 0.00000000         NaN  0.0000000
    #> 24:     2     3   194    0.060 32.3333333 2.26724805  461.107220 21.8888889
    #> 25:     3     6   191    0.090  0.0000000 0.00000000         NaN  0.0000000
    #> 26:     3    14   183    0.210  0.0000000 0.00000000         NaN  0.0000000
    #>         b     c     d expected        ror ror_ci_low ror_ci_high        prr
    #>     prr_ci_low prr_ci_high        chisq chisq_pvalue bcpnn_norm_ic
    #>          <num>       <num>        <num>        <num>         <num>
    #>  1:  0.0000000         NaN 4.096414e-31  1.000000000   -0.97458175
    #>  2:  1.6173190   54.412435 1.272561e+00  0.259286856    0.63833534
    #>  3:  0.0000000         NaN 1.265951e-26  1.000000000   -0.31739140
    #>  4:  0.0000000         NaN 2.866117e-32  1.000000000   -0.63762418
    #>  5:  0.0000000         NaN 1.265951e-26  1.000000000   -0.31739140
    #>  6:  1.3027676   40.863727 8.727402e-01  0.350197814    0.57607008
    #>  7:  0.3897628   10.159250 6.459270e-31  1.000000000    0.05900067
    #>  8:  0.1662546    4.155871 1.762340e-31  1.000000000   -0.57013768
    #>  9:  0.0000000         NaN 6.503567e-28  1.000000000   -0.83645056
    #> 10:  0.0000000         NaN 2.866117e-32  1.000000000   -0.63762418
    #> 11:  1.8426662   10.400656 2.619652e+00  0.105547591    0.81550390
    #> 12:  0.4272128   11.215100 3.165120e-03  0.955135161    0.11209704
    #> 13:  1.8426662   10.400656 2.619652e+00  0.105547591    0.81550390
    #> 14:  4.8197010   35.787374 1.045469e+01  0.001223383    1.24133970
    #> 15:  0.0000000         NaN 4.555566e-29  1.000000000   -1.09198678
    #> 16:  0.0000000         NaN 2.443333e-31  1.000000000   -0.86662496
    #> 17:  1.4420929    7.863710 1.626328e+00  0.202211729    0.66415657
    #> 18:  0.0000000         NaN 1.154037e-31  1.000000000   -0.80435971
    #> 19:  0.4139549   10.839606 1.007171e-03  0.974682619    0.09415638
    #> 20:  1.0903420   32.684500 6.144172e-01  0.433129486    0.51999218
    #> 21:  0.0000000         NaN 6.503567e-28  1.000000000   -0.83645056
    #> 22:  0.6595182   18.111563 1.504042e-01  0.698149378    0.32882236
    #> 23:  0.0000000         NaN 1.889084e-29  1.000000000   -1.13532142
    #> 24:  3.0987414  154.618730 3.342657e+00  0.067505526    0.80507086
    #> 25:  0.0000000         NaN 2.800437e-31  1.000000000   -0.73169389
    #> 26:  0.0000000         NaN 4.096414e-31  1.000000000   -0.97458175
    #>     prr_ci_low prr_ci_high        chisq chisq_pvalue bcpnn_norm_ic
    #>     bcpnn_norm_ic_ci_low bcpnn_norm_ic_ci_high bcpnn_mcmc_ic
    #>                    <num>                 <num>         <num>
    #>  1:            -4.960069              3.010906   -0.50449401
    #>  2:            -2.239177              3.515848    1.27660894
    #>  3:            -4.844759              4.209977   -0.03947607
    #>  4:            -4.773808              3.498560   -0.16092798
    #>  5:            -4.844759              4.209977   -0.03947607
    #>  6:            -2.270036              3.422176    1.20821022
    #>  7:            -2.690902              2.808903    0.57112278
    #>  8:            -3.294337              2.154062   -0.18051848
    #>  9:            -4.858428              3.185527   -0.34296004
    #> 10:            -4.773808              3.498560   -0.16092798
    #> 11:            -1.546257              3.177265    1.35163975
    #> 12:            -2.641970              2.866165    0.63695385
    #> 13:            -1.546257              3.177265    1.35163975
    #> 14:            -1.203821              3.686501    1.87988617
    #> 15:            -5.059438              2.875465   -0.64969772
    #> 16:            -4.878583              3.145333   -0.37675228
    #> 17:            -1.685783              3.014096    1.16526032
    #> 18:            -4.838659              3.229940   -0.30835356
    #> 19:            -2.658440              2.846753    0.61467416
    #> 20:            -2.304488              3.344472    1.14292058
    #> 21:            -4.858428              3.185527   -0.34296004
    #> 22:            -2.450528              3.108173    0.90790354
    #> 23:            -5.097867              2.827224   -0.70390961
    #> 24:            -2.213625              3.823767    1.42403452
    #> 25:            -4.801687              3.338300   -0.23653305
    #> 26:            -4.960069              3.010906   -0.50449401
    #>     bcpnn_norm_ic_ci_low bcpnn_norm_ic_ci_high bcpnn_mcmc_ic
    #>     bcpnn_mcmc_ic_ci_low bcpnn_mcmc_ic_ci_high    oe_ratio oe_ratio_ci_low
    #>                    <num>                 <num>       <num>           <num>
    #>  1:          -10.3196697             1.7472020 -0.50589093     -10.3196697
    #>  2:           -2.3407525             2.7739578  1.27462238      -2.5084784
    #>  3:          -10.0375795             2.2513770 -0.04264434      -9.9161429
    #>  4:          -10.0323162             2.1241023 -0.16349873     -10.1435381
    #>  5:           -9.9831122             2.2496459 -0.04264434      -9.9410266
    #>  6:           -2.4117140             2.6903211  1.20645088      -2.5766499
    #>  7:           -2.8600902             1.8952952  0.57060721      -3.2124936
    #>  8:           -3.4910011             0.9970158 -0.18057225      -3.9636731
    #>  9:          -10.2612343             1.9149076 -0.34482850     -10.2499302
    #> 10:          -10.0185693             2.1131744 -0.16349873     -10.1629730
    #> 11:           -0.7503787             2.3050676  1.35107444      -1.2419932
    #> 12:           -2.8253479             1.9749895  0.63636165      -3.1467392
    #> 13:           -0.7537848             2.3089207  1.35107444      -1.2419932
    #> 14:           -0.4187463             3.0192617  1.87832144      -0.7147462
    #> 15:          -10.4504516             1.5773569 -0.65076456     -10.4211629
    #> 16:          -10.2368410             1.8774969 -0.37851162     -10.2057785
    #> 17:           -0.9032040             2.0623380  1.16488438      -1.4281833
    #> 18:          -10.2813672             1.9626282 -0.31034012     -10.2449787
    #> 19:           -2.8127986             1.9516284  0.61410885      -3.1689920
    #> 20:           -2.4511852             2.6094964  1.14135585      -2.6417450
    #> 21:          -10.2889044             1.9052123 -0.34482850     -10.2046277
    #> 22:           -2.6154221             2.3120933  0.90689060      -2.8762102
    #> 23:          -10.5466983             1.4934969 -0.70487196     -10.4359087
    #> 24:           -2.2471733             2.9535899  1.42146377      -2.3616371
    #> 25:          -10.1443990             2.0341263 -0.23878686     -10.0607046
    #> 26:          -10.4263109             1.7286382 -0.50589093     -10.3566777
    #>     bcpnn_mcmc_ic_ci_low bcpnn_mcmc_ic_ci_high    oe_ratio oe_ratio_ci_low
    #>     oe_ratio_ci_high odds_ratio odds_ratio_ci_low odds_ratio_ci_high
    #>                <num>      <num>             <num>              <num>
    #>  1:         1.747202  0.0000000        0.00000000           33.68585
    #>  2:         2.962049 13.0303800        0.20150028          279.21542
    #>  3:         2.254056  0.0000000        0.00000000         2462.50000
    #>  4:         2.109325  0.0000000        0.00000000          145.21133
    #>  5:         2.262299  0.0000000        0.00000000         2462.50000
    #>  6:         2.893877 10.1233187        0.15947006          211.87117
    #>  7:         2.258033  2.4701675        0.04089140           48.73410
    #>  8:         1.506854  0.7478897        0.01250834           14.59249
    #>  9:         1.904840  0.0000000        0.00000000           55.53664
    #> 10:         2.113287  0.0000000        0.00000000          145.21133
    #> 11:         2.742477 10.9151800        0.55237709          657.45882
    #> 12:         2.323788  2.7642969        0.04567010           54.61951
    #> 13:         2.742477 10.9151800        0.55237709          657.45882
    #> 14:         3.269724 35.2158110        1.70522393         2176.34560
    #> 15:         1.566959  0.0000000        0.00000000           23.77817
    #> 16:         1.880091  0.0000000        0.00000000           49.24481
    #> 17:         2.556287  7.9848214        0.40614360          479.34125
    #> 18:         1.953706  0.0000000        0.00000000           63.38117
    #> 19:         2.301535  2.6598229        0.04397762           52.53253
    #> 20:         2.828782  8.2451292        0.13145968          170.30399
    #> 21:         1.905756  0.0000000        0.00000000           55.53664
    #> 22:         2.594317  4.6223903        0.07546238           92.88491
    #> 23:         1.495748  0.0000000        0.00000000           21.20022
    #> 24:         3.108890 29.5773686        0.41191588          733.00565
    #> 25:         2.028757  0.0000000        0.00000000           88.65547
    #> 26:         1.739295  0.0000000        0.00000000           33.68585
    #>     oe_ratio_ci_high odds_ratio odds_ratio_ci_low odds_ratio_ci_high
    #>     fisher_pvalue     ebgm ebgm_ci_low ebgm_ci_high
    #>             <num>    <num>       <num>        <num>
    #>  1:    1.00000000      NaN         2.4         2.45
    #>  2:    0.11582153 2.421831         2.4         2.45
    #>  3:    1.00000000      NaN         2.4         2.45
    #>  4:    1.00000000      NaN         2.4         2.45
    #>  5:    1.00000000      NaN         2.4         2.45
    #>  6:    0.14330745 2.421827         2.4         2.45
    #>  7:    0.42998325 2.421786         2.4         2.45
    #>  8:    1.00000000 2.421708         2.4         2.45
    #>  9:    1.00000000      NaN         2.4         2.45
    #> 10:    1.00000000      NaN         2.4         2.45
    #> 11:    0.06722095 2.421837         2.4         2.45
    #> 12:    0.39832191 2.421791         2.4         2.45
    #> 13:    0.06722095 2.421837         2.4         2.45
    #> 14:    0.00961474 2.421871         2.4         2.45
    #> 15:    1.00000000      NaN         2.4         2.45
    #> 16:    1.00000000      NaN         2.4         2.45
    #> 17:    0.10738541 2.421821         2.4         2.45
    #> 18:    1.00000000      NaN         2.4         2.45
    #> 19:    0.40900259 2.421790         2.4         2.45
    #> 20:    0.17021776 2.421824         2.4         2.45
    #> 21:    1.00000000      NaN         2.4         2.45
    #> 22:    0.27222476 2.421810         2.4         2.45
    #> 23:    1.00000000      NaN         2.4         2.45
    #> 24:    0.05909852 2.421837         2.4         2.45
    #> 25:    1.00000000      NaN         2.4         2.45
    #> 26:    1.00000000      NaN         2.4         2.45
    #>     fisher_pvalue     ebgm ebgm_ci_low ebgm_ci_high

The column containing the events of interest can be specified using an atomic character in the `.events` (default: “soc_name”) argument. The combination of all specified columns will define the unique event. Additionally, we can control which field data to find the columns in the `.field` (default: “reac”) argument.

    insulin_signals_hlgt <- faers_phv_signal(
        insulin_data,
        .events = "hlgt_name", .full = data,
        BPPARAM = BiocParallel::SerialParam(RNGseed = 1L)
    )
    #> ℹ Running `phv_ror()`
    #> ℹ Running `phv_prr()`
    #> ℹ Running `phv_chisq()`
    #> ℹ Running `phv_bcpnn_norm()`
    #> ℹ Running `phv_bcpnn_mcmc()`
    #> ℹ Running `phv_obsexp_shrink()`
    #> ℹ Running `phv_fisher()`
    #> ℹ Running `phv_ebgm()`

    insulin_signals_hlgt
    #> Key: <hlgt_name>
    #>                                                       hlgt_name     a     b
    #>                                                          <char> <int> <int>
    #>   1:                                        Acid-base disorders     0     3
    #>   2:                              Administration site reactions     0     3
    #>   3:                                        Allergic conditions     0     3
    #>   4:               Anaemias nonhaemolytic and marrow depression     0     3
    #>   5:                                   Angioedema and urticaria     0     3
    #>  ---
    #> 138:                                 Viral infectious disorders     0     3
    #> 139:                                           Vision disorders     1     2
    #> 140: Vulvovaginal disorders (excl infections and inflammations)     0     3
    #> 141:              Water, electrolyte and mineral investigations     1     2
    #> 142:                                 White blood cell disorders     0     3
    #>          c     d expected   ror ror_ci_low ror_ci_high      prr prr_ci_low
    #>      <int> <int>    <num> <num>      <num>       <num>    <num>      <num>
    #>   1:     1   196    0.015  0.00   0.000000         NaN  0.00000   0.000000
    #>   2:     9   188    0.135  0.00   0.000000         NaN  0.00000   0.000000
    #>   3:     3   194    0.045  0.00   0.000000         NaN  0.00000   0.000000
    #>   4:     2   195    0.030  0.00   0.000000         NaN  0.00000   0.000000
    #>   5:     1   196    0.015  0.00   0.000000         NaN  0.00000   0.000000
    #>  ---
    #> 138:     6   191    0.090  0.00   0.000000         NaN  0.00000   0.000000
    #> 139:     2   195    0.045 48.75   3.038446    782.1638 32.83333   3.971134
    #> 140:     1   196    0.015  0.00   0.000000         NaN  0.00000   0.000000
    #> 141:     1   196    0.030 98.00   4.405403   2180.0503 65.66667   5.249564
    #> 142:     6   191    0.090  0.00   0.000000         NaN  0.00000   0.000000
    #>      prr_ci_high        chisq chisq_pvalue bcpnn_norm_ic bcpnn_norm_ic_ci_low
    #>            <num>        <num>        <num>         <num>                <num>
    #>   1:         NaN 1.265951e-26  1.000000000    -0.3173914            -4.844759
    #>   2:         NaN 6.503567e-28  1.000000000    -0.8364506            -4.858428
    #>   3:         NaN 3.579029e-27  1.000000000    -0.5729454            -4.769182
    #>   4:         NaN 1.292402e-30  1.000000000    -0.4806767            -4.781546
    #>   5:         NaN 1.265951e-26  1.000000000    -0.3173914            -4.844759
    #>  ---
    #> 138:         NaN 2.800437e-31  1.000000000    -0.7316939            -4.801687
    #> 139:    271.4660 4.741741e+00  0.029439266     0.8697497            -2.230719
    #> 140:         NaN 1.265951e-26  1.000000000    -0.3173914            -4.844759
    #> 141:    821.4227 7.550975e+00  0.005997761     0.9620184            -2.278658
    #> 142:         NaN 2.800437e-31  1.000000000    -0.7316939            -4.801687
    #>      bcpnn_norm_ic_ci_high bcpnn_mcmc_ic bcpnn_mcmc_ic_ci_low
    #>                      <num>         <num>                <num>
    #>   1:              4.209977   -0.03947607            -9.937782
    #>   2:              3.185527   -0.34296004           -10.161457
    #>   3:              3.623291   -0.12157646           -10.114495
    #>   4:              3.820193   -0.08111417            -9.959860
    #>   5:              4.209977   -0.03947607            -9.983112
    #>  ---
    #> 138:              3.338300   -0.23653305           -10.224150
    #> 139:              3.970219    1.46338605            -2.208920
    #> 140:              4.209977   -0.03947607            -9.942375
    #> 141:              4.202695    1.50384833            -2.173397
    #> 142:              3.338300   -0.23653305           -10.112947
    #>      bcpnn_mcmc_ic_ci_high    oe_ratio oe_ratio_ci_low oe_ratio_ci_high
    #>                      <num>       <num>           <num>            <num>
    #>   1:              2.274611 -0.04264434       -9.937782         2.274611
    #>   2:              1.902619 -0.34482850      -10.161457         1.902619
    #>   3:              2.156724 -0.12432814      -10.114495         2.156724
    #>   4:              2.218562 -0.08406426       -9.959860         2.218562
    #>   5:              2.249646 -0.04264434       -9.983112         2.249646
    #>  ---
    #> 138:              2.034279 -0.23878686      -10.128830         2.023771
    #> 139:              3.003724  1.46063437       -2.322466         3.148061
    #> 140:              2.257494 -0.04264434      -10.025850         2.252671
    #> 141:              3.063304  1.50089824       -2.282203         3.188325
    #> 142:              2.022509 -0.23878686      -10.081710         2.036689
    #>      odds_ratio odds_ratio_ci_low odds_ratio_ci_high fisher_pvalue     ebgm
    #>           <num>             <num>              <num>         <num>    <num>
    #>   1:    0.00000         0.0000000         2462.50000    1.00000000 3.670936
    #>   2:    0.00000         0.0000000           55.53664    1.00000000 3.459110
    #>   3:    0.00000         0.0000000          213.09160    1.00000000 3.615584
    #>   4:    0.00000         0.0000000          408.94448    1.00000000 3.643050
    #>   5:    0.00000         0.0000000         2462.50000    1.00000000 3.670936
    #>  ---
    #> 138:    0.00000         0.0000000           88.65547    1.00000000 3.535617
    #> 139:   43.06704         0.5524356         1247.00745    0.04454850 4.117845
    #> 140:    0.00000         0.0000000         2462.50000    1.00000000 3.670936
    #> 141:   80.16649         0.8340751         7069.12541    0.02984925 4.149126
    #> 142:    0.00000         0.0000000           88.65547    1.00000000 3.535617
    #>      ebgm_ci_low ebgm_ci_high
    #>            <num>        <num>
    #>   1:        1.66         7.14
    #>   2:        1.56         6.73
    #>   3:        1.63         7.03
    #>   4:        1.65         7.09
    #>   5:        1.66         7.14
    #>  ---
    #> 138:        1.60         6.88
    #> 139:        1.96         7.71
    #> 140:        1.66         7.14
    #> 141:        1.98         7.77
    #> 142:        1.60         6.88

## 0.4 sessionInfo

    sessionInfo()
    #> R version 4.4.1 (2024-06-14 ucrt)
    #> Platform: x86_64-w64-mingw32/x64
    #> Running under: Windows Server 2022 x64 (build 20348)
    #>
    #> Matrix products: default
    #>
    #>
    #> locale:
    #> [1] LC_COLLATE=C
    #> [2] LC_CTYPE=English_United States.utf8
    #> [3] LC_MONETARY=English_United States.utf8
    #> [4] LC_NUMERIC=C
    #> [5] LC_TIME=English_United States.utf8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] faers_1.0.3      BiocStyle_2.32.1
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] gtable_0.3.5        xfun_0.45           bslib_0.7.0
    #>  [4] ggplot2_3.5.1       websocket_1.4.1     processx_3.8.4
    #>  [7] lattice_0.22-6      tzdb_0.4.0          generics_0.1.3
    #> [10] vctrs_0.6.5         tools_4.4.1         ps_1.7.7
    #> [13] curl_5.2.1          parallel_4.4.1      tibble_3.2.1
    #> [16] fansi_1.0.6         pkgconfig_2.0.3     Matrix_1.7-0
    #> [19] data.table_1.15.4   lifecycle_1.0.4     compiler_4.4.1
    #> [22] stringr_1.5.1       MatrixModels_0.5-3  mcmc_0.9-8
    #> [25] munsell_0.5.1       chromote_0.2.0      codetools_0.2-20
    #> [28] SparseM_1.84        quantreg_5.98       htmltools_0.5.8.1
    #> [31] sass_0.4.9          yaml_2.3.8          later_1.3.2
    #> [34] pillar_1.9.0        crayon_1.5.3        jquerylib_0.1.4
    #> [37] MASS_7.3-61         BiocParallel_1.38.0 cachem_1.1.0
    #> [40] tidyselect_1.2.1    rvest_1.0.4         digest_0.6.36
    #> [43] stringi_1.8.4       dplyr_1.1.4         bookdown_0.40
    #> [46] splines_4.4.1       fastmap_1.2.0       grid_4.4.1
    #> [49] archive_1.1.8       colorspace_2.1-0    cli_3.6.3
    #> [52] magrittr_2.0.3      survival_3.7-0      utf8_1.2.4
    #> [55] openEBGM_0.9.1      scales_1.3.0        promises_1.3.0
    #> [58] bit64_4.0.5         rmarkdown_2.27      httr_1.4.7
    #> [61] bit_4.0.5           coda_0.19-4.1       evaluate_0.24.0
    #> [64] knitr_1.47          rlang_1.1.4         MCMCpack_1.7-0
    #> [67] Rcpp_1.0.12         glue_1.7.0          selectr_0.4-2
    #> [70] BiocManager_1.30.23 xml2_1.3.6          vroom_1.6.5
    #> [73] jsonlite_1.8.8      R6_2.5.1