### Installation Source: https://context7.com/wanglabcsu/faers/llms.txt Instructions on how to install the faers package from Bioconductor. ```APIDOC ## Installation Install from Bioconductor. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("faers") ``` ``` -------------------------------- ### Install FAERS Development Version from GitHub Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Install the latest development version of the faers package from GitHub using the 'pak' package manager. Ensure 'pak' is installed first. ```r if (!requireNamespace("pak", quietly = TRUE)) { install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable") } pak::pkg_install("WangLabCSU/faers") ``` -------------------------------- ### Install FAERS from Bioconductor Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Install the stable version of the faers package from Bioconductor. Ensure BiocManager is installed first. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("faers") ``` -------------------------------- ### faers_load() - Load Package Sample Data Source: https://context7.com/wanglabcsu/faers/llms.txt Loads sample data bundled with the faers package for testing and examples. ```APIDOC ## faers_load() - Load Package Sample Data ### Description Loads sample data bundled with the faers package for testing and examples. ### Method `faers_load(name)` ### Parameters #### Path Parameters - **name** (character) - Required - The name of the sample dataset to load (e.g., "irAEs"). ### Request Example ```r # Load immune-related adverse events reference data irAEs_data <- faers_load("irAEs") ``` ### Response #### Success Response (200) - Returns a data.table containing the specified sample dataset. #### Response Example ```r # pt_code pt_name class # 1: 10000636 Adrenal insufficiency Endocrine disorders # 2: 10001551 Alopecia Skin disorders # ... ``` ``` -------------------------------- ### Get MedDRA Version Source: https://context7.com/wanglabcsu/faers/llms.txt Retrieves the version number of the loaded MedDRA dictionary. ```r # Get MedDRA version meddra_version(meddra_data) # [1] "26.0" ``` -------------------------------- ### FAERS PHV Signal Analysis Example Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Demonstrates the use of `faers_phv_signal` to detect signals for 'hlgt_name' events from 'insulin_data'. The function performs various statistical tests including ROR, PRR, and EBGM. ```R 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 a b #> #> 1: Abortions and stillbirth 0 9 #> 2: Acid-base disorders 0 9 #> 3: Administration site reactions 0 9 #> 4: Allergic conditions 1 8 #> 5: Anaemias nonhaemolytic and marrow depression 1 8 #> --- #> 136: Viral infectious disorders 0 9 #> 137: Vision disorders 0 9 #> 138: Vitamin related disorders 0 9 #> 139: Vulvovaginal disorders (excl infections and inflammations) 0 9 #> 140: White blood cell disorders 0 9 #> c d expected ror ror_ci_low ror_ci_high prr prr_ci_low #> #> 1: 1 190 0.045 0.000000 0.0000000 NaN 0.000000 0.0000000 #> 2: 1 190 0.045 0.000000 0.0000000 NaN 0.000000 0.0000000 #> 3: 7 184 0.315 0.000000 0.0000000 NaN 0.000000 0.0000000 #> 4: 3 188 0.180 7.833333 0.7313919 83.89635 7.074074 0.8140454 #> 5: 2 189 0.135 11.812500 0.9671714 144.27139 10.611111 1.0580416 #> --- #> 136: 5 186 0.225 0.000000 0.0000000 NaN 0.000000 0.0000000 #> 137: 2 189 0.090 0.000000 0.0000000 NaN 0.000000 0.0000000 #> 138: 1 190 0.045 0.000000 0.0000000 NaN 0.000000 0.0000000 ``` -------------------------------- ### Get FAERS Data by Reaction Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Use faers_get to retrieve FAERS data filtered by reaction codes. Requires the 'data' object to be pre-loaded. ```R faers_get(data, "reac") ``` -------------------------------- ### Get FAERS Data by Drug Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Use faers_get to retrieve FAERS data filtered by drug information. Requires the 'data' object to be pre-loaded. ```R faers_get(data, "drug") ``` -------------------------------- ### Get FAERS Metadata (Internal Copy) Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Retrieves FAERS metadata using an internal copy associated with the package. This is useful for offline access or consistent results. ```R faers_meta(internal = TRUE) ``` -------------------------------- ### Get FAERS Metadata Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Retrieves FAERS metadata, defaulting to cached data. If cache is unavailable, it parses metadata from the official FDA website. ```R faers_meta() ``` -------------------------------- ### Download and Load FDA Drugs Database with fda_drugs() Source: https://context7.com/wanglabcsu/faers/llms.txt Downloads and parses the FDA Drugs@FDA database. Can list available files, load default 'Products.txt', load files matching a pattern, or force a refresh from the FDA. ```r # List available files in Drugs@FDA dataset fda_drugs(list = TRUE) # [1] "Products.txt" "Submissions.txt" ... # Load Products data (default) products <- fda_drugs() # ApplNo ProductNo Form Strength ReferenceDrug DrugName ... # Load specific file pattern submissions <- fda_drugs(pattern = "Submissions") # Force refresh from FDA products <- fda_drugs(force = TRUE) ``` -------------------------------- ### faers_meta() - List Available FAERS Data Source: https://context7.com/wanglabcsu/faers/llms.txt Lists metadata for all FAERS databases currently available for download, including years, quarters, file URLs, and file sizes. ```APIDOC ## faers_meta() - List Available FAERS Data Lists metadata for all FAERS databases currently available for download, including years, quarters, file URLs, and file sizes. ```r # Get FAERS metadata (uses cache by default) metadata <- faers_meta() # year quarter period ascii_urls ascii_file_size ... # 1: 2024 q3 July - September https://fis.fda.gov/.../faers_ascii_2024q3.zip 82MB # 2: 2024 q2 April - June https://fis.fda.gov/.../faers_ascii_2024q2.zip 79MB # ... # Force refresh metadata from FDA website metadata <- faers_meta(force = TRUE) # Use internal cached metadata (no internet required) metadata <- faers_meta(internal = TRUE) ``` ``` -------------------------------- ### Check data availability with faers_available() Source: https://context7.com/wanglabcsu/faers/llms.txt Verifies if FAERS data for specific years and quarters are available for download. ```r # Check single year/quarter combination faers_available(2023, "q1") # [1] TRUE # Check multiple combinations faers_available(c(2011, 2023), c("q1", "q2")) # [1] TRUE TRUE # Check future/unavailable data faers_available(2030, "q1") # [1] FALSE ``` -------------------------------- ### Load MedDRA Dictionary with meddra() Source: https://context7.com/wanglabcsu/faers/llms.txt Loads MedDRA (Medical Dictionary for Regulatory Activities) data. Optionally includes Standardised MedDRA Queries (SMQ). Requires a valid MedDRA subscription and path. ```r # Load MedDRA hierarchy data meddra_data <- meddra("/path/to/MedDRA") # Hierarchy data for MedDRA (version 26.0) # Include SMQ (Standardised MedDRA Queries) meddra_data <- meddra("/path/to/MedDRA", add_smq = TRUE) # Hierarchy and SMQs data for MedDRA (version 26.0) ``` -------------------------------- ### Load FAERS Package Sample Data with faers_load() Source: https://context7.com/wanglabcsu/faers/llms.txt Loads sample data bundled with the faers package, such as immune-related adverse events (irAEs) reference data, useful for filtering and testing. ```r # Load immune-related adverse events reference data irAEs <- faers_load("irAEs") # pt_code pt_name class # 1: 10000636 Adrenal insufficiency Endocrine disorders # 2: 10001551 Alopecia Skin disorders # ... # This data is useful for filtering ICI-related adverse events ``` -------------------------------- ### Load faers library Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Load the faers package into the R session to begin pharmacovigilance analysis. ```R library(faers) ``` -------------------------------- ### faers_download() - Download FAERS Data Files Source: https://context7.com/wanglabcsu/faers/llms.txt Downloads FAERS data for selected years and quarters without parsing. Useful when you want to download first and parse later. ```APIDOC ## faers_download() - Download FAERS Data Files Downloads FAERS data for selected years and quarters without parsing. Useful when you want to download first and parse later. ```r # Download ASCII format (default) files <- faers_download( years = 2023, quarters = c("q1", "q2"), dir = "./faers_data" ) # Finding 2 files already downloaded: faers_ascii_2023q1.zip, faers_ascii_2023q2.zip # or # Downloading 2 files # Download XML format (only available from 2012q4 onwards) files <- faers_download( years = 2023, quarters = "q1", format = "xml", dir = "./faers_data" ) ``` ``` -------------------------------- ### faers_available() - Check Data Availability Source: https://context7.com/wanglabcsu/faers/llms.txt Check if FAERS data for specific years and quarters are available for download. ```APIDOC ## faers_available() - Check Data Availability Check if FAERS data for specific years and quarters are available for download. ```r # Check single year/quarter combination faers_available(2023, "q1") # [1] TRUE # Check multiple combinations faers_available(c(2011, 2023), c("q1", "q2")) # [1] TRUE TRUE # Check future/unavailable data faers_available(2030, "q1") # [1] FALSE ``` ``` -------------------------------- ### Commit Changes Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Stage and commit your code changes with a descriptive message. ```git git commit -m 'Add some AmazingFeature' ``` -------------------------------- ### Create a New Feature Branch Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Use this command to create a new branch for your feature development. ```git git checkout -b feature/AmazingFeature ``` -------------------------------- ### Load FAERS Data with faers() Source: https://context7.com/wanglabcsu/faers/llms.txt Loads FAERS data for a specified year and quarter. Requires specifying the directory and an optional compression directory. ```r data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) ``` -------------------------------- ### Run Disproportionality Analysis with phv_signal Source: https://context7.com/wanglabcsu/faers/llms.txt Performs disproportionality analysis using contingency table values. Can run all methods or specific ones like ROR and PRR. Requires a, b, c, d counts. ```r # Using contingency table values: a=n11, b=n10, c=n01, d=n00 # a: event of interest under exposure of interest # b: not event of interest under exposure of interest # c: event of interest under not exposure of interest # d: not event of interest under not exposure of interest # Run all methods results <- phv_signal(a = 122, b = 1320, c = 381, d = 31341) # expected ror ror_ci_low ror_ci_high prr prr_ci_low prr_ci_high ... # 1: 42.34 7.89 6.23 9.98 6.71 5.58 8.07 # Run specific methods ror_result <- phv_signal(122, 1320, 381, 31341, methods = "ror") prr_result <- phv_signal(122, 1320, 381, 31341, methods = "prr") ``` -------------------------------- ### Download FAERS files with faers_download() Source: https://context7.com/wanglabcsu/faers/llms.txt Downloads raw FAERS data files without parsing. Supports both ASCII and XML formats. ```r # Download ASCII format (default) files <- faers_download( years = 2023, quarters = c("q1", "q2"), dir = "./faers_data" ) # Finding 2 files already downloaded: faers_ascii_2023q1.zip, faers_ascii_2023q2.zip # or # Downloading 2 files # Download XML format (only available from 2012q4 onwards) files <- faers_download( years = 2023, quarters = "q1", format = "xml", dir = "./faers_data" ) ``` -------------------------------- ### Download and Parse Single FAERS Quarterly Data Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Downloads and parses a single quarterly data file. Ensure the directory path is correctly specified for your environment. ```R # Please make sure to replace dir with your own directory path, as the file # included in the package is a sampled version. data1 <- faers(2004, "q1", dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) #> data1 #> ``` -------------------------------- ### Basic FAERS Pharmacovigilance Workflow Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Demonstrates a basic pharmacovigilance analysis for Aspirin using the faers package. This includes downloading and parsing data, standardization, deduplication, and signal detection. Ensure MedDRA dictionary is available for standardization. ```r library(faers) # 1. Download and Parse Data (2023 Q1-Q2) # Note: Ensure you have enough disk space in the target directory data <- faers(2023, c("q1", "q2"), dir = "./faers_data") # 2. Standardization (Requires MedDRA dictionary) data_stand <- faers_standardize(data, meddra_path = "path/to/MedDRA") # 3. Deduplication (Requires Standardized data) data_dedup <- faers_dedup(data_stand) # 4.Signal Detection (Data screening for items of interest is needed, such as "aspirin".) results <- faers_phv_signal( faers_filter(data_dedup, .fn = ~ drugname == "aspirin"), .full = data_dedup ) ``` -------------------------------- ### Retrieve FAERS metadata with faers_meta() Source: https://context7.com/wanglabcsu/faers/llms.txt Lists available FAERS databases, including URLs and file sizes. Supports refreshing from the FDA website or using internal cached data. ```r # Get FAERS metadata (uses cache by default) metadata <- faers_meta() # year quarter period ascii_urls ascii_file_size ... # 1: 2024 q3 July - September https://fis.fda.gov/.../faers_ascii_2024q3.zip 82MB # 2: 2024 q2 April - June https://fis.fda.gov/.../faers_ascii_2024q2.zip 79MB # ... # Force refresh metadata from FDA website metadata <- faers_meta(force = TRUE) # Use internal cached metadata (no internet required) metadata <- faers_meta(internal = TRUE) ``` -------------------------------- ### meddra() - Load MedDRA Dictionary Source: https://context7.com/wanglabcsu/faers/llms.txt Loads MedDRA (Medical Dictionary for Regulatory Activities) data for terminology standardization. Requires a valid MedDRA subscription. ```APIDOC ## meddra() - Load MedDRA Dictionary ### Description Loads MedDRA (Medical Dictionary for Regulatory Activities) data for terminology standardization. Requires a valid MedDRA subscription. ### Method `meddra(path, add_smq = FALSE)` ### Parameters #### Path Parameters - **path** (character) - Required - The file path to the MedDRA data directory. - **add_smq** (logical) - Optional - Whether to include Standardised MedDRA Queries (SMQ) data. Defaults to FALSE. ### Request Example ```r # Load MedDRA hierarchy data meddra_data <- meddra("/path/to/MedDRA") # Include SMQ (Standardised MedDRA Queries) meddra_data_with_smq <- meddra("/path/to/MedDRA", add_smq = TRUE) ``` ### Response #### Success Response (200) - Returns a list containing MedDRA hierarchy and optionally SMQ data. #### Response Example ``` # Hierarchy data for MedDRA (version 26.0) # Hierarchy and SMQs data for MedDRA (version 26.0) ``` ## Helper functions for MedDRA data ### meddra_hierarchy() #### Description Extracts hierarchy data from the loaded MedDRA object. #### Method `meddra_hierarchy(meddra_object)` #### Response Example ```r # llt_code llt_name pt_code pt_name ... ``` ### meddra_smq() #### Description Extracts SMQ data from the loaded MedDRA object (if `add_smq` was TRUE). #### Method `meddra_smq(meddra_object)` #### Response Example ```r # SMQ data table ``` ### meddra_version() #### Description Retrieves the version of the loaded MedDRA data. #### Method `meddra_version(meddra_object)` #### Response Example ```r # [1] "26.0" ``` ``` -------------------------------- ### Parse FAERS files with faers_parse() Source: https://context7.com/wanglabcsu/faers/llms.txt Parses downloaded FAERS zip files or directories into R objects. Supports ASCII and XML formats. ```r # Parse from zip file data <- faers_parse( path = "./faers_data/faers_ascii_2023q1.zip", compress_dir = tempdir() ) # Parse from uncompressed directory data <- faers_parse( path = "./faers_data/ascii/", format = "ascii", year = 2023, quarter = "q1" ) # Parse sample data included in the package data <- faers_parse( system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"), compress_dir = tempdir() ) ``` -------------------------------- ### faers_parse() - Parse Downloaded FAERS Files Source: https://context7.com/wanglabcsu/faers/llms.txt Parses FAERS quarterly data from downloaded zip files or uncompressed directories. Supports both ASCII and XML formats. ```APIDOC ## faers_parse() - Parse Downloaded FAERS Files Parses FAERS quarterly data from downloaded zip files or uncompressed directories. Supports both ASCII and XML formats. ```r # Parse from zip file data <- faers_parse( path = "./faers_data/faers_ascii_2023q1.zip", compress_dir = tempdir() ) # Parse from uncompressed directory data <- faers_parse( path = "./faers_data/ascii/", format = "ascii", year = 2023, quarter = "q1" ) # Parse sample data included in the package data <- faers_parse( system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"), compress_dir = tempdir() ) ``` ``` -------------------------------- ### faers() - Download and Parse FAERS Quarterly Data Source: https://context7.com/wanglabcsu/faers/llms.txt The main entry point function that downloads and parses FAERS quarterly data files in a single call. It handles both the download and parsing process automatically, combining multiple quarters when specified. ```APIDOC ## faers() - Download and Parse FAERS Quarterly Data The main entry point function that downloads and parses FAERS quarterly data files in a single call. It handles both the download and parsing process automatically, combining multiple quarters when specified. ```r library(faers) # Download and parse a single quarter data <- faers(2023, "q1", dir = "./faers_data") # Download and parse multiple quarters data <- faers(2023, c("q1", "q2"), dir = "./faers_data") # Download multiple years and quarters data <- faers(c(2022, 2023), c("q4", "q1"), dir = "./faers_data") # Use existing downloaded files (from package samples) data <- faers( 2004, "q1", dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) # FAERS data from 1 Quarterly ascii file # Total reports: 100 (with duplicates) ``` ``` -------------------------------- ### phv_signal() - Low-Level Disproportionality Analysis Source: https://context7.com/wanglabcsu/faers/llms.txt Performs disproportionality analysis on contingency table values directly. Useful for custom analyses or when working with pre-computed counts. ```APIDOC ## phv_signal() - Low-Level Disproportionality Analysis ### Description Performs disproportionality analysis on contingency table values directly. Useful for custom analyses or when working with pre-computed counts. ### Method `phv_signal(a, b, c, d, methods = "all", ...)` ### Parameters #### Path Parameters - **a** (numeric) - Required - Event of interest under exposure of interest (n11) - **b** (numeric) - Required - Not event of interest under exposure of interest (n10) - **c** (numeric) - Required - Event of interest under not exposure of interest (n01) - **d** (numeric) - Required - Not event of interest under not exposure of interest (n00) - **methods** (character vector) - Optional - Methods to run (e.g., "ror", "prr", "bcpnn_norm", "ebgm"). Defaults to "all". ### Request Example ```r # Using contingency table values: a=n11, b=n10, c=n01, d=n00 # Run all methods results <- phv_signal(a = 122, b = 1320, c = 381, d = 31341) # Run specific methods ror_result <- phv_signal(122, 1320, 381, 31341, methods = "ror") ``` ### Response #### Success Response (200) - Returns a data.table with disproportionality metrics (e.g., expected, ror, prr) and their confidence intervals. #### Response Example ``` # expected ror ror_ci_low ror_ci_high prr prr_ci_low prr_ci_high # 1: 42.34 7.89 6.23 9.98 6.71 5.58 8.07 ``` ## Individual Method Functions ### phv_ror() #### Description Calculates the Reporting Odds Ratio (ROR). #### Method `phv_ror(a, b, c, d)` #### Response Example ``` # ror ci_low ci_high # 1: 7.8903 6.2276 9.9987 ``` ### phv_prr() #### Description Calculates the Proportional Reporting Ratio (PRR). #### Method `phv_prr(a, b, c, d)` #### Response Example ``` # prr ci_low ci_high # 1: 6.7125 5.5787 8.0785 ``` ### phv_bcpnn_norm() #### Description Calculates the Bayesian Confidence Propagation Neural Network (BCPNN) normalized score. #### Method `phv_bcpnn_norm(a, b, c, d)` #### Response Example ``` # ic ci_low ci_high # 1: 2.6801 2.2891 3.0711 ``` ### phv_ebgm() #### Description Calculates the Empirical Bayes Geometric Mean (EBGM). #### Method `phv_ebgm(a, b, c, d)` #### Response Example ``` # ebgm ci_low ci_high # 1: 2.879 2.392 3.451 ``` ``` -------------------------------- ### athena() - Access ATHENA Drug Vocabularies Source: https://context7.com/wanglabcsu/faers/llms.txt Reads and parses ATHENA VOCABULARIES data for drug standardization using OMOP vocabulary concepts. ```APIDOC ## athena() - Access ATHENA Drug Vocabularies ### Description Reads and parses ATHENA VOCABULARIES data for drug standardization using OMOP vocabulary concepts. ### Method `athena(use, url = NULL, ...)` ### Parameters #### Path Parameters - **use** (character or character vector) - Required - Specifies which vocabulary file(s) to load (e.g., "concept", "domain", "concept_synonym"). - **url** (character) - Optional - The URL to download the ATHENA data from. Required on the first run if data is not cached. - **...** - Additional arguments passed to underlying functions. ### Request Example ```r # List available vocabularies vocab_files <- athena(list = TRUE) # Load concept data (requires URL on first run) concept_data <- athena( use = "concept", url = "https://athena.ohdsi.org/..." # Replace with actual URL ) # Load multiple vocabulary files vocab_data <- athena(use = c("concept", "concept_synonym")) # Use cached data (if previously downloaded) vocab_data_cached <- athena(use = "concept") ``` ### Response #### Success Response (200) - Returns a data.table (or a list of data.tables if multiple `use` values are provided) containing the requested ATHENA vocabulary data. #### Response Example ```r # concept data table # concept_synonym data table ``` ``` -------------------------------- ### Download and parse FAERS data with faers() Source: https://context7.com/wanglabcsu/faers/llms.txt The primary function for downloading and parsing FAERS quarterly data in one step. It supports single or multiple quarters and years, and can utilize local files. ```r library(faers) # Download and parse a single quarter data <- faers(2023, "q1", dir = "./faers_data") # Download and parse multiple quarters data <- faers(2023, c("q1", "q2"), dir = "./faers_data") # Download multiple years and quarters data <- faers(c(2022, 2023), c("q4", "q1"), dir = "./faers_data") # Use existing downloaded files (from package samples) data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) # FAERS data from 1 Quarterly ascii file # Total reports: 100 (with duplicates) ``` -------------------------------- ### Load Standardized FAERS Data Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Reads a pre-standardized FAERS dataset from the package's internal storage. ```R data <- readRDS(system.file("extdata", "standardized_data.rds", package = "faers")) data ``` -------------------------------- ### Access ATHENA Drug Vocabularies with athena() Source: https://context7.com/wanglabcsu/faers/llms.txt Reads and parses ATHENA VOCABULARIES data for drug standardization. Can list available vocabularies, load specific ones (e.g., 'concept'), multiple files, or use cached data. ```r # List available vocabularies athena(list = TRUE) # [1] "concept.csv" "domain.csv" "concept_class.csv" ... # Load concept data (requires URL on first run) concept_data <- athena( use = "concept", url = "https://athena.ohdsi.org/..." # Your download URL ) # Load multiple vocabulary files vocab_data <- athena(use = c("concept", "concept_synonym")) # Use cached data vocab_data <- athena(use = "concept") # Uses previously cached data ``` -------------------------------- ### faers_combine() - Combine Multiple FAERS Objects Source: https://context7.com/wanglabcsu/faers/llms.txt Combines multiple FAERSascii or FAERSxml objects from different quarterly files into a single object. Objects must not be de-duplicated before combining. ```APIDOC ## faers_combine() - Combine Multiple FAERS Objects Combines multiple FAERSascii or FAERSxml objects from different quarterly files into a single object. Objects must not be de-duplicated before combining. ```r # Parse two separate quarterly files data1 <- faers_parse( system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"), compress_dir = tempdir() ) data2 <- faers_parse( system.file("extdata", "faers_ascii_2017q2.zip", package = "faers"), compress_dir = tempdir() ) # Combine into single object combined_data <- faers_combine(data1, data2) # Combining all 2 FAERS Datas # FAERS data from 2 Quarterly ascii files ``` ``` -------------------------------- ### fda_drugs() - Access FDA Drug Database Source: https://context7.com/wanglabcsu/faers/llms.txt Downloads and parses the FDA Drugs@FDA database for drug product information. ```APIDOC ## fda_drugs() - Access FDA Drug Database ### Description Downloads and parses the FDA Drugs@FDA database for drug product information. ### Method `fda_drugs(list = FALSE, pattern = NULL, force = FALSE)` ### Parameters #### Path Parameters - **list** (logical) - Optional - If TRUE, lists available files in the dataset instead of downloading. Defaults to FALSE. - **pattern** (character) - Optional - A pattern to filter the files to download/load. If NULL, loads the default 'Products.txt'. - **force** (logical) - Optional - If TRUE, forces a refresh of the data from the FDA website. Defaults to FALSE. ### Request Example ```r # List available files in Drugs@FDA dataset file_list <- fda_drugs(list = TRUE) # Load Products data (default) products_data <- fda_drugs() # Load specific file pattern (e.g., Submissions) submissions_data <- fda_drugs(pattern = "Submissions") # Force refresh from FDA products_refreshed <- fda_drugs(force = TRUE) ``` ### Response #### Success Response (200) - Returns a data.table containing the requested FDA drug information. #### Response Example ```r # ApplNo ProductNo Form Strength ReferenceDrug DrugName ... ``` ``` -------------------------------- ### Extract Multiple Fields from FAERS Data with faers_mget() Source: https://context7.com/wanglabcsu/faers/llms.txt Extracts multiple specified fields from FAERS data simultaneously. Returns a list containing the requested data tables. ```r # Extract multiple fields at once fields <- faers_mget(data, c("demo", "drug", "reac")) # $demo # year quarter primaryid caseid ... # $drug # year quarter primaryid drug_seq drugname ... # $reac # year quarter primaryid pt ... ``` -------------------------------- ### faers_phv_signal() Source: https://context7.com/wanglabcsu/faers/llms.txt Performs disproportionality analysis for drug safety signal detection. ```APIDOC ## faers_phv_signal() ### Description Performs disproportionality analysis for drug safety signal detection. Supports multiple statistical methods including ROR, PRR, BCPNN, and EBGM. ### Parameters - **data** (object) - Required - The drug-specific data to analyze. - **.full** (object) - Optional - The full database for comparison. - **.object2** (object) - Optional - A second drug dataset for direct comparison. - **.methods** (vector) - Optional - Specific statistical methods to run (e.g., c('ror', 'prr', 'ebgm')). ``` -------------------------------- ### Combine Multiple FAERS Quarterly Data Files Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Uses faers_combine internally to process and merge multiple quarterly data files. ```R data2 <- faers(c(2004, 2017), c("q1", "q2"), dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) #> data2 #> ``` -------------------------------- ### Combine FAERS objects with faers_combine() Source: https://context7.com/wanglabcsu/faers/llms.txt Merges multiple FAERS objects into a single object. Objects must not be de-duplicated prior to combination. ```r # Parse two separate quarterly files data1 <- faers_parse( system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"), compress_dir = tempdir() ) data2 <- faers_parse( system.file("extdata", "faers_ascii_2017q2.zip", package = "faers"), compress_dir = tempdir() ) # Combine into single object combined_data <- faers_combine(data1, data2) # Combining all 2 FAERS Datas # FAERS data from 2 Quarterly ascii files ``` -------------------------------- ### Check FAERS Metadata Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Retrieves metadata for FAERS data, including years, periods, quarters, and file URLs/sizes. By default, it uses a cached file. If the cache is not found, it parses the metadata from the official FDA website. ```APIDOC ## GET /faers_meta ### Description Retrieves metadata for FAERS data, including years, periods, quarters, and file URLs/sizes. By default, it uses a cached file. If the cache is not found, it parses the metadata from the official FDA website. ### Method GET ### Endpoint /faers_meta ### Parameters #### Query Parameters - **internal** (boolean) - Optional - If TRUE, uses the internal FAERS metadata snapshot associated with the package. ### Response #### Success Response (200) - **data.table** - A data.table containing the following columns: - **year** (integer) - The year of the FAERS data. - **quarter** (character) - The quarter of the FAERS data (e.g., 'q1', 'q2'). - **period** (character) - The time period corresponding to the quarter (e.g., 'January - March'). - **ascii_urls** (character) - The URL to download the ASCII version of the FAERS data file. - **ascii_file_size** (character) - The size of the ASCII FAERS data file (e.g., '63.9MB'). ### Response Example ```json { "data.table": [ { "year": 2024, "quarter": "q2", "period": "April - June", "ascii_urls": "https://fis.fda.gov/content/Exports/faers_ascii_2024q2.zip", "ascii_file_size": "63.9MB" }, { "year": 2024, "quarter": "q1", "period": "January - March", "ascii_urls": "https://fis.fda.gov/content/Exports/faers_ascii_2024q1.zip", "ascii_file_size": "63.1MB" } ] } ``` ``` -------------------------------- ### Retrieve MedDRA Data Components Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Accesses MedDRA hierarchy or SMQ data components within the standardized FAERS object. ```R faers_meddra(data) faers_meddra(data, use = "hierarchy") ``` -------------------------------- ### Push Changes to Branch Source: https://github.com/wanglabcsu/faers/blob/devel/README.md Push your committed changes to your remote feature branch. ```git git push origin feature/AmazingFeature ``` -------------------------------- ### Standardize FAERS Data Source: https://context7.com/wanglabcsu/faers/llms.txt Standardizes adverse event terms using MedDRA. Requires a valid MedDRA license and path. ```r # Load FAERS data data <- faers(c(2004, 2017), c("q1", "q2"), dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) # Standardize with MedDRA (requires MedDRA license) data_std <- faers_standardize(data, meddra_path = "/path/to/MedDRA") # standardize Preferred Term in indi # standardize Preferred Term in reac # Include SMQ (Standardised MedDRA Queries) data data_std <- faers_standardize(data, meddra_path = "/path/to/MedDRA", add_smq = TRUE ) ``` -------------------------------- ### Perform pharmacovigilance signal analysis Source: https://github.com/wanglabcsu/faers/blob/devel/README.html Executes signal detection methods on filtered FAERS data using faers_phv_signal. ```R 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 a #> #> 1: Blood and lymphatic system disorders 1 #> 2: Cardiac disorders 2 #> 3: Congenital, familial and genetic disorders 0 #> 4: Ear and labyrinth disorders 0 #> 5: Endocrine disorders 0 #> 6: Eye disorders 0 #> 7: Gastrointestinal disorders 1 #> 8: General disorders and administration site conditions 3 #> 9: Hepatobiliary disorders 0 #> 10: Immune system disorders 1 #> 11: Infections and infestations 1 #> 12: Injury, poisoning and procedural complications 2 #> 13: Investigations 5 #> 14: Metabolism and nutrition disorders 2 #> 15: Musculoskeletal and connective tissue disorders 2 #> b c d expected ror ror_ci_low ror_ci_high prr #> #> 1: 8 10 181 0.495 2.2625000 0.25725215 19.898400 2.1222222 #> 2: 7 14 177 0.720 3.6122449 0.68476430 19.055189 3.0317460 #> 3: 9 1 190 0.045 0.0000000 0.00000000 NaN 0.0000000 #> 4: 9 1 190 0.045 0.0000000 0.00000000 NaN 0.0000000 ``` -------------------------------- ### Combine FAERS Data Source: https://context7.com/wanglabcsu/faers/llms.txt Combines multiple FAERS data objects into a single list. ```r combined_data <- faers_combine(list(data1, data2)) ``` -------------------------------- ### Detect Pharmacovigilance Signals Source: https://context7.com/wanglabcsu/faers/llms.txt Performs disproportionality analysis using various statistical methods. ```r # Prepare data: standardize and deduplicate data <- faers(c(2022, 2023), c("q3", "q4"), dir = "./faers_data") data_std <- faers_standardize(data, meddra_path = "/path/to/MedDRA") data_dedup <- faers_dedup(data_std) # Filter for drug of interest aspirin_data <- faers_filter(data_dedup, .fn = ~ .x[toupper(drugname) == "ASPIRIN"]$primaryid, .field = "drug" ) # Run signal detection comparing to full database results <- faers_phv_signal(aspirin_data, .full = data_dedup) # 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 # Results include all disproportionality measures # soc_name a b c d expected ror ror_ci_low ror_ci_high ... # 1: Gastrointestinal disorders 122 1320 381 31341 42.3 7.89 6.23 9.98 # Run specific methods only results <- faers_phv_signal(aspirin_data, .full = data_dedup, .methods = c("ror", "prr", "ebgm") ) # Compare two drugs against each other drug_a <- faers_filter(data_dedup, .fn = ~ .x[drugname == "DRUG_A"]$primaryid, .field = "drug") drug_b <- faers_filter(data_dedup, .fn = ~ .x[drugname == "DRUG_B"]$primaryid, .field = "drug") comparison <- faers_phv_signal(drug_a, .object2 = drug_b) ``` -------------------------------- ### faers_get() and faers_mget() - Extract Field Data Source: https://context7.com/wanglabcsu/faers/llms.txt Extract specific field data from FAERS objects. Available fields are: demo, drug, indi, ther, reac, rpsr, and outc. ```APIDOC ## faers_get() and faers_mget() - Extract Field Data ### Description Extract specific field data from FAERS objects. Available fields are: demo, drug, indi, ther, reac, rpsr, and outc. ### Method `faers_get(data, field)` `faers_mget(data, fields)` ### Parameters #### Path Parameters - **data** (list or data.table) - Required - The FAERS data object loaded by `faers()`. - **field** (character) - Required - The name of the field to extract (e.g., "demo", "drug"). - **fields** (character vector) - Required - A vector of field names to extract. ### Request Example ```r data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"), compress_dir = tempdir() ) # Extract single field demo_data <- faers_get(data, "demo") drug_data <- faers_get(data, "drug") # Alternative syntax using $ or [[]] demo_data <- data$demo reac_data <- data[["reac"]] # Extract multiple fields at once fields <- c("demo", "drug", "reac") multi_fields_data <- faers_mget(data, fields) ``` ### Response #### Success Response (200) - `faers_get()` returns a data.table for the specified field. - `faers_mget()` returns a list of data.tables for the specified fields. #### Response Example ```r # $demo # year quarter primaryid caseid ... # $drug # year quarter primaryid drug_seq drugname ... # $reac # year quarter primaryid pt ... ``` ``` -------------------------------- ### Calculate EBGM with phv_ebgm Source: https://context7.com/wanglabcsu/faers/llms.txt Calculates the Empirical Bayesian Geometric Mean (EBGM) for disproportionality analysis. Returns EBGM and its confidence interval. ```r phv_ebgm(122, 1320, 381, 31341) # ebgm ci_low ci_high # 1: 2.879 2.392 3.451 ```