Package 'extractFAERS'

Title: Extract Data from FAERS Database
Description: Provides functions to extract and process data from the FDA Adverse Event Reporting System (FAERS). It facilitates the conversion of raw FAERS data into structured formats for analysis. See Yang et al. (2022) <doi:10.3389/fphar.2021.772768> for related information.
Authors: Renjun Yang [ctb], Renjun Yang [aut, cre]
Maintainer: Renjun Yang <rjyang@rcees.ac.cn>
License: Apache License (>= 2)
Version: 0.1.1
Built: 2025-03-18 16:24:11 UTC
Source: CRAN

Help Index


Extract reports with only one drug used from FAERS data

Description

This function processes the FDA Adverse Event Reporting System (FAERS) data to extract reports where only a single drug was administered.

Usage

extract_FAERS_data(
  workingdir = NULL,
  usetempdir = FALSE,
  corenum = NULL,
  startfile = NULL,
  endfile = NULL,
  onlydoextract = FALSE,
  occpextract = NULL
)

Arguments

workingdir

Character vector. The directory containing the decompressed FAERS ASCII folders.

usetempdir

Logical. If TRUE, processed files are stored in a temporary directory; otherwise, they are saved in workingdir.

corenum

Numeric. The number of CPU cores to use for parallel processing. Using more cores reduces processing time.

startfile

Numeric. The index of the first file to process in the DRUG and related folders.

endfile

Numeric. The index of the last file to process in the DRUG and related folders.

onlydoextract

Logical. If TRUE, only extracts data without performing additional combination or filtering steps.

occpextract

Character vector. Specifies the occupation categories for data extraction. Defaults to c("MD", "HP", "PH", "OT").

Details

This package includes example data files in extdata:

  • faers_ascii_2015q1_example.zip: Example dataset 1.

  • faers_ascii_2015q2_example.zip: Example dataset 2.

  • faers_ascii_2015q3_example.zip: Example dataset 3.

  • faers_ascii_2015q4_example.zip: Example dataset 4.

  • Use system.file("extdata",package = "extractFAERS") to access the folder contain example zip files.

Value

A character vector containing the file paths of the processed folders

Examples

# Example_1 Perform FAERS data preprocessing in one step and
# generate `F_COREDATA_1PS_PROF_STU.RData` in a temporary folder.
# In practice, it is recommended to set `usetempdir = FALSE` and specify `workingdir`
# to prevent the processed results in the temporary folder from being automatically deleted.
extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = FALSE,
  occpextract = NULL
)

# Example_2 Stepwise FAERS data preprocessing
# Setting `onlydoextract = TRUE` extracts only single-drug cases and organizes file paths.
# The processed file paths are saved in a temporary directory.
extractfaerspath <- extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = TRUE,
  occpextract = NULL
)
print(extractfaerspath)

# Filter data based on reporter occupation
# By default, only reports from healthcare professionals
# (e.g., physicians, pharmacists) are retained.
faers1psprofdata <- filter_by_occp_FAERS(
  workingdir = extractfaerspath,
  occpextract = NULL,
  savetoRData = TRUE
)

# Standardize time units to days
# This ensures consistency in the dataset and facilitates analysis of adverse reactions
# based on patient age.
time_to_day_FAERS(
workingdir = extractfaerspath,
usexistRData = TRUE,
filteres = NULL
)

Filter extracted FAERS data by reporter occupation

Description

Filter extracted FAERS data by reporter occupation

Usage

filter_by_occp_FAERS(
  workingdir = NULL,
  temp_dir = NULL,
  occpextract = NULL,
  savetoRData = FALSE
)

Arguments

workingdir

Character vector. The directory containing decompressed FAERS ASCII folders.

temp_dir

Internal parameter used only when extract1PSFAERS is called internally. Do not modify.

occpextract

Character vector. Specifies the occupation types to extract. Defaults to c("MD", "HP", "PH", "OT").

savetoRData

Logical. Determines whether to save F_COREDATA_1PS_PROF.RData in the working directory. Must be set to TRUE if filter_by_occu_FAERS is used independently.

Details

This package includes example data files in extdata:

  • faers_ascii_2015q1_example.zip: Example dataset 1.

  • faers_ascii_2015q2_example.zip: Example dataset 2.

  • faers_ascii_2015q3_example.zip: Example dataset 3.

  • faers_ascii_2015q4_example.zip: Example dataset 4.

  • Use system.file("extdata",package = "extractFAERS") to access the folder contain example zip files.

Value

A list containing six data frames, containing formatted FAERS data after selecting single-drug cases and filtering reports based on reporter occupation. Can be used by time_to_day_FAERS() to standardize time units.

Examples

# Example_1 Perform FAERS data preprocessing in one step and
# generate `F_COREDATA_1PS_PROF_STU.RData` in a temporary folder.
# In practice, it is recommended to set `usetempdir = FALSE` and specify `workingdir`
# to prevent the processed results in the temporary folder from being automatically deleted.
extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = FALSE,
  occpextract = NULL
)

# Example_2 Stepwise FAERS data preprocessing
# Setting `onlydoextract = TRUE` extracts only single-drug cases and organizes file paths.
# The processed file paths are saved in a temporary directory.
extractfaerspath <- extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = TRUE,
  occpextract = NULL
)
print(extractfaerspath)

# Filter data based on reporter occupation
# By default, only reports from healthcare professionals
# (e.g., physicians, pharmacists) are retained.
faers1psprofdata <- filter_by_occp_FAERS(
  workingdir = extractfaerspath,
  occpextract = NULL,
  savetoRData = TRUE
)

# Standardize time units to days
# This ensures consistency in the dataset and facilitates analysis of adverse reactions
# based on patient age.
time_to_day_FAERS(
workingdir = extractfaerspath,
usexistRData = TRUE,
filteres = NULL
)

Change all time units to days in the data filtered by filter_by_occu_FAERS(). This function converts age and time units in the data to days, and processes occupation and reaction data.

Description

Change all time units to days in the data filtered by filter_by_occu_FAERS(). This function converts age and time units in the data to days, and processes occupation and reaction data.

Usage

time_to_day_FAERS(workingdir = NULL, usexistRData = FALSE, filteres = NULL)

Arguments

workingdir

Directory containing F_COREDATA_1PS_PROF.RData.

usexistRData

Logical. Specifies whether to use F_COREDATA_1PS_PROF.RData in the working directory for calculations. Must be set to TRUE and workingdir must be provided if time_to_day_FAERS is used independently.

filteres

Filtered results for changing time units. Used only when extract1PSFAERS is called internally. Set to NULL if time_to_day_FAERS is used separately.

Details

This package includes example data files in extdata:

  • faers_ascii_2015q1_example.zip: Example dataset 1.

  • faers_ascii_2015q2_example.zip: Example dataset 2.

  • faers_ascii_2015q3_example.zip: Example dataset 3.

  • faers_ascii_2015q4_example.zip: Example dataset 4.

  • Use system.file("extdata",package = "extractFAERS") to access the folder contain example zip files.

Value

A character vector containing the path of the processed file "F_COREDATA_1PS_PROF_STU.RData", which can be used for further analysis

Examples

# Example_1 Perform FAERS data preprocessing in one step and
# generate `F_COREDATA_1PS_PROF_STU.RData` in a temporary folder.
# In practice, it is recommended to set `usetempdir = FALSE` and specify `workingdir`
# to prevent the processed results in the temporary folder from being automatically deleted.
extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = FALSE,
  occpextract = NULL
)

# Example_2 Stepwise FAERS data preprocessing
# Setting `onlydoextract = TRUE` extracts only single-drug cases and organizes file paths.
# The processed file paths are saved in a temporary directory.
extractfaerspath <- extract_FAERS_data(
  workingdir = system.file("extdata", package = "extractFAERS"),
  usetempdir = TRUE,
  corenum = 2,
  startfile = 1,
  endfile = 4,
  onlydoextract = TRUE,
  occpextract = NULL
)
print(extractfaerspath)

# Filter data based on reporter occupation
# By default, only reports from healthcare professionals
# (e.g., physicians, pharmacists) are retained.
faers1psprofdata <- filter_by_occp_FAERS(
  workingdir = extractfaerspath,
  occpextract = NULL,
  savetoRData = TRUE
)

# Standardize time units to days
# This ensures consistency in the dataset and facilitates analysis of adverse reactions
# based on patient age.
time_to_day_FAERS(
workingdir = extractfaerspath,
usexistRData = TRUE,
filteres = NULL
)