diff --git a/DESCRIPTION b/DESCRIPTION index dd838b8c2..9cb98d931 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -90,4 +90,4 @@ Suggests: DSLite Encoding: UTF-8 Language: en-GB -Config/roxygen2/version: 8.1.0 +Config/roxygen2/version: 8.1.1 diff --git a/R/ds.auc.R b/R/ds.auc.R index ebfc5fc31..8b16502b1 100644 --- a/R/ds.auc.R +++ b/R/ds.auc.R @@ -11,19 +11,12 @@ #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return returns the AUC and its standard error #' @author Demetris Avraam for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export #' ds.auc <- function(pred=NULL, y=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- DSI::datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) # verify that 'pred' was set if(is.null(pred)){ @@ -35,10 +28,6 @@ ds.auc <- function(pred=NULL, y=NULL, datasources=NULL){ stop("Please provide the name of the outcome variable", call.=FALSE) } - # check if the pred and y objects are defined in all the studies - defined.pred <- isDefined(datasources, pred) - defined.y <- isDefined(datasources, y) - cally <- call('aucDS', pred, y) output <- DSI::datashield.aggregate(datasources, cally) diff --git a/R/ds.bp_standards.R b/R/ds.bp_standards.R index ae76c54ca..fe9b69fa5 100644 --- a/R/ds.bp_standards.R +++ b/R/ds.bp_standards.R @@ -26,20 +26,13 @@ #' blood pressure in children and adolescents: #' https://www.nhlbi.nih.gov/sites/default/files/media/docs/hbp_ped.pdf #' @author Demetris Avraam for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @import data.table #' @export ds.bp_standards <- function(sex=NULL, age=NULL, height=NULL, bp=NULL, systolic=TRUE, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- DSI::datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) # verify that 'sex' was set if(is.null(sex)){ @@ -61,12 +54,6 @@ ds.bp_standards <- function(sex=NULL, age=NULL, height=NULL, bp=NULL, systolic=T stop("Please provide the name of the blood pressure variable", call.=FALSE) } - # check if the input objects are defined in all the studies - defined.sex <- isDefined(datasources, sex) - defined.age <- isDefined(datasources, age) - defined.height <- isDefined(datasources, height) - defined.bp <- isDefined(datasources, bp) - # if no output object specified then provide a default name if(is.null(newobj)){ newobj <- "bp.newobj" diff --git a/R/ds.exists.R b/R/ds.exists.R index 24c5bfa26..b7a378144 100644 --- a/R/ds.exists.R +++ b/R/ds.exists.R @@ -16,6 +16,7 @@ #' @return \code{ds.exists} returns a logical object. #' TRUE if the object is on the server-side and FALSE otherwise. #' @author DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @seealso \code{\link{ds.class}} to check the type of an object. #' @seealso \code{\link{ds.length}} to check the length of an object. #' @seealso \code{\link{ds.dim}} to check the dimension of an object. @@ -61,15 +62,7 @@ #' ds.exists <- function(x=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of the input object!", call.=FALSE) diff --git a/R/ds.igb_standards.R b/R/ds.igb_standards.R index 89498a0ca..dd4023045 100644 --- a/R/ds.igb_standards.R +++ b/R/ds.igb_standards.R @@ -36,20 +36,13 @@ #' } #' @return assigns the converted measurement as a new object on the server-side #' @author Demetris Avraam for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export #' ds.igb_standards <- function(gagebrth=NULL, z=0, p=50, val=NULL, var=NULL, sex=NULL, fun='igb_value2zscore', newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) # check if user has provided the name of the input variables if(is.null(gagebrth)){ @@ -59,10 +52,6 @@ ds.igb_standards <- function(gagebrth=NULL, z=0, p=50, val=NULL, var=NULL, sex=N stop("Please provide the name of the sex variable", call.=FALSE) } - # check if the input objects are defined in all the studies - isDefined(datasources, gagebrth) - isDefined(datasources, sex) - # check if the provided fun is valid if(!(fun %in% c("igb_centile2value","igb_zscore2value","igb_value2zscore","igb_value2centile"))){ stop("Please provide a valid fun", call.=FALSE) @@ -72,8 +61,6 @@ ds.igb_standards <- function(gagebrth=NULL, z=0, p=50, val=NULL, var=NULL, sex=N if(fun %in% c("igb_value2zscore","igb_value2centile")){ if(is.null(val)){ stop("Please provide the name of the val variable", call.=FALSE) - }else{ - isDefined(datasources, val) } } diff --git a/R/ds.listDisclosureSettings.R b/R/ds.listDisclosureSettings.R index 04851def6..f115bdb28 100644 --- a/R/ds.listDisclosureSettings.R +++ b/R/ds.listDisclosureSettings.R @@ -57,6 +57,7 @@ #' @return \code{ds.listDisclosureSettings} returns a list containing the current settings of the #' \code{nfilters} in each study specified. #' @author DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export #' @examples #' \dontrun{ @@ -100,15 +101,7 @@ #' } #' ds.listDisclosureSettings <- function(datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) # CALL THE MAIN SERVER SIDE FUNCTION calltext <- call("listDisclosureSettingsDS") diff --git a/R/ds.mdPattern.R b/R/ds.mdPattern.R index 37823071d..98fa8ec19 100644 --- a/R/ds.mdPattern.R +++ b/R/ds.mdPattern.R @@ -46,6 +46,7 @@ #' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained #' after login. If the \code{datasources} argument is not specified, the default set of #' connections will be used: see \code{\link[DSI]{datashield.connections_default}}. +#' @template classConsistencyCheckTrue #' @return For type='split': A list with one element per study, each containing: #' \describe{ #' \item{pattern}{The missing data pattern matrix for that study} @@ -60,6 +61,7 @@ #' \item{message}{A message describing the validity status} #' } #' @author Xavier EscribĂ  montagut for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export #' @examples #' \dontrun{ @@ -111,17 +113,9 @@ #' datashield.logout(connections) #' } #' -ds.mdPattern <- function(x = NULL, type = 'split', datasources = NULL){ +ds.mdPattern <- function(x = NULL, type = 'split', datasources = NULL, classConsistencyCheck = TRUE){ - # Look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # Ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of a data frame or matrix!", call.=FALSE) @@ -134,10 +128,14 @@ ds.mdPattern <- function(x = NULL, type = 'split', datasources = NULL){ cally <- call("mdPatternDS", x) results <- DSI::datashield.aggregate(datasources, cally) + if(classConsistencyCheck){ + .checkClassConsistency(results) + } + # Process results based on type if(type == "split"){ # Return individual study results - return(results) + return(lapply(results, function(r) { r$class <- NULL; r })) } else if(type == "combine"){ # Pool results across studies @@ -176,7 +174,7 @@ ds.mdPattern <- function(x = NULL, type = 'split', datasources = NULL){ } # Pool the patterns - pooled_pattern <- .pool_md_patterns(patterns_list, study_names) + pooled_pattern <- .poolMdPatterns(patterns_list, study_names) # Check validity of pooled results # Get threshold from first study's results or use a default check @@ -217,8 +215,8 @@ ds.mdPattern <- function(x = NULL, type = 'split', datasources = NULL){ #' @param patterns_list List of pattern matrices from each study #' @param study_names Names of the studies #' @return Pooled pattern matrix -#' @keywords internal -.pool_md_patterns <- function(patterns_list, study_names){ +#' @noRd +.poolMdPatterns <- function(patterns_list, study_names){ # Initialize with first study's pattern structure pooled <- patterns_list[[1]] diff --git a/R/ds.rm.R b/R/ds.rm.R index 652e9e58d..9e104228a 100644 --- a/R/ds.rm.R +++ b/R/ds.rm.R @@ -22,6 +22,7 @@ #' is successful the message \code{"Object(s) '' was deleted."} is returned #' to the client-side. #' @author DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @examples #' \dontrun{ #' @@ -68,15 +69,7 @@ ds.rm<-function(x.names=NULL, datasources=NULL){ - # look for DS connections - if (is.null(datasources)) { - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if (is.null(x.names)) { stop("Please provide the names of the objects to be deleted (eg 'object.name') as the x.names argument", call.=FALSE) diff --git a/dsBase_7.0.0-permissive.tar.gz b/dsBase_7.0.0-permissive.tar.gz index 137855e31..b7e29c284 100644 Binary files a/dsBase_7.0.0-permissive.tar.gz and b/dsBase_7.0.0-permissive.tar.gz differ diff --git a/man/dot-pool_md_patterns.Rd b/man/dot-pool_md_patterns.Rd deleted file mode 100644 index baabf3e92..000000000 --- a/man/dot-pool_md_patterns.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ds.mdPattern.R -\name{.pool_md_patterns} -\alias{.pool_md_patterns} -\title{Pool missing data patterns across studies} -\usage{ -.pool_md_patterns(patterns_list, study_names) -} -\arguments{ -\item{patterns_list}{List of pattern matrices from each study} - -\item{study_names}{Names of the studies} -} -\value{ -Pooled pattern matrix -} -\description{ -Internal function to pool md.pattern results from multiple studies -} -\keyword{internal} diff --git a/man/ds.auc.Rd b/man/ds.auc.Rd index 0ca1a5d37..133a904e2 100644 --- a/man/ds.auc.Rd +++ b/man/ds.auc.Rd @@ -28,4 +28,6 @@ The AUC determines the discriminative ability of a model. } \author{ Demetris Avraam for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.bp_standards.Rd b/man/ds.bp_standards.Rd index edbdd06dd..ff7a31719 100644 --- a/man/ds.bp_standards.Rd +++ b/man/ds.bp_standards.Rd @@ -55,4 +55,6 @@ https://www.nhlbi.nih.gov/sites/default/files/media/docs/hbp_ped.pdf } \author{ Demetris Avraam for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.exists.Rd b/man/ds.exists.Rd index eb9795a02..8569971e5 100644 --- a/man/ds.exists.Rd +++ b/man/ds.exists.Rd @@ -79,4 +79,6 @@ Server function called: \code{exists} } \author{ DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.igb_standards.Rd b/man/ds.igb_standards.Rd index e9ab20f51..686041a65 100644 --- a/man/ds.igb_standards.Rd +++ b/man/ds.igb_standards.Rd @@ -70,4 +70,6 @@ standard is used. } \author{ Demetris Avraam for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.listDisclosureSettings.Rd b/man/ds.listDisclosureSettings.Rd index 5ac64a610..d86ac1326 100644 --- a/man/ds.listDisclosureSettings.Rd +++ b/man/ds.listDisclosureSettings.Rd @@ -114,4 +114,6 @@ Server function called: \code{listDisclosureSettingsDS} } \author{ DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.mdPattern.Rd b/man/ds.mdPattern.Rd index d52730497..05bb06f1a 100644 --- a/man/ds.mdPattern.Rd +++ b/man/ds.mdPattern.Rd @@ -4,7 +4,12 @@ \alias{ds.mdPattern} \title{Display missing data patterns with disclosure control} \usage{ -ds.mdPattern(x = NULL, type = "split", datasources = NULL) +ds.mdPattern( + x = NULL, + type = "split", + datasources = NULL, + classConsistencyCheck = TRUE +) } \arguments{ \item{x}{a character string specifying the name of a data frame or matrix on the @@ -17,6 +22,9 @@ across studies.} \item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified, the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} + +\item{classConsistencyCheck}{logical. If TRUE, checks that the input object has the same +class across all studies. Default TRUE.} } \value{ For type='split': A list with one element per study, each containing: @@ -127,4 +135,6 @@ for disclosure control: } \author{ Xavier EscribĂ  montagut for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/ds.rm.Rd b/man/ds.rm.Rd index 2988826a0..9db0eef5a 100644 --- a/man/ds.rm.Rd +++ b/man/ds.rm.Rd @@ -82,4 +82,6 @@ Server function called: \code{rmDS} } \author{ DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/tests/testthat/perf_files/armadillo_azure-pipeline_perf-profile.csv b/tests/testthat/perf_files/armadillo_azure-pipeline_perf-profile.csv index 3eb977f09..84d295b95 100644 --- a/tests/testthat/perf_files/armadillo_azure-pipeline_perf-profile.csv +++ b/tests/testthat/perf_files/armadillo_azure-pipeline_perf-profile.csv @@ -11,9 +11,11 @@ "ds.asMatrix::perf::0","17.44","0.5","2" "ds.asNumeric::perf:0","16.79","0.5","2" "ds.assign::perf::0","16.75","0.5","2" +"ds.auc::perf::0","20.20","0.5","2" "ds.Boole::perf::0","2.324","0.5","2" "ds.boxPlot::perf::0","5.837","0.5","2" "ds.boxPlotGG::perf::0","6.696","0.5","2" +"ds.bp_standards::perf::0","13.64","0.5","2" "ds.c::perf::0","10.23","0.5","2" "ds.cbind::perf::0","3.814","0.5","2" "ds.changeRefGroup::perf::0","17.98","0.5","2" @@ -41,12 +43,15 @@ "ds.heatmapPlot::perf::0","4.519","0.5","2" "ds.hetcor::perf::0","0.2028","0.5","2" "ds.histogram::perf::0","9.261","0.5","2" +"ds.igb_standards::perf::0","7.719","0.5","2" "ds.isNA::perf::combine:0","23.86","0.5","2" +"ds.isValid::perf::0","22.52","0.5","2" "ds.kurtosis::perf::combine:0","8.377","0.5","2" "ds.length::perf::combine:0","24.04","0.5","2" "ds.levels::perf::combine:0","23.96","0.5","2" "ds.lexis::perf::0","3.760","0.5","2" "ds.list::perf::0","10.03","0.5","2" +"ds.listDisclosureSettings::perf::0","22.08","0.5","2" "ds.log::perf::0","17.30","0.5","2" "ds.ls::perf::combine:0","24.35","0.5","2" "ds.lspline::perf::0","14.17","0.5","2" @@ -59,6 +64,7 @@ "ds.matrixInvert::perf::0","16.49","0.5","2" "ds.matrixMult::perf::0","16.65","0.5","2" "ds.matrixTranspose::perf::0","17.90","0.5","2" +"ds.mdPattern::perf::0","6.701","0.5","2" "ds.mean::perf::combine:0","24.12","0.5","2" "ds.mean::perf::split:0","24.45","0.5","2" "ds.meanSdGp::perf::combine:0","19.84","0.5","2" @@ -76,6 +82,7 @@ "ds.rep::perf::0","17.44","0.5","2" "ds.replaceNA::perf::0","3.292","0.5","2" "ds.reShape::perf::0","17.31","0.5","2" +"ds.rm::perf::0","19.85","0.5","2" "ds.rowColCalc::perf::0","16.70","0.5","2" "ds.rNorm::perf::0","8.597","0.5","2" "ds.rPois::perf::0","8.556","0.5","2" diff --git a/tests/testthat/perf_files/armadillo_github-workflows_perf-profile.csv b/tests/testthat/perf_files/armadillo_github-workflows_perf-profile.csv index d850131ae..e9eb1fa69 100644 --- a/tests/testthat/perf_files/armadillo_github-workflows_perf-profile.csv +++ b/tests/testthat/perf_files/armadillo_github-workflows_perf-profile.csv @@ -1,97 +1,103 @@ "refer_name","rate","lower_tolerance","upper_tolerance" -"conndisconn::perf::simple0","0.1581","0.5","2" -"ds.abs::perf::0","17.27","0.5","2" -"ds.asCharacter::perf::0","16.84","0.5","2" -"ds.asDataMatrix::perf::0","17.44","0.5","2" -"ds.asFactor::perf::0","10.22","0.5","2" -"ds.asFactorSimple::perf::0","17.79","0.5","2" -"ds.asInteger::perf:0","17.61","0.5","2" -"ds.asList::perf:0","22.52","0.5","2" -"ds.asLogical::perf::0","17.46","0.5","2" -"ds.asMatrix::perf::0","17.44","0.5","2" -"ds.asNumeric::perf:0","16.79","0.5","2" -"ds.assign::perf::0","23.51","0.5","2" -"ds.Boole::perf::0","5.479","0.5","2" -"ds.boxPlot::perf::0","5.837","0.5","2" -"ds.boxPlotGG::perf::0","6.696","0.5","2" -"ds.c::perf::0","10.23","0.5","2" -"ds.cbind::perf::0","3.814","0.5","2" -"ds.changeRefGroup::perf::0","17.98","0.5","2" -"ds.class::perf::combine:0","24.90","0.5","2" -"ds.colnames::perf:0","24.83","0.5","2" -"ds.completeCases::perf::combine:0","17.26","0.5","2" -"ds.contourPlot::perf::0","4.593","0.5","2" -"ds.cor::perf::combine:0","7.019","0.5","2" -"ds.corTest::perf::combine:0","22.45","0.5","2" -"ds.cov::perf::combine:0","7.010","0.5","2" -"ds.dataFrame::perf::0","5.943","0.5","2" -"ds.dataFrameFill::perf::0","2.749","0.5","2" -"ds.dataFrameSort::perf::0","14.38","0.5","2" -"ds.dataFrameSubset::perf::0","2.450","0.5","2" -"ds.densityGrid::perf::0","4.653","0.5","2" -"ds.dim::perf::0","23.82","0.5","2" -"ds.dmtC2S::perf::0","16.61","0.5","2" -"ds.elspline::perf::0","16.32","0.5","2" -"ds.exists::perf::combine:0","24.21","0.5","2" -"ds.exp::perf::0","17.18","0.5","2" -"ds.gamlss::perf::0","21.11","0.5","2" -"ds.getWGSR::perf::0","0.6753","0.5","2" -"ds.glmPredict::perf::0","10.04","0.5","2" -"ds.glmSummary::perf::0","10.10","0.5","2" -"ds.heatmapPlot::perf::0","4.519","0.5","2" -"ds.hetcor::perf::0","0.4028","0.5","2" -"ds.histogram::perf::0","9.261","0.5","2" -"ds.isNA::perf::combine:0","23.86","0.5","2" -"ds.isValid::perf::0","33.16","0.5","2" -"ds.kurtosis::perf::combine:0","8.377","0.5","2" -"ds.length::perf::combine:0","24.04","0.5","2" -"ds.levels::perf::combine:0","23.96","0.5","2" -"ds.lexis::perf::0","3.760","0.5","2" -"ds.list::perf::0","10.03","0.5","2" -"ds.log::perf::0","17.30","0.5","2" -"ds.ls::perf::combine:0","24.35","0.5","2" -"ds.lspline::perf::0","14.17","0.5","2" -"ds.make::perf::0","16.81","0.5","2" -"ds.matrix::perf::0","16.140","0.5","2" -"ds.matrixDet::perf::0","16.015","0.5","2" -"ds.matrixDet.report::perf::0","24.038","0.5","2" -"ds.matrixDiag::perf::0","16.109","0.5","2" -"ds.matrixDimnames::perf::0","16.72","0.5","2" -"ds.matrixInvert::perf::0","16.49","0.5","2" -"ds.matrixMult::perf::0","16.65","0.5","2" -"ds.matrixTranspose::perf::0","17.90","0.5","2" -"ds.mean::perf::combine:0","24.12","0.5","2" -"ds.mean::perf::split:0","24.45","0.5","2" -"ds.meanSdGp::perf::combine:0","19.84","0.5","2" -"ds.merge::perf::0","1.217","0.5","2" -"ds.metadata::perf::0","24.58","0.5","2" -"ds.mice::perf::0","3.896","0.5","2" -"ds.names::perf::combine:0","24.22","0.5","2" -"ds.ns::perf::0","28.41","0.5","2" -"ds.numNA::perf::combine:0","29.58","0.5","2" -"ds.qlspline::perf::0","29.40","0.5","2" -"ds.quantileMean::perf::combine:0","8.354","0.5","2" -"ds.rbind::perf::0","8.424","0.5","2" -"ds.rBinom::perf::0","17.489","0.5","2" -"ds.recodeValues::perf::0","16.842","0.5","2" -"ds.rep::perf::0","17.44","0.5","2" -"ds.replaceNA::perf::0","3.292","0.5","2" -"ds.reShape::perf::0","17.31","0.5","2" -"ds.rowColCalc::perf::0","23.48","0.5","2" -"ds.rNorm::perf::0","17.97","0.5","2" -"ds.rPois::perf::0","18.26","0.5","2" -"ds.rUnif::perf::0","17.85","0.5","2" -"ds.sample::perf::0","7.652","0.5","2" -"ds.scatterPlot::perf::0","3.318","0.5","2" -"ds.seq::perf::0","17.55","0.5","2" -"ds.setSeed::perf::0","44.75","0.5","2" -"ds.skewness::perf::combine:0","8.226","0.5","2" -"ds.sqrt::perf::0","16.83","0.5","2" -"ds.summary::perf::0","6.095","0.5","2" -"ds.table::perf::0","22.03","0.5","2" -"ds.tapply.assign::perf::0","30.61","0.5","2" -"ds.tapply::perf::0","41.96","0.5","2" -"ds.unique::perf::combine:0","22.04","0.5","2" -"ds.unList::perf::0","16.70","0.5","2" -"ds.var::perf::combine:0","25.02","0.5","2" -"void::perf::void::0","52590","0.5","2" +"conndisconn::perf::simple0","0.1581","0.333","3" +"ds.abs::perf::0","17.27","0.333","3" +"ds.asCharacter::perf::0","16.84","0.333","3" +"ds.asDataMatrix::perf::0","17.44","0.333","3" +"ds.asFactor::perf::0","10.22","0.333","3" +"ds.asFactorSimple::perf::0","17.79","0.333","3" +"ds.asInteger::perf:0","17.61","0.333","3" +"ds.asList::perf:0","22.52","0.333","3" +"ds.asLogical::perf::0","17.46","0.333","3" +"ds.asMatrix::perf::0","17.44","0.333","3" +"ds.asNumeric::perf:0","16.79","0.333","3" +"ds.assign::perf::0","23.51","0.333","3" +"ds.auc::perf::0","31.06","0.333","3" +"ds.Boole::perf::0","5.479","0.333","3" +"ds.boxPlot::perf::0","5.837","0.333","3" +"ds.boxPlotGG::perf::0","6.696","0.333","3" +"ds.bp_standards::perf::0","20.81","0.333","3" +"ds.c::perf::0","10.23","0.333","3" +"ds.cbind::perf::0","3.814","0.333","3" +"ds.changeRefGroup::perf::0","17.98","0.333","3" +"ds.class::perf::combine:0","24.90","0.333","3" +"ds.colnames::perf:0","24.83","0.333","3" +"ds.completeCases::perf::combine:0","17.26","0.333","3" +"ds.contourPlot::perf::0","4.593","0.333","3" +"ds.cor::perf::combine:0","7.019","0.333","3" +"ds.corTest::perf::combine:0","22.45","0.333","3" +"ds.cov::perf::combine:0","7.010","0.333","3" +"ds.dataFrame::perf::0","4.043","0.333","3" +"ds.dataFrameFill::perf::0","3.549","0.333","3" +"ds.dataFrameSort::perf::0","24.38","0.333","3" +"ds.dataFrameSubset::perf::0","2.450","0.333","3" +"ds.densityGrid::perf::0","4.653","0.333","3" +"ds.dim::perf::0","23.82","0.333","3" +"ds.dmtC2S::perf::0","16.61","0.333","3" +"ds.elspline::perf::0","16.32","0.333","3" +"ds.exists::perf::combine:0","24.21","0.333","3" +"ds.exp::perf::0","17.18","0.333","3" +"ds.gamlss::perf::0","21.11","0.333","3" +"ds.getWGSR::perf::0","0.6753","0.333","3" +"ds.glmPredict::perf::0","10.04","0.333","3" +"ds.glmSummary::perf::0","10.10","0.333","3" +"ds.heatmapPlot::perf::0","4.519","0.333","3" +"ds.hetcor::perf::0","0.4028","0.333","3" +"ds.histogram::perf::0","9.261","0.333","3" +"ds.igb_standards::perf::0","9.796","0.333","3" +"ds.isNA::perf::combine:0","23.86","0.333","3" +"ds.isValid::perf::0","33.16","0.333","3" +"ds.kurtosis::perf::combine:0","8.377","0.333","3" +"ds.length::perf::combine:0","24.04","0.333","3" +"ds.levels::perf::combine:0","23.96","0.333","3" +"ds.lexis::perf::0","3.760","0.333","3" +"ds.list::perf::0","10.03","0.333","3" +"ds.listDisclosureSettings::perf::0","25.17","0.333","3" +"ds.log::perf::0","17.30","0.333","3" +"ds.ls::perf::combine:0","24.35","0.333","3" +"ds.lspline::perf::0","16.17","0.333","3" +"ds.make::perf::0","16.81","0.333","3" +"ds.matrix::perf::0","16.140","0.333","3" +"ds.matrixDet::perf::0","18.015","0.333","3" +"ds.matrixDet.report::perf::0","28.038","0.333","3" +"ds.matrixDiag::perf::0","16.109","0.333","3" +"ds.matrixDimnames::perf::0","16.72","0.333","3" +"ds.matrixInvert::perf::0","16.49","0.333","3" +"ds.matrixMult::perf::0","16.65","0.333","3" +"ds.matrixTranspose::perf::0","17.90","0.333","3" +"ds.mdPattern::perf::0","13.23","0.333","3" +"ds.mean::perf::combine:0","24.12","0.333","3" +"ds.mean::perf::split:0","24.45","0.333","3" +"ds.meanSdGp::perf::combine:0","25.84","0.333","3" +"ds.merge::perf::0","1.217","0.333","3" +"ds.metadata::perf::0","24.58","0.333","3" +"ds.mice::perf::0","3.896","0.333","3" +"ds.names::perf::combine:0","24.22","0.333","3" +"ds.ns::perf::0","14.04","0.333","3" +"ds.numNA::perf::combine:0","29.58","0.333","3" +"ds.qlspline::perf::0","14.37","0.333","3" +"ds.quantileMean::perf::combine:0","8.354","0.333","3" +"ds.rbind::perf::0","3.534","0.333","3" +"ds.rBinom::perf::0","7.932","0.333","3" +"ds.recodeValues::perf::0","16.842","0.333","3" +"ds.rep::perf::0","17.44","0.333","3" +"ds.replaceNA::perf::0","3.292","0.333","3" +"ds.reShape::perf::0","17.31","0.333","3" +"ds.rm::perf::0","30.72","0.333","3" +"ds.rowColCalc::perf::0","23.48","0.333","3" +"ds.rNorm::perf::0","8.623","0.333","3" +"ds.rPois::perf::0","8.659","0.333","3" +"ds.rUnif::perf::0","8.175","0.333","3" +"ds.sample::perf::0","7.652","0.333","3" +"ds.scatterPlot::perf::0","3.318","0.333","3" +"ds.seq::perf::0","17.55","0.333","3" +"ds.setSeed::perf::0","20.88","0.333","3" +"ds.skewness::perf::combine:0","8.226","0.333","3" +"ds.sqrt::perf::0","16.83","0.333","3" +"ds.summary::perf::0","6.095","0.333","3" +"ds.table::perf::0","10.91","0.333","3" +"ds.tapply.assign::perf::0","30.61","0.333","3" +"ds.tapply::perf::0","41.96","0.333","3" +"ds.unique::perf::combine:0","22.04","0.333","3" +"ds.unList::perf::0","16.70","0.333","3" +"ds.var::perf::combine:0","25.02","0.333","3" +"void::perf::void::0","52590","0.333","3" diff --git a/tests/testthat/perf_files/opal_github-workflows_perf-profile.csv b/tests/testthat/perf_files/opal_github-workflows_perf-profile.csv index b1329d947..693040be8 100644 --- a/tests/testthat/perf_files/opal_github-workflows_perf-profile.csv +++ b/tests/testthat/perf_files/opal_github-workflows_perf-profile.csv @@ -1,97 +1,103 @@ "refer_name","rate","lower_tolerance","upper_tolerance" -"conndisconn::perf::simple0","0.1654","0.5","2" -"ds.abs::perf::0","12.94","0.5","2" -"ds.asCharacter::perf::0","14.19","0.5","2" -"ds.asDataMatrix::perf::0","14.88","0.5","2" -"ds.asFactor::perf::0","7.273","0.5","2" -"ds.asFactorSimple::perf::0","14.89","0.5","2" -"ds.asInteger::perf:0","15.17","0.5","2" -"ds.asList::perf:0","14.83","0.5","2" -"ds.asLogical::perf::0","15.19","0.5","2" -"ds.asMatrix::perf::0","15.25","0.5","2" -"ds.asNumeric::perf:0","15.18","0.5","2" -"ds.assign::perf::0","15.79","0.5","2" -"ds.Boole::perf::0","5.393","0.5","2" -"ds.boxPlot::perf::0","4.674","0.5","2" -"ds.boxPlotGG::perf::0","4.526","0.5","2" -"ds.c::perf::0","7.516","0.5","2" -"ds.cbind::perf::0","2.756","0.5","2" -"ds.changeRefGroup::perf::0","15.41","0.5","2" -"ds.class::perf::combine:0","14.86","0.5","2" -"ds.colnames::perf:0","15.85","0.5","2" -"ds.completeCases::perf::combine:0","14.254","0.5","2" -"ds.contourPlot::perf::0","4.599","0.5","2" -"ds.cor::perf::combine:0","7.364","0.5","2" -"ds.corTest::perf::combine:0","14.95","0.5","2" -"ds.cov::perf::combine:0","13.18","0.5","2" -"ds.dataFrame::perf::0","2.488","0.5","2" -"ds.dataFrameFill::perf::0","1.098","0.5","2" -"ds.dataFrameSort::perf::0","8.263","0.5","2" -"ds.dataFrameSubset::perf::0","2.043","0.5","2" -"ds.densityGrid::perf::0","2.365","0.5","2" -"ds.dim::perf::0","8.687","0.5","2" -"ds.dmtC2S::perf::0","8.161","0.5","2" -"ds.elspline::perf::0","9.253","0.5","2" -"ds.exists::perf::combine:0","10.02","0.5","2" -"ds.exp::perf::0","8.644","0.5","2" -"ds.gamlss::perf::0","6.853","0.5","2" -"ds.getWGSR::perf::0","0.685","0.5","2" -"ds.glmPredict::perf::0","5.006","0.5","2" -"ds.glmSummary::perf::0","4.979","0.5","2" -"ds.heatmapPlot::perf::0","2.409","0.5","2" -"ds.hetcor::perf::0","0.3609","0.5","2" -"ds.histogram::perf::0","3.939","0.5","2" -"ds.isNA::perf::combine:0","8.677","0.5","2" -"ds.isValid::perf::0","9.110","0.5","2" -"ds.kurtosis::perf::combine:0","2.872","0.5","2" -"ds.length::perf::combine:0","8.551","0.5","2" -"ds.levels::perf::combine:0","8.594","0.5","2" -"ds.lexis::perf::0","2.410","0.5","2" -"ds.list::perf::0","4.415","0.5","2" -"ds.log::perf::0","8.415","0.5","2" -"ds.ls::perf::combine:0","8.689","0.5","2" -"ds.lspline::perf::0","9.241","0.5","2" -"ds.make::perf::0","10.92","0.5","2" -"ds.matrix::perf::0","8.422","0.5","2" -"ds.matrixDet::perf::0","9.613","0.5","2" -"ds.matrixDet.report::perf::0","9.829","0.5","2" -"ds.matrixDiag::perf::0","9.700","0.5","2" -"ds.matrixDimnames::perf::0","9.754","0.5","2" -"ds.matrixInvert::perf::0","9.728","0.5","2" -"ds.matrixMult::perf::0","9.876","0.5","2" -"ds.matrixTranspose::perf::0","9.746","0.5","2" -"ds.mean::perf::combine:0","8.690","0.5","2" -"ds.mean::perf::split:0","9.823","0.5","2" -"ds.meanSdGp::perf::combine:0","8.285","0.5","2" -"ds.merge::perf::0","1.207","0.5","2" -"ds.metadata::perf::0","9.529","0.5","2" -"ds.mice::perf::0","3.166","0.5","2" -"ds.names::perf::combine:0","8.620","0.5","2" -"ds.ns::perf::0","8.999","0.5","2" -"ds.numNA::perf::combine:0","8.411","0.5","2" -"ds.qlspline::perf::0","9.053","0.5","2" -"ds.quantileMean::perf::combine:0","2.896","0.5","2" -"ds.rbind::perf::0","1.726","0.5","2" -"ds.rBinom::perf::0","3.925","0.5","2" -"ds.recodeValues::perf::0","8.478","0.5","2" -"ds.rep::perf::0","8.645","0.5","2" -"ds.replaceNA::perf::0","1.280","0.5","2" -"ds.reShape::perf::0","8.211","0.5","2" -"ds.rNorm::perf::0","3.881","0.5","2" -"ds.rowColCalc::perf::0","8.905","0.5","2" -"ds.rPois::perf::0","3.848","0.5","2" -"ds.rUnif::perf::0","3.864","0.5","2" -"ds.sample::perf::0","3.764","0.5","2" -"ds.seq::perf::0","8.522","0.5","2" -"ds.setSeed::perf::0","8.990","0.5","2" -"ds.skewness::perf::combine:0","2.889","0.5","2" -"ds.sqrt::perf::0","8.666","0.5","2" -"ds.summary::perf::0","2.149","0.5","2" -"ds.scatterPlot::perf::0","2.163","0.5","2" -"ds.table::perf::0","5.031","0.5","2" -"ds.tapply.assign::perf::0","8.062","0.5","2" -"ds.tapply::perf::0","8.194","0.5","2" -"ds.unique::perf::combine:0","8.656","0.5","2" -"ds.unList::perf::0","8.128","0.5","2" -"ds.var::perf::combine:0","7.6420","0.5","2" -"void::perf::void::0","46340","0.5","2" +"conndisconn::perf::simple0","0.1654","0.333","3" +"ds.abs::perf::0","12.94","0.333","3" +"ds.asCharacter::perf::0","14.19","0.333","3" +"ds.asDataMatrix::perf::0","14.88","0.333","3" +"ds.asFactor::perf::0","7.273","0.333","3" +"ds.asFactorSimple::perf::0","14.89","0.333","3" +"ds.asInteger::perf:0","15.17","0.333","3" +"ds.asList::perf:0","14.83","0.333","3" +"ds.asLogical::perf::0","15.19","0.333","3" +"ds.asMatrix::perf::0","15.25","0.333","3" +"ds.asNumeric::perf:0","15.18","0.333","3" +"ds.assign::perf::0","15.79","0.333","3" +"ds.auc::perf::0","11.14","0.333","3" +"ds.Boole::perf::0","5.393","0.333","3" +"ds.boxPlot::perf::0","4.674","0.333","3" +"ds.boxPlotGG::perf::0","4.526","0.333","3" +"ds.bp_standard::perf::0","9.806","0.333","3" +"ds.c::perf::0","7.516","0.333","3" +"ds.cbind::perf::0","2.756","0.333","3" +"ds.changeRefGroup::perf::0","15.41","0.333","3" +"ds.class::perf::combine:0","14.86","0.333","3" +"ds.colnames::perf:0","15.85","0.333","3" +"ds.completeCases::perf::combine:0","14.254","0.333","3" +"ds.contourPlot::perf::0","4.599","0.333","3" +"ds.cor::perf::combine:0","7.364","0.333","3" +"ds.corTest::perf::combine:0","14.95","0.333","3" +"ds.cov::perf::combine:0","13.18","0.333","3" +"ds.dataFrame::perf::0","2.488","0.333","3" +"ds.dataFrameFill::perf::0","1.556","0.333","3" +"ds.dataFrameSort::perf::0","13.83","0.333","3" +"ds.dataFrameSubset::perf::0","1.559","0.333","3" +"ds.densityGrid::perf::0","5.385","0.333","3" +"ds.dim::perf::0","14.92","0.333","3" +"ds.dmtC2S::perf::0","14.11","0.333","3" +"ds.elspline::perf::0","14.55","0.333","3" +"ds.exists::perf::combine:0","19.02","0.333","3" +"ds.exp::perf::0","14.84","0.333","3" +"ds.gamlss::perf::0","6.853","0.333","3" +"ds.getWGSR::perf::0","0.785","0.333","3" +"ds.glmPredict::perf::0","7.06","0.333","3" +"ds.glmSummary::perf::0","8.19","0.333","3" +"ds.heatmapPlot::perf::0","4.509","0.333","3" +"ds.hetcor::perf::0","0.4609","0.333","3" +"ds.histogram::perf::0","8.139","0.333","3" +"ds.igb_standards::perf::0","17.639","0.333","3" +"ds.isNA::perf::combine:0","18.677","0.333","3" +"ds.isValid::perf::0","9.230","0.333","3" +"ds.kurtosis::perf::combine:0","3.684","0.333","3" +"ds.length::perf::combine:0","8.480","0.333","3" +"ds.levels::perf::combine:0","10.724","0.333","3" +"ds.lexis::perf::0","5.610","0.333","3" +"ds.list::perf::0","9.915","0.333","3" +"ds.listDisclosureSettings::perf::0","9.170","0.333","3" +"ds.log::perf::0","19.415","0.333","3" +"ds.ls::perf::combine:0","9.179","0.333","3" +"ds.lspline::perf::0","9.741","0.333","3" +"ds.make::perf::0","19.92","0.333","3" +"ds.matrix::perf::0","18.422","0.333","3" +"ds.matrixDet::perf::0","20.33","0.333","3" +"ds.matrixDet.report::perf::0","20.829","0.333","3" +"ds.matrixDiag::perf::0","10.40","0.333","3" +"ds.matrixDimnames::perf::0","9.0954","0.333","3" +"ds.matrixInvert::perf::0","9.728","0.333","3" +"ds.matrixMult::perf::0","9.876","0.333","3" +"ds.matrixTranspose::perf::0","9.446","0.333","3" +"ds.mdPattern::perf::0","7.546","0.333","3" +"ds.mean::perf::combine:0","8.690","0.333","3" +"ds.mean::perf::split:0","9.823","0.333","3" +"ds.meanSdGp::perf::combine:0","8.585","0.333","3" +"ds.merge::perf::0","1.407","0.333","3" +"ds.metadata::perf::0","9.529","0.333","3" +"ds.mice::perf::0","2.596","0.333","3" +"ds.names::perf::combine:0","8.620","0.333","3" +"ds.ns::perf::0","8.999","0.333","3" +"ds.numNA::perf::combine:0","17.65","0.333","3" +"ds.qlspline::perf::0","9.053","0.333","3" +"ds.quantileMean::perf::combine:0","2.896","0.333","3" +"ds.rbind::perf::0","1.726","0.333","3" +"ds.rBinom::perf::0","3.925","0.333","3" +"ds.recodeValues::perf::0","17.57","0.333","3" +"ds.rep::perf::0","10.66","0.333","3" +"ds.replaceNA::perf::0","1.280","0.333","3" +"ds.reShape::perf::0","18.45","0.333","3" +"ds.rm::perf::0","19.74","0.333","3" +"ds.rNorm::perf::0","6.568","0.333","3" +"ds.rowColCalc::perf::0","18.31","0.333","3" +"ds.rPois::perf::0","6.344","0.333","3" +"ds.rUnif::perf::0","6.643","0.333","3" +"ds.sample::perf::0","4.773","0.333","3" +"ds.seq::perf::0","8.522","0.333","3" +"ds.setSeed::perf::0","8.990","0.333","3" +"ds.skewness::perf::combine:0","6.102","0.333","3" +"ds.sqrt::perf::0","8.666","0.333","3" +"ds.summary::perf::0","3.275","0.333","3" +"ds.scatterPlot::perf::0","4.100","0.333","3" +"ds.table::perf::0","5.031","0.333","3" +"ds.tapply.assign::perf::0","8.062","0.333","3" +"ds.tapply::perf::0","8.194","0.333","3" +"ds.unique::perf::combine:0","18.12","0.333","3" +"ds.unList::perf::0","16.49","0.333","3" +"ds.var::perf::combine:0","16.39","0.333","3" +"void::perf::void::0","85900","0.333","3" diff --git a/tests/testthat/test-arg-ds.auc.R b/tests/testthat/test-arg-ds.auc.R index ade352110..55978417a 100644 --- a/tests/testthat/test-arg-ds.auc.R +++ b/tests/testthat/test-arg-ds.auc.R @@ -15,6 +15,8 @@ # context("ds.auc::arg::setup") +connect.studies.dataset.cnsim(list("LAB_TSC")) + # # Tests # @@ -33,4 +35,5 @@ test_that("ds.auc errors for null pred or y", { # # context("ds.auc::arg::shutdown") +disconnect.studies.dataset.cnsim() # context("ds.auc::arg::done") diff --git a/tests/testthat/test-perf-ds.auc.R b/tests/testthat/test-perf-ds.auc.R new file mode 100644 index 000000000..e961c8840 --- /dev/null +++ b/tests/testthat/test-perf-ds.auc.R @@ -0,0 +1,52 @@ + +# +# Set up +# + +# context("ds.auc::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TRIG", "DIS_DIAB")) +ds.glmSLMA('D$DIS_DIAB~D$LAB_TRIG', family = "binomial", newobj = "auc.glm") +ds.glmPredict("auc.glm", output.type = "link", se.fit = FALSE, newobj = "auc.pred") + +# +# Tests +# + +# context("ds.auc::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.auc(pred = "auc.pred$fit", y = "auc.glm$y") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.auc::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.auc::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.auc::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.auc::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.auc::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.auc::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.auc::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.auc::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.auc::perf::done") diff --git a/tests/testthat/test-perf-ds.bp_standards.R b/tests/testthat/test-perf-ds.bp_standards.R new file mode 100644 index 000000000..c59cf0317 --- /dev/null +++ b/tests/testthat/test-perf-ds.bp_standards.R @@ -0,0 +1,52 @@ + +# +# Set up +# + +# context("ds.bp_standards::perf::setup") +connect.studies.dataset.anthro(list("age", "sex", "weight", "height", "muac")) +ds.make("D$age/12", "age.years") # nolint: nonportable_path_linter. DataSHIELD expression, not a file path +ds.make("D$muac*7", "bp.value") + +# +# Tests +# + +# context("ds.bp_standards::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.bp_standards(sex = "D$sex", age = "age.years", height = "D$height", bp = "bp.value", systolic = TRUE, newobj = "bp.out") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.bp_standards::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.bp_standards::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.bp_standards::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.bp_standards::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.bp_standards::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.bp_standards::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.bp_standards::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.bp_standards::perf::shutdown") +disconnect.studies.dataset.anthro() +# context("ds.bp_standards::perf::done") diff --git a/tests/testthat/test-perf-ds.igb_standards.R b/tests/testthat/test-perf-ds.igb_standards.R new file mode 100644 index 000000000..12dd2e6be --- /dev/null +++ b/tests/testthat/test-perf-ds.igb_standards.R @@ -0,0 +1,52 @@ + +# +# Set up +# + +# context("ds.igb_standards::perf::setup") +connect.studies.dataset.anthro(list("age", "sex", "weight", "height", "muac")) +ds.make("(D$age*0)+280", "gagebrth") +ds.recodeValues(var.name = "D$sex", values2replace.vector = c(1, 2), new.values.vector = c("Male", "Female"), newobj = "sex.label") + +# +# Tests +# + +# context("ds.igb_standards::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.igb_standards(gagebrth = "gagebrth", z = 0, p = 50, var = "lencm", sex = "sex.label", fun = "igb_centile2value", newobj = "igb.out") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.igb_standards::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.igb_standards::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.igb_standards::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.igb_standards::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.igb_standards::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.igb_standards::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.igb_standards::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.igb_standards::perf::shutdown") +disconnect.studies.dataset.anthro() +# context("ds.igb_standards::perf::done") diff --git a/tests/testthat/test-perf-ds.listDisclosureSettings.R b/tests/testthat/test-perf-ds.listDisclosureSettings.R new file mode 100644 index 000000000..9de207f1a --- /dev/null +++ b/tests/testthat/test-perf-ds.listDisclosureSettings.R @@ -0,0 +1,50 @@ + +# +# Set up +# + +# context("ds.listDisclosureSettings::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_HDL")) + +# +# Tests +# + +# context("ds.listDisclosureSettings::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.listDisclosureSettings() + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.listDisclosureSettings::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.listDisclosureSettings::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.listDisclosureSettings::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.listDisclosureSettings::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.listDisclosureSettings::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.listDisclosureSettings::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.listDisclosureSettings::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.listDisclosureSettings::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.listDisclosureSettings::perf::done") diff --git a/tests/testthat/test-perf-ds.mdPattern.R b/tests/testthat/test-perf-ds.mdPattern.R new file mode 100644 index 000000000..3c17fb465 --- /dev/null +++ b/tests/testthat/test-perf-ds.mdPattern.R @@ -0,0 +1,50 @@ + +# +# Set up +# + +# context("ds.mdPattern::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG", "LAB_HDL")) + +# +# Tests +# + +# context("ds.mdPattern::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.mdPattern(x = "D", type = "split") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.mdPattern::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.mdPattern::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.mdPattern::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.mdPattern::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.mdPattern::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.mdPattern::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.mdPattern::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.mdPattern::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.mdPattern::perf::done") diff --git a/tests/testthat/test-perf-ds.rm.R b/tests/testthat/test-perf-ds.rm.R new file mode 100644 index 000000000..20d3765bc --- /dev/null +++ b/tests/testthat/test-perf-ds.rm.R @@ -0,0 +1,50 @@ + +# +# Set up +# + +# context("ds.rm::perf::setup") +connect.studies.dataset.survival(list("survtime", "time.id", "female")) + +# +# Tests +# + +# context("ds.rm::perf::0") +test_that("performance", { + .durationSec <- perf.testduration() + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.rm("nonexistant_object") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.rm::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.rm::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.rm::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.rm::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.rm::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.rm::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.rm::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.rm::perf::shutdown") +disconnect.studies.dataset.survival() +# context("ds.rm::perf::done") diff --git a/tests/testthat/test-smk-ds.auc.R b/tests/testthat/test-smk-ds.auc.R new file mode 100644 index 000000000..4d99fe3e5 --- /dev/null +++ b/tests/testthat/test-smk-ds.auc.R @@ -0,0 +1,71 @@ + +# +# Set up +# + +# context("ds.auc::smk::setup") + +connect.studies.dataset.cnsim(list("LAB_TRIG", "DIS_DIAB")) + +test_that("setup", { + ds_expect_variables(c("D")) +}) + +ds.glmSLMA('D$DIS_DIAB~D$LAB_TRIG', family = "binomial", newobj = "auc.glm") +ds.glmPredict("auc.glm", output.type = "link", se.fit = FALSE, newobj = "auc.pred") + +# +# Tests +# + +# context("ds.auc::smk") +test_that("simple auc", { + res <- ds.auc(pred = "auc.pred$fit", y = "auc.glm$y") + + expect_length(res, 3) + for (study.res in res) { + expect_named(study.res, c("AUC", "se")) + expect_true(study.res$AUC > 0.5 && study.res$AUC < 1) + expect_true(study.res$se > 0) + } +}) + +test_that("fails if pred does not exist", { + expect_error( + ds.auc(pred = "nonexistent_object", y = "auc.glm$y"), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "The server-side object 'nonexistent_object' does not exist") + } +}) + +test_that("fails if y does not exist", { + expect_error( + ds.auc(pred = "auc.pred$fit", y = "nonexistent_object"), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "The server-side object 'nonexistent_object' does not exist") + } +}) + +# +# Done +# + +# context("ds.auc::smk::shutdown") + +test_that("shutdown", { + ds_expect_variables(c("D", "auc.glm", "auc.pred")) +}) + +disconnect.studies.dataset.cnsim() + +# context("ds.auc::smk::done") diff --git a/tests/testthat/test-smk-ds.bp_standards.R b/tests/testthat/test-smk-ds.bp_standards.R new file mode 100644 index 000000000..5e1c3c50c --- /dev/null +++ b/tests/testthat/test-smk-ds.bp_standards.R @@ -0,0 +1,56 @@ + +# +# Set up +# + +# context("ds.bp_standards::smk::setup") + +connect.studies.dataset.anthro(list("age", "sex", "weight", "height", "muac")) + +test_that("setup", { + ds_expect_variables(c("D")) +}) + +ds.make("D$age/12", "age.years") # nolint: nonportable_path_linter. DataSHIELD expression, not a file path +ds.make("D$muac*7", "bp.value") + +# +# Tests +# + +# context("ds.bp_standards::smk") +test_that("simple bp_standards", { + ds.bp_standards(sex = "D$sex", age = "age.years", height = "D$height", bp = "bp.value", systolic = TRUE, newobj = "bp.out") + + res.class <- ds.class("bp.out") + for (study.class in res.class) { + expect_equal(study.class, "list") + } +}) + +test_that("fails if an input does not exist", { + expect_error( + ds.bp_standards(sex = "D$sex", age = "age.years", height = "D$height", bp = "nonexistent_object", systolic = TRUE), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "The server-side object 'nonexistent_object' does not exist") + } +}) + +# +# Done +# + +# context("ds.bp_standards::smk::shutdown") + +test_that("shutdown", { + ds_expect_variables(c("D", "age.years", "bp.value", "bp.out")) +}) + +disconnect.studies.dataset.anthro() + +# context("ds.bp_standards::smk::done") diff --git a/tests/testthat/test-smk-ds.igb_standards.R b/tests/testthat/test-smk-ds.igb_standards.R new file mode 100644 index 000000000..03d1454d3 --- /dev/null +++ b/tests/testthat/test-smk-ds.igb_standards.R @@ -0,0 +1,56 @@ + +# +# Set up +# + +# context("ds.igb_standards::smk::setup") + +connect.studies.dataset.anthro(list("age", "sex", "weight", "height", "muac")) + +test_that("setup", { + ds_expect_variables(c("D")) +}) + +ds.make("(D$age*0)+280", "gagebrth") +ds.recodeValues(var.name = "D$sex", values2replace.vector = c(1, 2), new.values.vector = c("Male", "Female"), newobj = "sex.label") + +# +# Tests +# + +# context("ds.igb_standards::smk") +test_that("simple igb_standards", { + ds.igb_standards(gagebrth = "gagebrth", z = 0, p = 50, var = "lencm", sex = "sex.label", fun = "igb_centile2value", newobj = "igb.out") + + res.class <- ds.class("igb.out") + for (study.class in res.class) { + expect_equal(study.class, "numeric") + } +}) + +test_that("fails if an input does not exist", { + expect_error( + ds.igb_standards(gagebrth = "nonexistent_object", z = 0, p = 50, var = "lencm", sex = "sex.label", fun = "igb_centile2value"), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "The server-side object 'nonexistent_object' does not exist") + } +}) + +# +# Done +# + +# context("ds.igb_standards::smk::shutdown") + +test_that("shutdown", { + ds_expect_variables(c("D", "gagebrth", "sex.label", "igb.out")) +}) + +disconnect.studies.dataset.anthro() + +# context("ds.igb_standards::smk::done") diff --git a/tests/testthat/test-smk-ds.mdPattern.R b/tests/testthat/test-smk-ds.mdPattern.R new file mode 100644 index 000000000..b2367f87e --- /dev/null +++ b/tests/testthat/test-smk-ds.mdPattern.R @@ -0,0 +1,86 @@ + +# +# Set up +# + +# context("ds.mdPattern::smk::setup") + +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG", "LAB_HDL")) + +test_that("setup", { + ds_expect_variables(c("D")) +}) + +# +# Tests +# + +# context("ds.mdPattern::smk::split") +test_that("simple mdPattern, split", { + res <- ds.mdPattern(x = "D", type = "split") + + expect_length(res, 3) + for (study.res in res) { + expect_named(study.res, c("pattern", "valid", "message")) + expect_true(is.matrix(study.res$pattern)) + } +}) + +# context("ds.mdPattern::smk::combine") +test_that("simple mdPattern, combine", { + caught_warnings <- capture_warnings( + res <- ds.mdPattern(x = "D", type = "combine") + ) + + expect_named(res, c("pattern", "valid", "message", "studies")) + expect_true(any(grepl("Disclosure control", caught_warnings))) + expect_true(is.matrix(res$pattern)) +}) + +test_that("fails if the object does not exist", { + expect_error( + ds.mdPattern(x = "nonexistent_object"), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "The server-side object 'nonexistent_object' does not exist") + } +}) + +test_that("fails if the object is not a data.frame or matrix", { + expect_error( + ds.mdPattern(x = "D$LAB_TSC"), + "There are some DataSHIELD errors, list them with datashield.errors()", + fixed = TRUE + ) + + res.errors <- DSI::datashield.errors() + for (study.errors in res.errors) { + expect_match(study.errors, "must be of type data.frame or matrix") + } +}) + +test_that("class consistency check aborts when classes differ across studies", { + ds.asDataMatrix(x.name = "D", newobj = "mixed.class", datasources = ds.test_env$connections[1]) + ds.assign(toAssign = "D", newobj = "mixed.class", datasources = ds.test_env$connections[2:3]) + + expect_error(ds.mdPattern(x = "mixed.class"), "not of the same class in all studies") + expect_no_error(ds.mdPattern(x = "mixed.class", classConsistencyCheck = FALSE)) +}) + +# +# Done +# + +# context("ds.mdPattern::smk::shutdown") + +test_that("shutdown", { + ds_expect_variables(c("D", "mixed.class")) +}) + +disconnect.studies.dataset.cnsim() + +# context("ds.mdPattern::smk::done")