Title: A 'shiny' Application for Exploring Laboratory Data
Version: 1.3.5
Description: A novel concept for generating knowledge and gaining insights into laboratory data. You will be able to efficiently and easily explore your laboratory data from different perspectives. Janitza, S., Majumder, M., Mendolia, F., Jeske, S., & Kulmann, H. (2021) <doi:10.1007/s43441-021-00318-4>.
Depends: R (≥ 3.5.0), seriation
License: GPL-3
URL: https://github.com/openpharma/elaborator
Encoding: UTF-8
Imports: shiny, dplyr, purrr, DT, here, tidyselect, rlang, tidyr, forcats, RColorBrewer, bsplus, dendextend, haven, reshape2, shape, shinyWidgets, shinydashboard
LazyData: true
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2025-03-24 19:47:04 UTC; sgfpj
Author: Silke Janitza [aut], Steffen Jeske [aut], Madhurima Majumder [aut], Franco Mendolia [aut], Bodo Kirsch [cre], Hermann Kulmann [aut]
Maintainer: Bodo Kirsch <kirschbodo@gmail.com>
Repository: CRAN
Date/Publication: 2025-03-25 05:50:12 UTC

Boxplot function used in app elaborator

Description

Boxplot function used in app elaborator

Usage

elaborator_boxplot(
  elab_data,
  draw_points_logical,
  same_axes_per_treatment_logical,
  boxplot_color,
  boxplot_border_color,
  lines_data,
  number_plots,
  tol_percentage,
  test_results_logical,
  length_visit2_is_one_logical,
  sort_points,
  incProgress,
  outliers_logical,
  col_lines_options,
  custom_visit
)

Arguments

elab_data

nested elaborator data with possibly up to three nests 'raw', 'test' and 'differences' grouped by treatment and labparameter

draw_points_logical

a logical (TRUE/FALSE) if points should be drawn

same_axes_per_treatment_logical

a logical (TRUE/FALSE) if same axes should be used within lab parameters

boxplot_color

vector with color(s) for boxplots

boxplot_border_color

vector with color(s) for boxplots border (used to incidate which visits are used for statistical tests)

lines_data

data frame with connection lines between subjects lab values

number_plots

number of plots (used in progress bar (if incProgress is TRUE))

tol_percentage

tolerated percentage value

test_results_logical

a logical (TRUE/FALSE) if statistical test is used

length_visit2_is_one_logical

a logical (TRUE/FALSE) if statistical test is performed between one or more visits (this will influence the appearence of the background)

incProgress

a logical (TRUE/FALSE) indicates if shiny progress bar is used

col_lines_options

option how the lines between visits should be colorized. Possible options are "first_last","each_visit", "custom_visits" or "all_grey". In the first three options decrease is colorized blue and an increase orange.

custom_visit

if col_lines_options is "custom_visits" then two visits need to be selected. Otherwise all lines are grey.

Value

No return value. Boxplots are generated, used in elaborator.


Calculates the index of the color vector in the qualitative trend analysis plot

Description

This function is mostly useful for generating the qualitative trend analysis plots. It returns the index of the color for a percentage which is observed for a specific pattern characterized by decreases/stability/increases from one visit to the next.

Usage

elaborator_calculate_color_index(r)

Arguments

r

numeric value specifying the percentage of patients with a specific pattern of decreased/stable/increased values from one visit to the next

Value

A numeric value between 1 and 11. This value is used as an index for the color legend in the qualitative trends plot in which darker colors reflect more frequent patterns


Returns row of a matrix containing all combinations of elements -1, 0, 1 of a pre-specified length

Description

This function is mostly useful for generating the qualitative trend analysis plots. It returns the (i-1)-th row of a matrix containing all combinations of elements -1, 0 and 1 of a pre-specified length.

Usage

elaborator_calculate_pattern(index, number_combinations)

Arguments

index

selected row -1 of the combination matrix which shall be returned

number_combinations

length of the combination vector

Value

A numeric vector containing a specific combination of elements -1, 0 and 1; this combination is used to calculate pattern for qualitative trend analysis plot.


Pattern number for input patterns defined by decreases, stability and increases

Description

This function is mostly useful for generating the qualitative trend analysis plots. It returns the pattern numbers for input patterns.

Usage

elaborator_calculate_pattern_number(p)

Arguments

p

matrix with patterns within each row. A pattern is described by a combination of elements -1, 0, 1 for decrease, stability and increase between adjacent visits.

Value

A numeric vector giving the pattern numbers for all input patterns.


Returns row of a matrix containing all combinations of elements 0 and 1 of a pre-specified length

Description

This function is mostly useful for generating the reference-value based pattern analysis plots. It returns the (i-1)-th row of a matrix containing all combinations of elements 0 and 1 of a pre-specified length.

Usage

elaborator_calculate_ref_pattern(index, number_combinations)

Arguments

index

selected row -1 of the combination matrix which shall be returned

number_combinations

length of the combination vector

Value

A numeric vector containing a specific combination of elements 0 and 1; this combination is used to calculate pattern for reference-value based pattern analysis plot.


Calculates the distance matrix based on Spearman's correlation coefficient

Description

This function derives the Spearman correlation coefficients for a data matrix and transforms the resulting similarity matrix into a distance/dissimilarity matrix. No difference is made between positive and negative correlations, i.e., correlations of -1 and 1 will be transformed to a distance of 0; correlations of 0 will be transformed to a distance of 1. Missing values in the input data will be handled by casewise deletion.

Usage

elaborator_calculate_spearman_distance(x)

Arguments

x

data matrix for which a distance matrix based on the Spearman correlation coefficient is calculated

Value

A distance matrix of class "dist", which can be used for example for a seriation algorithm


Perform pairwise statistical tests for quantitative trend plots

Description

Perform pairwise statistical tests for quantitative trend plots

Usage

elaborator_calculate_test_for_all_visits(
  elab_data,
  Visit1,
  Visit2,
  sign_test,
  pcutoff
)

Arguments

elab_data

nested elaborator data with possibly up to three nests 'raw',

Visit1

first visit for statistical tests (only one allowed)

Visit2

second visit(s) for statistical tests (multiple visits applicable - pairwise tests performed)

sign_test

character string if sign test or t-test should be performed ("signtest"/"ttest")

pcutoff

p value for test(s)

Value

tibble with test results (estimate/p-values) and color code for quantitative trend graphs


function to change (rdata) or set (csv data) the classes of the required variables in elaborator

Description

function to change (rdata) or set (csv data) the classes of the required variables in elaborator

Usage

elaborator_change_class_required_variables(elab_data, visit, treatment, lab)

Arguments

elab_data

elaborator_data (requires columns AVISIT,LBTESTCD,TRTP,SUBJIDN,LBORRES,LBORNRHI,LBORNRLO)

visit

desired level order for AVISIT

treatment

desired level order for TRTP

lab

desired level order for LBTESTCD

Value

elab_data with changed classes (and factor levels)


create hover text info in elaborator app zoom panel(s)

Description

create hover text info in elaborator app zoom panel(s)

Usage

elaborator_create_hover_info_text(elab_data, labparameter, treat, select.visit)

Arguments

elab_data

elaborator data

labparameter

labparameter used for filtering

treat

treatment used for filtering

select.visit

visit selection

Value

character string with text about number of visits in every treatment group and labparameter


Returns indices for all elements of a vector x that are contained in another vector y

Description

This function is mostly useful for generating the qualitative trend analysis plots. It returns the indices or all elements of a vector x that are contained in another vector y

Usage

elaborator_derive_equal_values(y, x)

Arguments

y

numeric vector

x

numeric vector

Value

A numeric vector with the indices for all elements of a vector x that are contained in another vector y.


Derives p-values and estimates for sign test or t-test

Description

This function is mostly useful for generating the quantitative trend analysis plots. It returns p-values and estimates for the sign test or the t-test used for colorizing the background of the plots.

Usage

elaborator_derive_test_values(
  data = data,
  signtest = TRUE,
  Visit1 = c("Randomization"),
  Visit2 = c("End of Treatment"),
  lab_column
)

Arguments

data

data set

signtest

logical, if true sign test, otherwise t-test for comparing Visit1 and Visit2 is performed

Visit1

name of visit time point one

Visit2

name of visit time point two, or vector of visit names for pairwise comparison to Visit1

lab_column

column name of data which includes the laboratory parameter names

Value

A list with p-values and estimates of the selected statistical test. The p-values and estimates will be used to colorize the background of the quantitative trend analysis plots.


Draws a curved line from start to end point

Description

This function is mostly useful for generating the reference-value based pattern analysis plots. It draws a curved line from a start to an end point.

Usage

elaborator_draw_curved_line(x1, y1, x2, y2, ...)

Arguments

x1

x-coordinate of the starting point

y1

y-coordinate of the starting point

x2

x-coordinate of the end point

y2

y-coordinate of the end point

...

further parameters

Value

No return value; this function is called to draw curved lines of the reference-value based pattern plot.


Draws a circle with specified size, coordinates and color in a plot window

Description

This function is mostly useful for generating the reference-value based pattern analysis plots. It draws a circle with specified size, coordinates and color in a plot window.

Usage

elaborator_draw_dots(
  x,
  y,
  height,
  dot_col,
  pattern_Matrix,
  number_column,
  dot_Radius,
  dot_radius,
  fontsize,
  empty_color = "#A9A9A9",
  upper_color = "#2fb39f",
  lower_color = "#f78300"
)

Arguments

x

x-coordinate of circle

y

y-coordinate of circle

height

height of curved lines which connect circles

dot_col

color of circle

pattern_Matrix

matrix with the reference-value based pattern information

number_column

number of layers (visits)

dot_Radius

circle radius for circles representing existing patterns

dot_radius

circle radius for circles representing non-existing patterns

fontsize

font size of numbers printed inside the circles

Value

No return value; this function is called to draw the circles for the reference-value based pattern analysis plot.


Generates tree diagram according to the reference-value based pattern analysis

Description

Generate tree diagram showing the number of patients with normal/abnormal values at each visit of a study according to the reference-value based pattern analysis.

Usage

elaborator_draw_ref_pattern(
  pattern_Matrix,
  fontsize,
  number_columns,
  background_color = "#E2F3F2"
)

Arguments

pattern_Matrix

matrix with reference-value based pattern information

fontsize

font size of numbers printed inside the circles

number_columns

number of layers (visits) of tree diagram

background_color

background color

Value

No return value; this function is called to draw a tree diagram according to the reference-value based pattern analysis.


Color scheme preview

Description

This function is mostly useful for changing the color scheme of the qualitative trend analysis plots.

Usage

elaborator_draw_scheme_preview(x)

Arguments

x

color palette

Value

No return value; this function is used to generate plots with the selected color scheme for the qualitative trend analysis.


Transform data and fill them with missing values in app elaborator

Description

Transform data and fill them with missing values in app elaborator

Usage

elaborator_fill_with_missings(elab_data)

Arguments

elab_data

data set

Value

Transformed data frame


loading function for elaborator data, also performs checks for required variables

Description

loading function for elaborator data, also performs checks for required variables

Usage

elaborator_load_and_check(
  data_switch = "*.RData file",
  rdata_file_path = NULL,
  csv_file_path = NULL,
  loaded_file = NULL,
  separator = NULL,
  quote = NULL,
  decimal = NULL
)

Arguments

data_switch

app widgets input wheter rdata or csv files or demo data should be uploaded

rdata_file_path

path of rdata file

csv_file_path

path of csv file

loaded_file

saved file for demo data (outdated)

separator

separator (for csv file upload only)

quote

quote (for csv file upload only)

decimal

decimal (for csv file upload only)

Value

list with data and error message


Performs binomial test for changes of a laboratory parameter between two visits

Description

This function is mostly useful for generating the quantitative trend analysis plots. It returns the output of a binomial test result used for colorizing the background of the plots.

Usage

elaborator_perform_binomial_test(
  data,
  treatment,
  lab_parameter,
  Visit1 = "Randomization",
  Visit2 = "End of Treatment",
  lab_column
)

Arguments

data

data set

treatment

name of treatment group

lab_parameter

name of laboratory parameter

Visit1

name of visit time point one

Visit2

name of visit time point two

lab_column

column name of data which includes the laboratory parameter names

Value

A list of class "htest", with the results of the binomial test.


Performs t-test for changes of a laboratory parameter between two visits

Description

This function is mostly useful for generating the quantitative trend analysis plots. It returns the output of a t-test result used for colorizing the background of the plots.

Usage

elaborator_perform_ttest(
  data,
  treatment,
  lab_parameter,
  Visit1 = "Randomization",
  Visit2 = "End of Treatment",
  lab_column
)

Arguments

data

data set

treatment

name of treatment group

lab_parameter

name of laboratory parameter

Visit1

name of visit time point one

Visit2

name of visit time point two

lab_column

column name of data which includes the laboratory parameter names

Value

A list of class "htest" with the results of the t-test.


Description

Generates diagrams showing the frequency of specific patterns of decreased, stable and increased values between adjacent visits of a study separately by treatment group and laboratory parameter according to the qualitative trend analysis.

Usage

elaborator_plot_qual_trends(
  dat1,
  Variab,
  fontsize = 1,
  method = "InQuRa",
  color_palette = c("#ffffff", "#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c",
    "#fc4e2a", "#e31a1c", "#bd0026", "#800026", "#000000"),
  Summa = Summa
)

Arguments

dat1

data set

Variab

vector of names for laboratory parameters

fontsize

font size of numbers inside the cells of the diagram

method

method specifying if values are considered being stable if the difference falls below a specific percentage of the reference range (Reference Range), interquartile range (InQuRa) or range (Range).

color_palette

vector with 11 colors used for background of the cells

Summa

summarization matrix

Value

No return value. Generates plots for the qualitative trend analysis.


Description

Generate boxplots showing the distribution of laboratory values at each visits of a study separately by treatment group and laboratory parameter according to the quantitative trend analysis.

Usage

elaborator_plot_quant_trends(
  elab_data,
  signtest = TRUE,
  Visit1,
  Visit2,
  sameaxes,
  cols = NULL,
  labelvis = NULL,
  labcolumn,
  sortpoints = FALSE,
  pcutoff = 0.01,
  infotest = NULL,
  sortinput,
  bordercol = NULL,
  add_points = TRUE,
  connect_lines,
  lin_data = NULL,
  outliers,
  tolerated_percentage = 100,
  color_lines_options,
  custom_visits = NULL
)

Arguments

elab_data

elaborator data

signtest

logical, if true sign test, otherwise t-test for comparing Visit1 and Visit2 is performed

Visit1

name of visit time point one

Visit2

name of visit time point two, or vector of visit names for pairwise comparison to Visit1

sameaxes

logical indicating if boxplot should have the same y-axis range for all treatment groups within a laboratory parameter

cols

vector with colors of boxplots

labelvis

vector of visit names used for labeling

labcolumn

column name of dat1 which includes the laboratory parameter names

sortpoints

logical indicating if dots in boxplots should be sorted from smallest to largest

pcutoff

numeric for p-value threshold; if p-value of specified test is below this threshold, the background of the respective plot is colorized.

infotest

list object from the perform test function

sortinput

vector of laboratory parameter names in the order in which laboratory parameters are presented in the output

bordercol

color of boxes which are not selected for hypothesis testing

add_points

logical indicating if points showing patients' values should be added to the boxplots

connect_lines

logical indicating if subject values should be connected between visits via lines

lin_data

data set with connection line data

tolerated_percentage

tolerated percentage value

color_lines_options

option how the lines between visits should be colorized. Possible options are "first_last","each_visit", "custom_visits" or "all_grey". In the first three options decrease is colorized blue and an increase orange.

custom_visits

if col_lines_options is "custom_visits" then two visits need to be selected. Otherwise all lines are grey.

Value

No return value. Generates plots for the quantitative trends analysis.


Generates the reference-value based pattern analysis plots in the shiny app elaborator

Description

Generates diagrams showing the frequency of normal and abnormal values at each visit of a study separately by treatment group and laboratory parameter according to the reference-value based pattern analysis.

Usage

elaborator_plot_ref_pattern(
  data,
  criterion,
  fontsize = 0.6,
  sorting_vector = as.character(unique(data[, "LBTESTCD"])),
  abnormal_value_factor = 1
)

Arguments

data

data set

criterion

criterion for defining whether abnormal values are defined as values below the lower limit of normal (less), above the upper limit of normal (greater) or either above the upper limit of normal or below the lower limit of normal (within)

fontsize

font size of numbers printed inside the circles

sorting_vector

vector of laboratory parameter names in the order in which laboratory parameters are presented in the output

abnormal_value_factor

numeric which is multiplied with upper and/or lower limit of normal for defining abnormal values; can only take positive values.

Value

No return value, called to plot the reference-based value pattern.


Transform data in form for cluster analysis in app elaborator

Description

Transform data in form for cluster analysis in app elaborator

Usage

elaborator_prepare_clustering_matrix(elab_data, first_variable, last_variable)

Arguments

elab_data

data set

first_variable

character with variable name

last_variable

character with variable name

Value

Transformed data frame


Transform data by removing visits with too many missing values in app elaborator

Description

Transform data by removing visits with too many missing values in app elaborator

Usage

elaborator_remove_visits_due_tolerated_missings(elab_data, tolerated_value)

Arguments

elab_data

data set

tolerated_value

numeric value with tolerated percentage value

Value

Transformed data frame


Server part of the elaborator application

Description

Server part of the elaborator application

Usage

elaborator_server(input, output, session)

Arguments

input, output, session

Internal parameters for shiny.

Value

No return value. Server part of the app, used in launch_elaborator-function.


Calculates the transparent version of a given color

Description

Calculates the transparent version of a given color

Usage

elaborator_transform_transparent(some_color, alpha = 100)

Arguments

some_color

A color in hexcode

alpha

shading parameter

Value

A character string representing a color hexcode with added transparency.


User Interface of the elaborator application

Description

User Interface of the elaborator application

Usage

elaborator_ui()

Value

No return value. User interface part of the app, used in launch_elaborator-function.


Launches the elaborator application

Description

Starts the elaborator application in the client's browser.

Usage

launch_elaborator(
  elaborator_data = NULL,
  host = "0.0.0.0",
  port = NULL,
  browser = NULL
)

Arguments

elaborator_data

data derived for the elaborator app

host

host link (defaults to the local machine "127.0.0.1")

port

port number (randomly chosen unless specified as a certain number)

browser

path to browser exe (defaults to standard browser)

Value

A shiny app

Examples

if(interactive()){
## Launch application on localhost (127.0.0.1)
## -------------------------------------------
## By default launch_elaborator starts the application on localhost
## and a randomly selected port (e.g. 9876), in which case you can connect
## to the running application by navigating your browser to
## http://localhost:9876.
launch_elaborator()

## Launch application on a different host
## --------------------------------------
## You can also run the application on a different host
## by specifying a hostname and port. Just make sure to
## use an open port on your machine. Here "open" means
## that the port should not be used by another service
## and the port is opened by your firewall.
launch_elaborator(host="your-hostname", port = 8888, browser = NULL)


## Make the application available to your coworkers
## ------------------------------------------------
## within your local area network even without a
## dedicated Shiny server. The value set through the
## host argument says to accept any connection (not just from localhost).
## Then take note of your local IP (if you are under linux,
## you can see it through ifconfig). Say your IP is 192.168.1.70.
## Your colleagues can use your app by inserting in the address
## bar of their browser 192.168.1.70:8888, i.e. your IP followed
## by : and the port number you selected.
launch_elaborator(host="0.0.0.0", port=8888)

## Launch application on a different browser
## ----------------------------------------
## To run the shiny app on a different browser than your standard browser
## use the "browser" argument to set the path to the respective .exe file.
launch_elaborator(browser = "C:/Program Files/Mozilla Firefox/firefox.exe")
}


Demo data documentation for elaborator app

Description

Demo data documentation for elaborator app

mirror server hosted at Truenetwork, Russian Federation.