Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from esqLABS/develop
Browse files Browse the repository at this point in the history
Merge develop
  • Loading branch information
PavelBal committed Nov 14, 2022
2 parents 74a35b7 + f087330 commit 227fc9e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 40 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: esqlabsRLegacy
Title: esqLABS utilities package legacy functions
Version: 3.0.0
Version: 3.0.1
Authors@R:
c(person("esqLABS GmbH", role = c("cph", "fnd")),
person("Pavel", "Balazki", role = c("cre", "aut"), email = "pavel.balazki@esqlabs.com"),
Expand Down Expand Up @@ -30,4 +30,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
RoxygenNote: 7.2.1
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# esqlabsRLegacy 3.0.1

Fixes unit conversion error when trying to plot data with geometric standard
deviation.

-----

# esqlabsRLegacy 3.0.0

- Initial release of the package.
Expand Down
4 changes: 4 additions & 0 deletions R/DataMapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ DataMapping <- R6::R6Class(
label <- dataSet$name
# Create a `XYData` object from `DataSet`
xyData <- XYData$new(xVals = dataSet$xValues, yVals = dataSet$yValues, yError = dataSet$yErrorValues, label = label)
# Check if error type is set in the DataSet object
if (!is.null(dataSet$yErrorType)){
xyData$yErrorType <- dataSet$yErrorType
}
xyData$dataType <- XYDataTypes$Observed
xyData$MW <- dataSet$molWeight
xyData$xDimension <- dataSet$xDimension
Expand Down
25 changes: 24 additions & 1 deletion R/XYData.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ XYData <- R6::R6Class(
}
},

#' @field yErrorType Type of error values - either 'ArithmeticStdDev' (default)
#' or 'GeometricStdDev'
yErrorType = function(value){
if (missing(value)) {
private$.yErrorType
} else {
if (!(value %in% c("ArithmeticStdDev", "GeometricStdDev"))){
stop("Supported error types are 'ArithmeticStdDev' and 'GeometricStdDev'.")
}

private$.yErrorType <- value
}
},

#' @field MW Molecular weight in g/mol. Required for conversion between
#' molar and mass dimensions. Can be `NULL` (default)
MW = function(value) {
Expand All @@ -186,6 +200,7 @@ XYData <- R6::R6Class(
.yDimension = NULL,
.yUnit = NULL,
.yErrorUnit = NULL,
.yErrorType = NULL,
.MW = NULL,
.metaData = list()
),
Expand Down Expand Up @@ -215,6 +230,8 @@ XYData <- R6::R6Class(

self$xDimension <- ospDimensions$Time
self$yDimension <- ospDimensions$Dimensionless

private$.yErrorType <- "ArithmeticStdDev"
},

#' @description Returns the minimal value (minus error, if specified) of the y series that is not negative or null
Expand Down Expand Up @@ -280,7 +297,9 @@ XYData <- R6::R6Class(
},

#' @description
#' y error values with all conversions applied.
#' y error values with all conversions applied. If error type is 'GeometricStdDev',
#' raw error values are multiplied by processed yValues
#'
#'
#' @param unit Target unit. If `NULL` (default), the no conversion between
#' units is applied.
Expand All @@ -293,6 +312,10 @@ XYData <- R6::R6Class(
return(NULL)
}

if (private$.yErrorType == "GeometricStdDev"){
return(private$.yError * self$yValuesProcessed(unit))
}

# Add offset and multiply by the factor. The values are in the unit of XYData
valuesProcessed <- private$.yError * self$yFactor

Expand Down
4 changes: 4 additions & 0 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ messages$errorWrongLength <- function(object, length, optionalMessage = NULL) {
messages$errorMultipleMetaDataEntries <- function(optionalMessage = NULL) {
paste("Can only set a single meta data entry at once", optionalMessage)
}

messages$dataMappingNoGrouping <- function(optionalMessage = NULL) {
paste("No data sets are grouped in the data mapping!", optionalMessage)
}
6 changes: 6 additions & 0 deletions R/utilities-data-mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ plotTimeValues <- function(dataMapping, aggregated, ...) {
#' @export
plotPredictedVsObserved <- function(dataMapping, foldDistance = 2, timeDiffThreshold = 10, ...) {
validateIsOfType(dataMapping, "DataMapping")

# Cannot create such a plot if no grouping exists
if (length(dataMapping$groupings) == 0){
stop(messages$dataMappingNoGrouping())
}

legendEntries <- c()
legendColors <- c()
legendPch <- c()
Expand Down
6 changes: 0 additions & 6 deletions man/DataConfiguration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions man/DataMapping.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions man/DataMappingConfiguration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions man/PlotConfiguration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions man/Plotable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions man/XYData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 227fc9e

Please sign in to comment.