pgu.limitsOfQuantification: pgu.limitsOfQuantification

Description Format Details Active bindings Methods Author(s)

Description

Handles values in the pguIMP dataset that exceed the limits of quantification. This object is used by the shiny based gui and is not for use in individual R-scripts!

Format

R6::R6Class object.

Details

more information

Active bindings

loq

Returns the instance variable loq (tibble::tibble)

setLoq

Sets the instance variable loq. (tibble::tibble)

outliers

Returns instance variable outliers (tibble::tibble)

lloqSubstituteAlphabet

Returns the instance variable lloqSubstititeAlphabet (character)

lloqSubstituteAgent

Returns the instance variable lloqSubstituteAgent (character)

setLloqSubstituteAgent

Sets the instance variable lloqSubstituteAgent. (character)

uloqSubstituteAlphabet

Returns the instance variable uloqSubstititeAlphabet (character)

uloqSubstituteAgent

Returns the instance variable uloqSubstituteAgent (character)

setUloqSubstituteAgent

Sets the instance variable uloqSubstituteAgent. (character)

naHandlingAlphabet

Returns the instance variable naHandlingAlphabet (character)

naHandlingAgent

Returns the instance variable naHandlingAgentt (character)

setNaHandlingAgent

Sets the instance variable naHandlingAgentt (character)

loqStatistics

Returns the instance variable loqStatistics

Methods

Public methods


Method new()

Mutates outlier candidates characterized as below LLOQ based on user defined actions.

Mutates outlier candidates characterized as above ULOQ based on user defined actions.

Searches for outliers in the given data frame. If an outlier was found, it is appended to the instance variable outliers. Indicates if an outlier was found.

Extends the instance variable outliers by one entry.

Tests if the provided attributes are known to the class.

Resets the class' instance variable outliers

Calculates statistics of outlier appearance. Stores it into the instance variable loqStatistics

Resets the class' instance variable loqStatistics

Resets the class by a data frame comprising information about LOQs.

Resets the class by a vector of attribute names. The Attributes' LOQs are initially assigned to na.

Clears the heap and indicates that instance of pgu.limitaOfQuantification is removed from heap.

Creates and returns a new pgu.limitsOfQuantification object.

Usage
pgu.limitsOfQuantification$new(attribute_names = "character")
Arguments
attribute_names

Vector of attribute names with to be analyzed by the loq object. (character)

Returns

A new pgu.limitsOfQuantification object. (pguIMP::pgu.limitsOfQuantification)


Method print()

Prints instance variables of a pgu.limitsOfQuantification object.

Usage
pgu.limitsOfQuantification$print()
Returns

string


Method reset()

Resets the pguIMP::pgu.limitsOfQuantification object on the given parameters attribute_names and data_df

Usage
pgu.limitsOfQuantification$reset(
  attribute_names = "character",
  data_df = "tbl_df"
)
Arguments
attribute_names

Vector of attribute names with to be analyzed by the loq object. (character)

data_df

Dataframe comprising loq information. Feature names need to be 'attribute', 'LLOQ' and 'ULOQ'. (tibble::tibble)


Method fit()

Analyses the data dets for instances outside of the LOQ defined value interval.

Usage
pgu.limitsOfQuantification$fit(data_df = "tbl_df")
Arguments
data_df

Dataframe to be analyzed


Method predict()

Mutates all outlier candidates based on user defined actions.

Usage
pgu.limitsOfQuantification$predict(data_df = "tbl_df")
Arguments
data_df

The data to be analyzed. (tibble::tibble)

Returns

The revised data frame (tibble::tibble)


Method attribute_lloq()

Returns the attribute's specific lloq.

Usage
pgu.limitsOfQuantification$attribute_lloq(attribute = "character")
Arguments
attribute

The attribute to be analyzed (character)

Returns

The attribute's lloq (numeric)


Method attribute_uloq()

Returns the attribute's specific uloq.

Usage
pgu.limitsOfQuantification$attribute_uloq(attribute = "character")
Arguments
attribute

The attribute to be analyzed (character)

Returns

The attribute's uloq (numeric)


Method set_attribute_lloq()

sets the attribute's specific lloq to value.

Usage
pgu.limitsOfQuantification$set_attribute_lloq(
  attribute = "character",
  value = NA
)
Arguments
attribute

The attribute to be updated (character)

value

The value parsed to the attributes lloq (numeric)


Method set_attribute_uloq()

sets the attribute's specific uloq to value.

Usage
pgu.limitsOfQuantification$set_attribute_uloq(
  attribute = "character",
  value = NA
)
Arguments
attribute

The attribute to be updated (character)

value

The value parsed to the attributes lloq (numeric)


Method attribute_outliers()

Returns the detected outliers of a given attribute.

Usage
pgu.limitsOfQuantification$attribute_outliers(attribute = "character")
Arguments
attribute

The attribute to be analyzed (character)

Returns

The attribute's outliers (tibble::tibble)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
                                        ####################
                                        # data information #
                                        ####################
                                        #' @description
                                        #' Gathers and returns class information
                                        dataInformation = function(){
                                          self$loq %>%
                                            dplyr::summarise_all(class) %>%
                                            tidyr::gather(variable, class) %>%
                                            return()
                                        }, #function

                                        ####################
                                        # output functions #
                                        ####################
                                        #' @description
                                        #' Merges dfData and dfMetadata and returns a fromatted data table.
                                        #' @param dfData
                                        #' The data to be analyzed.
                                        #' (tibble::tibble)
                                        #' @param dfMetadata
                                        #' The data frame containing metadata.
                                        #' (tibble::tibble)
                                        #' @return
                                        #' A formatted data table
                                        #' (DT::datatable)
                                        loqDataTable = function(dfData = "tbl_df", dfMetadata = "tbl_df"){
                                          options(htmlwidgets.TOJSON_ARGS = list(na = 'string'))
                                          t <- NULL
                                          featureNames <- colnames(dfData)
                                          tryCatch(
                                            dfMerge <- dplyr::bind_cols(dfMetadata, dfData),
                                            error = function(e){
                                              print("error")
                                              print(e)
                                              dfMerge <- dfData
                                            }#error
                                          )#tryCatch
                                          if(self$checkValidity(featureNames)){
                                            t <- dfMerge %>%
                                              dplyr::mutate_if(is.numeric, round, 3) %>%
                                              DT::datatable(options = list(scrollX = TRUE,
                                                                           scrollY = '350px',
                                                                           paging = FALSE))
                                            for (featureName in featureNames){
                                              featureOutlier <- self$outliers %>%
                                                dplyr::filter(feature == featureName) %>%
                                                dplyr::mutate_if(is.numeric, round, 3)
                                              if (nrow(featureOutlier) > 0){
                                                t <- DT::formatStyle(t,
                                                                     featureName,
                                                                     backgroundColor = DT::styleEqual(dfMerge %>%
                                                                                                        dplyr::select(!!featureName) %>%
                                                                                                        dplyr::slice(featureOutlier[["measurement"]]) %>%
                                                                                                        unlist() %>%
                                                                                                        round(digits = 3),
                                                                                                      featureOutlier[["color"]]))
                                              }#if
                                            }#for
                                          }#if
                                          return(t)
                                        }, #function

                                        #' @description
                                        #' Returns a formatted data table with comrising the information of a user defined attribute's outliers.
                                        #' @param obj
                                        #' The data to be analyzed.
                                        #' (tibble::tibble)
                                        #' @param feature
                                        #' The attribute to be analyzed
                                        #' (character)
                                        #' @return
                                        #' A formatted data table
                                        #' (DT::datatable)
                                        loqFeatureTable = function(obj = "tbl_df", feature = "character"){
                                          options(htmlwidgets.TOJSON_ARGS = list(na = 'string'))
                                          t <- NULL
                                          if(self$checkValidity(feature)){
                                            featureOutlier <- self$outliers %>%
                                              dplyr::filter(feature == !!feature) %>%
                                              dplyr::mutate_if(is.numeric, round, 3)

                                            dfFeature <- obj %>%
                                              dplyr::mutate_if(is.numeric, round, 3)

                                            print(dfFeature)

                                            t <- dfFeature %>%
                                              DT::datatable(options = list(scrollX = TRUE,
                                                                           scrollY = '350px',
                                                                           paging = FALSE))
                                            if (nrow(featureOutlier) > 0){
                                              t <- DT::formatStyle(
                                                t,
                                                feature,
                                                backgroundColor = DT::styleEqual(dfFeature %>%
                                                                                   dplyr::select(!!feature) %>%
                                                                                   dplyr::slice(featureOutlier[["measurement"]]) %>%
                                                                                   unlist() %>%
                                                                                   round(digits = 3),
                                                                                 featureOutlier[["color"]]))
                                            }#if
                                          }#if
                                          return(t)
                                        }, #function

Method plot_loq_distribution()

Creates a plot of the instance variable loqStatistics.

Usage
pgu.limitsOfQuantification$plot_loq_distribution()
Returns

A plot. (ggplot2::ggplot)


Method attribute_bar_plot()

Creates a bar plot of a user defined attribute's value distribution. LOQs are indicated as dotted lines

Usage
pgu.limitsOfQuantification$attribute_bar_plot(
  data_df = "tbl_df",
  attribute = "character"
)
Arguments
data_df

The data to be analyzed. (tibble::tibble)

attribute

The attribute to be analyzed (character)

Returns

A bar plot. (ggplot2::ggplot)


Method attribute_box_plot_with_subset()

Creates a box plot of a user defined attribute's value distribution. LOQs are indicated as dotted lines

Usage
pgu.limitsOfQuantification$attribute_box_plot_with_subset(
  data_df = "tbl_df",
  attribute = "character"
)
Arguments
data_df

The data to be analyzed. (tibble::tibble)

attribute

The attribute to be analyzed (character)

Returns

A box plot. (ggplot2::ggplot)


Method attribute_plot()

Creates and returns a composite graphical analysis of the outlier analysis of a user defined attribute.

Usage
pgu.limitsOfQuantification$attribute_plot(
  data_df = "tbl_df",
  attribute = "character"
)
Arguments
data_df

The data to be analyzed. (tibble::tibble)

attribute

Attribute's name. (character)

Returns

Composite result plot. (gridExtra::grid.arrange)


Method clone()

The objects of this class are cloneable with this method.

Usage
pgu.limitsOfQuantification$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Sebastian Malkusch, malkusch@med.uni-frankfurt.de


pguIMP documentation built on Sept. 30, 2021, 5:08 p.m.