Generate Histogram or Bar Plot for Liver-Related Scores
Source:R/get_histogram_barplot.R
get_histogram_barplot.RdThis function generates a bar plot comparing liver-related findings to non-liver-related findings,
or returns processed data for further analysis. The function can fetch data from an SQLite database,
a provided XPT file, or simulate data if fake_study is set to TRUE.
Usage
get_histogram_barplot(
Data = NULL,
generateBarPlot = FALSE,
path_db = FALSE,
rat_studies = FALSE,
studyid_metadata,
fake_study = FALSE,
use_xpt_file = FALSE,
Round = FALSE,
output_individual_scores = TRUE,
utput_zscore_by_USUBJID = FALSE
)Arguments
- Data
A data frame containing liver-related scores. If NULL, the function will attempt to generate or fetch the data from a database or file.
- generateBarPlot
A logical flag (default = FALSE). If TRUE, generates a bar plot. If FALSE, returns the processed data.
- path_db
A character string representing the path to the SQLite database. Required if
use_xpt_fileis FALSE orfake_studyis FALSE.- rat_studies
A logical flag (default = FALSE) to filter for rat studies when fetching data from the database.
- studyid_metadata
A data frame containing metadata associated with study IDs. Required when
fake_studyis FALSE and real data is fetched.- fake_study
A logical flag (default = FALSE). If TRUE, the function simulates study data instead of fetching it from a database.
- use_xpt_file
A logical flag (default = FALSE). If TRUE, the function will use an XPT file to fetch data, instead of relying on the database.
- Round
A logical flag (default = FALSE). Whether to round the liver scores.
- output_individual_scores
A logical flag (default = TRUE). Whether to output individual scores or aggregated scores.
- output_zscore_by_USUBJID
A logical flag (default = FALSE). Whether to output z-scores by USUBJID (unique subject identifier).
Value
If generateBarPlot = TRUE, a ggplot2 bar plot object is returned displaying the
average scores for liver-related findings versus non-liver-related findings. If
generateBarPlot = FALSE, a data frame (plotData) containing the calculated values
for each finding, liver status (LIVER), and mean values (Value) is returned.
Details
If no data is provided, the function attempts to fetch data from an SQLite database or simulate
data based on the fake_study flag. The function also supports the use of XPT files and allows
customization of study filtering through the rat_studies and studyid_metadata parameters.
When generating a plot, the function compares liver-related findings to other findings,
displaying the average scores for each finding in a bar plot.
Examples
if (FALSE) { # \dontrun{
# Example 1: Generate a bar plot with fake study data
#get_histogram_barplot(generateBarPlot = TRUE, fake_study = TRUE)
# Example 2: Get processed data without generating a plot
#data <- get_histogram_barplot(generateBarPlot = FALSE, fake_study = FALSE, path_db = "path/to/db")
} # }