The StatisticEngine R6 class is a framework for performing statistical analysis on data.
Data can be added as a character vector with a path to a csv
file with variable names as first
row and analyses names as first column or a data.frame
or matrix
object.
Note
Note that the model must be created before prediction and data must have the same number of variables as the model. Also, any pre-processing applied to the model data should be applied to the data before prediction. Note that only numeric values are accepted in data and the data column names are used as variable names and data row names are used as analyses names.
Note that the model must be created before testing and data must have the same number of variables as the model. Also, any pre-processing applied to the model data should be applied to the data before testing. Note that only numeric values are accepted in data and the data column names are used as variable names and data row names are used as analyses names.
Super class
StreamFind::CoreEngine
-> StatisticEngine
Active bindings
data
Data object.
model
Statistic model.
quantification
Quantification results.
prediction_results
Prediction results.
classification_results
Classification results.
Methods
Inherited methods
StreamFind::CoreEngine$clear_cache()
StreamFind::CoreEngine$clear_results()
StreamFind::CoreEngine$get_cache_info()
StreamFind::CoreEngine$get_cache_size()
StreamFind::CoreEngine$has_analyses()
StreamFind::CoreEngine$has_results()
StreamFind::CoreEngine$load()
StreamFind::CoreEngine$print()
StreamFind::CoreEngine$run()
StreamFind::CoreEngine$run_app()
StreamFind::CoreEngine$run_workflow()
StreamFind::CoreEngine$save()
Method new()
Creates an R6 class StatisticEngine. Child of CoreEngine R6 class.
Usage
StatisticEngine$new(metadata = NULL, workflow = NULL, analyses = NULL)
Arguments
metadata
A named list or a
Metadata
object. Each list element must have length one. There is no type restrictions except for name (must be type character), author (must be type character) and date (must be class POSIXct or POSIXt). A file entry must be a character string with a full path to a file.workflow
A
Workflow
object, a list ofProcessingStep
objects or a character string with a full path to a rds or json file containing aWorkflow
.analyses
A
StatisticAnalyses
S7 class object or acharacter vector
with full file path to.csv
file with variable names as first row and analyses names as first column or adata.frame
ormatrix
object.
Method add_analyses()
Adds analyses. Note that when adding new analyses, any existing results are removed. Note that the data must have the same number and names of variables (i.e., columns) as the model.
Method remove_analyses()
Removes analyses.
Method predict()
Predicts the data using the model.
Method test()
Tests the model using the data.
Method plot_data()
Plots the data.
Usage
StatisticEngine$plot_data(
analyses = NULL,
features = NULL,
transpose = FALSE,
interactive = TRUE,
xLab = NULL,
yLab = NULL,
title = NULL,
colorGroups = NULL,
xTickLabelsShow = TRUE
)
Arguments
analyses
Character or numeric vector with names or indexes of analyses in the
Analyses
object.features
A numeric vector with the features (columns of data matrix) to plot.
transpose
Logical, if TRUE the data is transposed (i.e., column names are used as legend).
interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.xLab
A string with the title for the x axis.
yLab
A string with the title for the y axis.
title
A string with the title.
colorGroups
A factor character vector with the color groups for the data.
xTickLabelsShow
Logical, if TRUE the x-axis tick labels are shown.
Method plot_explained_variance()
Plots the model explained cumulative variance.
Method plot_scores()
Plots scores of the model.
Usage
StatisticEngine$plot_scores(
analyses = NULL,
interactive = TRUE,
pcs = 1:2,
title = NULL,
colorGroups = NULL,
showText = TRUE,
showLegend = TRUE
)
Arguments
analyses
Character or numeric vector with names or indexes of analyses in the
Analyses
object.interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.pcs
A numeric vector (length 2) with the principle components to plot.
title
A string with the title.
colorGroups
A factor character vector with the color groups for the scores.
showText
Logical (length 1), set to
TRUE
to show the text annotations.showLegend
Logical (length 1). Set to
TRUE
to show legend.
Method plot_residuals()
Plots residuals of the model.
Usage
StatisticEngine$plot_residuals(
analyses = NULL,
interactive = TRUE,
xLab = NULL,
yLab = NULL,
title = NULL
)
Arguments
analyses
Character or numeric vector with names or indexes of analyses in the
Analyses
object.interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.xLab
A string with the title for the x axis.
yLab
A string with the title for the y axis.
title
A string with the title.
Method plot_loadings()
Plots model loadings.
Usage
StatisticEngine$plot_loadings(
interactive = TRUE,
pcs = 1:2,
colorKey = NULL,
title = NULL,
showText = TRUE,
showLegend = TRUE
)
Arguments
interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.pcs
A vector with the principle components to plot.
colorKey
A character vector with the color key for the loading variables.
title
A string with the title.
showText
Logical (length 1), set to
TRUE
to show the text annotations.showLegend
Logical (length 1). Set to
TRUE
to show legend.
Method plot_resolved_spectra()
Plots model resolved spectra.
Usage
StatisticEngine$plot_resolved_spectra(
interactive = TRUE,
pcs = NULL,
original = TRUE,
title = NULL,
showText = TRUE,
showLegend = TRUE
)
Arguments
interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.pcs
Integer vectors with the principle component to use for categorization.
original
Logical, if TRUE the original data is plotted.
title
A string with the title.
showText
Logical (length 1), set to
TRUE
to show the text annotations.showLegend
Logical (length 1). Set to
TRUE
to show legend.
Method plot_contributions()
Plots model contributions.
Usage
StatisticEngine$plot_contributions(
interactive = TRUE,
pcs = NULL,
title = NULL,
showText = TRUE,
showLegend = TRUE
)
Arguments
interactive
Logical (length 1). When
TRUE
, the data is plotted interactively using plotly.pcs
Integer vectors with the principle component to use for categorization.
title
A string with the title.
showText
Logical (length 1), set to
TRUE
to show the text annotations.showLegend
Logical (length 1). Set to
TRUE
to show legend.
Method plot_residual_distance()
Plots the residual distance of the model.