From 66b582109e570d817a4411ab609cdadc6377bc97 Mon Sep 17 00:00:00 2001 From: Kai Gu Date: Mon, 25 Sep 2023 13:28:14 +0800 Subject: [PATCH] remove mcr related codes --- DESCRIPTION | 1 - NAMESPACE | 5 - R/autoplot.R | 24 +- R/mcr.R | 47 ++-- R/pkg_methods.R | 7 +- R/referenceInterval.R | 2 +- _pkgdown.yml | 4 - cran-comments.md | 8 +- inst/WORDLIST | 11 +- man/autoplot.Rd | 14 +- man/calcBias.Rd | 37 --- man/getCoefficients.Rd | 28 --- man/getOutlier.Rd | 3 +- man/mcreg.Rd | 82 ------- man/printSummary.Rd | 28 --- man/refInterval.Rd | 2 +- man/show.Rd | 4 +- .../autoplot-basummary-with-absolute-diff.svg | 2 +- .../autoplot-basummary-with-relative-diff.svg | 2 +- ...toplot-mcresult-with-default-arguments.svg | 230 ------------------ ...oplot-mcresult-with-multiple-arguments.svg | 229 ----------------- tests/testthat/test-autoplot.R | 58 ++--- tests/testthat/test-mcr.R | 122 +++++----- tests/testthat/test-pkg_methods.R | 7 +- vignettes/mcradds.Rmd | 26 +- 25 files changed, 162 insertions(+), 821 deletions(-) delete mode 100644 man/calcBias.Rd delete mode 100644 man/getCoefficients.Rd delete mode 100644 man/mcreg.Rd delete mode 100644 man/printSummary.Rd delete mode 100644 tests/testthat/_snaps/autoplot/autoplot-mcresult-with-default-arguments.svg delete mode 100644 tests/testthat/_snaps/autoplot/autoplot-mcresult-with-multiple-arguments.svg diff --git a/DESCRIPTION b/DESCRIPTION index 6c9f602..1a3e291 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,7 +33,6 @@ Imports: Suggests: dplyr, knitr, - mcr, rmarkdown, spelling, testthat (>= 3.0.0), diff --git a/NAMESPACE b/NAMESPACE index 4497d0c..fb72fb6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,23 +6,18 @@ export(VCAinference) export(anovaVCA) export(aucTest) export(blandAltman) -export(calcBias) export(cat_with_newline) export(diagTab) export(dixon_outlier) export(esd.critical) -export(getCoefficients) export(h_difference) export(h_factor) export(h_fmt_est) export(h_fmt_num) export(h_fmt_range) export(h_summarize) -export(mcreg) -export(mcreg2) export(nonparRI) export(pearsonTest) -export(printSummary) export(refInterval) export(robustRI) export(size_ci_corr) diff --git a/R/autoplot.R b/R/autoplot.R index 52dc2bd..d739f94 100644 --- a/R/autoplot.R +++ b/R/autoplot.R @@ -11,8 +11,8 @@ #' default is FALSE. #' @param loa.line (`logical`)\cr whether to plot limit of agreement line, default is TRUE. #' @param ref.line.params,ci.line.params,loa.line.params (`list`)\cr parameters -#' (color, linetype, size) for the argument 'ref.line', 'ci.line' and 'loa.line'; -#' eg. ref.line.params = list(col = "blue", linetype = "solid", size = 1). +#' (color, linetype, linewidth) for the argument 'ref.line', 'ci.line' and 'loa.line'; +#' eg. ref.line.params = list(col = "blue", linetype = "solid", linewidth = 1). #' @param label (`logical`)\cr whether to add specific value label for each line #' (ref.line, ci.line and loa.line). Only be shown when the line is defined as TRUE. #' @param label.digits (`integer`)\cr the number of digits after the decimal point @@ -29,16 +29,10 @@ #' @export #' #' @examples -#' # Using creatinine dataset from `mcr` package -#' data(creatinine, package = "mcr") -#' object <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) -#' autoplot(object) -#' autoplot(object, type = "relative") -#' #' # Specify the type for difference plot #' data("platelet") #' object <- blandAltman(x = platelet$Comparative, y = platelet$Candidate) -#' autoplot(object, type = "absolute") +#' autoplot(object) #' autoplot(object, type = "relative") #' #' # Set the addition parameters for `geom_point` @@ -182,7 +176,7 @@ setMethod( yintercept = statmat["mean"], col = if (is.null(ref.line.params[["col"]])) 1 else ref.line.params[["col"]], linetype = if (is.null(ref.line.params[["linetype"]])) 1 else ref.line.params[["linetype"]], - size = if (is.null(ref.line.params[["size"]])) 0.9 else ref.line.params[["size"]] + linewidth = if (is.null(ref.line.params[["linewidth"]])) 0.9 else ref.line.params[["linewidth"]] ) if (label) { @@ -203,13 +197,13 @@ setMethod( yintercept = statmat["ci_lr"], col = if (is.null(ci.line.params[["col"]])) 1 else ci.line.params[["col"]], linetype = if (is.null(ci.line.params[["linetype"]])) 1 else ci.line.params[["linetype"]], - size = if (is.null(ci.line.params[["size"]])) 0.8 else ci.line.params[["size"]] + linewidth = if (is.null(ci.line.params[["linewidth"]])) 0.8 else ci.line.params[["size"]] ) + geom_hline( yintercept = statmat["ci_ur"], col = if (is.null(ci.line.params[["col"]])) 1 else ci.line.params[["col"]], linetype = if (is.null(ci.line.params[["linetype"]])) 1 else ci.line.params[["linetype"]], - size = if (is.null(ci.line.params[["size"]])) 0.8 else ci.line.params[["size"]] + linewidth = if (is.null(ci.line.params[["linewidth"]])) 0.8 else ci.line.params[["linewidth"]] ) if (label) { @@ -237,13 +231,13 @@ setMethod( yintercept = statmat["limit_lr"], col = if (is.null(loa.line.params[["col"]])) 1 else loa.line.params[["col"]], linetype = if (is.null(loa.line.params[["linetype"]])) 1 else loa.line.params[["linetype"]], - size = if (is.null(loa.line.params[["size"]])) 0.8 else loa.line.params[["size"]] + linewidth = if (is.null(loa.line.params[["linewidth"]])) 0.8 else loa.line.params[["linewidth"]] ) + geom_hline( yintercept = statmat["limit_ur"], col = if (is.null(loa.line.params[["col"]])) 1 else loa.line.params[["col"]], linetype = if (is.null(loa.line.params[["linetype"]])) 1 else loa.line.params[["linetype"]], - size = if (is.null(loa.line.params[["size"]])) 0.8 else loa.line.params[["size"]] + linewidth = if (is.null(loa.line.params[["linewidth"]])) 0.8 else loa.line.params[["linewidth"]] ) if (label) { @@ -308,6 +302,7 @@ setMethod( #' @export #' #' @examples +#' \dontrun{ #' # Using the default arguments for regression plot #' data("platelet") #' fit <- mcreg2( @@ -323,6 +318,7 @@ setMethod( #' legend.title = FALSE, #' legend.digits = 4 #' ) +#' } setMethod( f = "autoplot", signature = c("MCR"), diff --git a/R/mcr.R b/R/mcr.R index 9614c63..02114ea 100644 --- a/R/mcr.R +++ b/R/mcr.R @@ -16,11 +16,9 @@ #' method.reg = "Deming", method.ci = "jackknife" #' ) #' printSummary(fit) -printSummary <- function(...) { - mcr::printSummary(...) -} - - +# printSummary <- function(...) { +# mcr::printSummary(...) +# } # getCoefficients ---- #' Get Regression Coefficients @@ -39,11 +37,9 @@ printSummary <- function(...) { #' method.reg = "Deming", method.ci = "jackknife" #' ) #' getCoefficients(fit) -getCoefficients <- function(...) { - mcr::getCoefficients(...) -} - - +# getCoefficients <- function(...) { +# mcr::getCoefficients(...) +# } # mcreg ---- #' Comparison of Two Measurement Methods Using Regression Analysis @@ -65,9 +61,9 @@ getCoefficients <- function(...) { #' ) #' printSummary(fit) #' getCoefficients(fit) -mcreg <- function(...) { - mcr::mcreg(...) -} +# mcreg <- function(...) { +# mcr::mcreg(...) +# } #' @rdname mcreg #' @aliases mcreg @@ -80,16 +76,15 @@ mcreg <- function(...) { #' x = platelet$Comparative, y = platelet$Candidate, #' method.reg = "Deming", method.ci = "jackknife" #' ) -mcreg2 <- function(...) { - fit <- mcr::mcreg(...) - MCR( - data = fit@data, - coef = fit@glob.coef, - mnames = fit@mnames, - regmeth = fit@regmeth - ) -} - +# mcreg2 <- function(...) { +# fit <- mcr::mcreg(...) +# MCR( +# data = fit@data, +# coef = fit@glob.coef, +# mnames = fit@mnames, +# regmeth = fit@regmeth +# ) +# } # calcBias ---- #' Systematical Bias Between Reference Method and Test Method @@ -114,6 +109,6 @@ mcreg2 <- function(...) { #' calcBias(fit, x.levels = c(30, 200)) #' calcBias(fit, x.levels = c(30, 200), type = "proportional") #' calcBias(fit, x.levels = c(30, 200), type = "proportional", percent = FALSE) -calcBias <- function(...) { - mcr::calcBias(...) -} +# calcBias <- function(...) { +# mcr::calcBias(...) +# } diff --git a/R/pkg_methods.R b/R/pkg_methods.R index dd8e6bc..9fe1e4f 100644 --- a/R/pkg_methods.R +++ b/R/pkg_methods.R @@ -62,8 +62,8 @@ setMethod( #' @examples #' #' # Bland-Altman analysis -#' data("creatinine", package = "mcr") -#' blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) +#' data("platelet") +#' blandAltman(x = platelet$Comparative, y = platelet$Candidate) setMethod( f = "show", signature = "BAsummary", @@ -257,8 +257,7 @@ setGeneric("getOutlier", function(object, ...) standardGeneric("getOutlier")) #' getOutlier(ba3, method = "ESD", difference = "rel") #' #' # Using "4E" as the method input -#' data("creatinine", package = "mcr") -#' ba4 <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) +#' ba4 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate) #' getOutlier(ba4, method = "4E") setMethod( f = "getOutlier", diff --git a/R/referenceInterval.R b/R/referenceInterval.R index 3f88359..5bb84be 100644 --- a/R/referenceInterval.R +++ b/R/referenceInterval.R @@ -157,7 +157,7 @@ nonparRI <- function(x, ind = 1:length(x), conf.level = 0.95) { #' x <- calcium$Value #' refInterval(x, RI_method = "parametric", CI_method = "parametric") #' refInterval(x, RI_method = "nonparametric", CI_method = "nonparametric") -#' refInterval(x, RI_method = "robust", CI_method = "boot") +#' refInterval(x, RI_method = "robust", CI_method = "boot", R = 1000) refInterval <- function(x, out_method = c("doxin", "tukey"), out_rm = FALSE, RI_method = c("parametric", "nonparametric", "robust"), diff --git a/_pkgdown.yml b/_pkgdown.yml index 5e947a7..4c7c2e0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -53,10 +53,6 @@ reference: - size_ci_corr - diagTab - blandAltman - - mcreg - - printSummary - - getCoefficients - - calcBias - pearsonTest - spearmanTest - ESD_test diff --git a/cran-comments.md b/cran-comments.md index 9080345..df9bb16 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,9 +2,13 @@ 0 errors | 0 warnings | 1 note +Maintainer: 'Kai Gu ' + + New submission + * This is a new release. -* Suggests or Enhances not in mainstream repositories: `mcr`. Because `mcr` package -is not available in CRAN. But users can install it from archived version. +* As `mcr` package is not available in CRAN for now, I add not running statement +for the examples. But users can install it from archived version. ## revdepcheck results diff --git a/inst/WORDLIST b/inst/WORDLIST index c80128a..a024dfa 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -26,11 +26,9 @@ Jen LDL Liu LoA -MCResult MCTab MMEs McCulloch -NBins NCSS NMPA NMPA's @@ -38,11 +36,8 @@ NOBOUND NSCLC Newcombe OxLDL -PBequi PDL PROC -PaBa -PaBaLarge QC'ed RandomEffects Reproducibility @@ -51,7 +46,6 @@ SampleSize Satterthwaite Searle Statist -Theil VC VCA VCoriginal @@ -70,7 +64,6 @@ confInt creatinin dL eg -equivariant et fontface gb @@ -78,6 +71,7 @@ ggplot immunohistochemical ixed linetype +linewidth lipoprotein loa magrittr @@ -95,15 +89,12 @@ pearson plr ppa ppv -quasilinear quations refInt refROC regmeth -regmethod repo reproducibility -rng roxygen sas satterthwaite diff --git a/man/autoplot.Rd b/man/autoplot.Rd index 60441ea..600b206 100644 --- a/man/autoplot.Rd +++ b/man/autoplot.Rd @@ -73,8 +73,8 @@ to the location of points.} \item{ref.line}{(\code{logical})\cr whether to plot a 'mean' line, default is TRUE.} \item{ref.line.params, ci.line.params, loa.line.params}{(\code{list})\cr parameters -(color, linetype, size) for the argument 'ref.line', 'ci.line' and 'loa.line'; -eg. ref.line.params = list(col = "blue", linetype = "solid", size = 1).} +(color, linetype, linewidth) for the argument 'ref.line', 'ci.line' and 'loa.line'; +eg. ref.line.params = list(col = "blue", linetype = "solid", linewidth = 1).} \item{ci.line}{(\code{logical})\cr whether to plot a confidence interval line of 'mean', default is FALSE.} @@ -129,16 +129,10 @@ If you'd like to alter any part that this \code{autoplot} function haven't provided, adding other \code{ggplot} statements are suggested. } \examples{ -# Using creatinine dataset from `mcr` package -data(creatinine, package = "mcr") -object <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) -autoplot(object) -autoplot(object, type = "relative") - # Specify the type for difference plot data("platelet") object <- blandAltman(x = platelet$Comparative, y = platelet$Candidate) -autoplot(object, type = "absolute") +autoplot(object) autoplot(object, type = "relative") # Set the addition parameters for `geom_point` @@ -174,6 +168,7 @@ autoplot(object, x.title = "Mean of Test and Reference Methods", y.title = "Reference - Test" ) +\dontrun{ # Using the default arguments for regression plot data("platelet") fit <- mcreg2( @@ -190,6 +185,7 @@ autoplot(fit, legend.digits = 4 ) } +} \seealso{ \code{\link[=h_difference]{h_difference()}} to see the type details. diff --git a/man/calcBias.Rd b/man/calcBias.Rd deleted file mode 100644 index 9ae7cc8..0000000 --- a/man/calcBias.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/mcr.R -\name{calcBias} -\alias{calcBias} -\title{Systematical Bias Between Reference Method and Test Method} -\usage{ -calcBias(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[mcr:MCResult.calcBias]{mcr::calcBias}} - \describe{ - \item{\code{.Object}}{object of class "MCResult".} - }} -} -\value{ -Bis and corresponding confidence interval for the specific medical -decision levels (\code{x.levels}). -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -A copy from \link[mcr:MCResult.calcBias]{mcr::calcBias} in \code{mcr} package -} -\examples{ -data(platelet) -fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" -) -calcBias(fit, x.levels = c(30, 200)) -calcBias(fit, x.levels = c(30, 200), type = "proportional") -calcBias(fit, x.levels = c(30, 200), type = "proportional", percent = FALSE) -} -\seealso{ -\code{\link[mcr:MCResult.calcBias]{mcr::calcBias()}} -} diff --git a/man/getCoefficients.Rd b/man/getCoefficients.Rd deleted file mode 100644 index 28483c7..0000000 --- a/man/getCoefficients.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/mcr.R -\name{getCoefficients} -\alias{getCoefficients} -\title{Get Regression Coefficients} -\usage{ -getCoefficients(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[mcr:MCResult.getCoefficients]{mcr::getCoefficients}} - \describe{ - \item{\code{.Object}}{object of class "MCResult".} - }} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -A copy from \link[mcr:MCResult.getCoefficients]{mcr::getCoefficients} in \code{mcr} package -} -\examples{ -data(platelet) -fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" -) -getCoefficients(fit) -} diff --git a/man/getOutlier.Rd b/man/getOutlier.Rd index e655722..e8322f4 100644 --- a/man/getOutlier.Rd +++ b/man/getOutlier.Rd @@ -64,7 +64,6 @@ ba3 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate, type2 = 4) getOutlier(ba3, method = "ESD", difference = "rel") # Using "4E" as the method input -data("creatinine", package = "mcr") -ba4 <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) +ba4 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate) getOutlier(ba4, method = "4E") } diff --git a/man/mcreg.Rd b/man/mcreg.Rd deleted file mode 100644 index c1c3018..0000000 --- a/man/mcreg.Rd +++ /dev/null @@ -1,82 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/mcr.R -\name{mcreg} -\alias{mcreg} -\alias{mcreg2} -\title{Comparison of Two Measurement Methods Using Regression Analysis} -\usage{ -mcreg(...) - -mcreg2(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[mcr:mcreg]{mcr::mcreg}} - \describe{ - \item{\code{x}}{measurement values of reference method, or two column matrix.} - \item{\code{y}}{measurement values of test method.} - \item{\code{error.ratio}}{ratio between squared measurement errors of reference and -test method, necessary for Deming regression (Default 1).} - \item{\code{alpha}}{value specifying the 100(1-alpha)\% confidence level for confidence intervals (Default is 0.05).} - \item{\code{mref.name}}{name of reference method (Default "Method1").} - \item{\code{mtest.name}}{name of test Method (Default "Method2").} - \item{\code{sample.names}}{names of cases (Default "S##").} - \item{\code{method.reg}}{regression method. It is possible to choose between five regression methods: -\code{"LinReg"} - ordinary least square regression.\cr -\code{"WLinReg"} - weighted ordinary least square regression.\cr -\code{"Deming"} - Deming regression.\cr -\code{"WDeming"} - weighted Deming regression.\cr -\code{"TS"} - Theil-Sen regression.\cr -\code{"PBequi"} - equivariant Passing-Bablok regression.\cr -\code{"PaBa"} - Passing-Bablok regression.\cr -\code{"PaBaLarge"} - approximative Passing-Bablok regression for large datasets, operating on \code{NBins} classes of constant slope angle which each slope - is classified to instead of building the complete triangular matrix of all N*N/2 slopes.} - \item{\code{method.ci}}{method of confidence interval calculation. The function -contains four basic methods for calculation of confidence intervals for regression coefficients. - \code{"analytical"} - with parametric method.\cr - \code{"jackknife"} - with leave one out resampling.\cr - \code{"bootstrap"} - with ordinary non-parametric bootstrap resampling.\cr - \code{"nested bootstrap"} - with ordinary non-parametric bootstrap resampling.\cr} - \item{\code{method.bootstrap.ci}}{bootstrap based confidence interval estimation method.} - \item{\code{nsamples}}{number of bootstrap samples.} - \item{\code{nnested}}{number of nested bootstrap samples.} - \item{\code{rng.seed}}{integer number that sets the random number generator seed for bootstrap sampling. If set to NULL currently in the R session used RNG setting will be used.} - \item{\code{rng.kind}}{type of random number generator for bootstrap sampling. Only used when rng.seed is specified, see set.seed for details.} - \item{\code{iter.max}}{maximum number of iterations for weighted Deming iterative algorithm.} - \item{\code{threshold}}{numerical tolerance for weighted Deming iterative algorithm convergence.} - \item{\code{na.rm}}{remove measurement pairs that contain missing values (Default is FALSE).} - \item{\code{NBins}}{number of bins used when 'reg.method="PaBaLarge"' to classify each slope in one of 'NBins' bins covering the range of all slopes} - \item{\code{slope.measure}}{angular measure of pairwise slopes used for exact PaBa regression (see below for details).\cr -\code{"radian"} - for data sets with even sample numbers median slope is calculated as average of two central slope angles.\cr -\code{"tangent"} - for data sets with even sample numbers median slope is calculated as average of two central slopes (tan(angle)).\cr} - \item{\code{methodlarge}}{Boolean. This parameter applies only to regmethod="PBequi" and "TS". -If TRUE, a quasilinear algorithm is used. -If FALSE, a quadratic algorithm is used which is faster for less than several hundred data pairs.} - }} -} -\value{ -A regression fit model. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -A copy from \link[mcr:mcreg]{mcr::mcreg} in \code{mcr} package -} -\examples{ -data(platelet) -fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" -) -printSummary(fit) -getCoefficients(fit) - -# use `MCR` class instead of `MCResult` class in `mcr` package -mcreg2( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" -) -} -\seealso{ -\code{\link[mcr:mcreg]{mcr::mcreg()}} -} diff --git a/man/printSummary.Rd b/man/printSummary.Rd deleted file mode 100644 index c4ab97b..0000000 --- a/man/printSummary.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/mcr.R -\name{printSummary} -\alias{printSummary} -\title{Print Summary of a Regression Analysis} -\usage{ -printSummary(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[mcr:MCResult.printSummary]{mcr::printSummary}} - \describe{ - \item{\code{.Object}}{object of type "MCResult".} - }} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -A copy from \link[mcr:MCResult.printSummary]{mcr::printSummary} in \code{mcr} package -} -\examples{ -data(platelet) -fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" -) -printSummary(fit) -} diff --git a/man/refInterval.Rd b/man/refInterval.Rd index eb77253..f61122c 100644 --- a/man/refInterval.Rd +++ b/man/refInterval.Rd @@ -86,5 +86,5 @@ data("calcium") x <- calcium$Value refInterval(x, RI_method = "parametric", CI_method = "parametric") refInterval(x, RI_method = "nonparametric", CI_method = "nonparametric") -refInterval(x, RI_method = "robust", CI_method = "boot") +refInterval(x, RI_method = "robust", CI_method = "boot", R = 1000) } diff --git a/man/show.Rd b/man/show.Rd index 23aab0e..3643e38 100644 --- a/man/show.Rd +++ b/man/show.Rd @@ -40,8 +40,8 @@ size_ci_corr(r = 0.9, lr = 0.85, alpha = 0.025, alternative = "greater") qualData \%>\% diagTab(formula = ~ CandidateN + ComparativeN) # Bland-Altman analysis -data("creatinine", package = "mcr") -blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) +data("platelet") +blandAltman(x = platelet$Comparative, y = platelet$Candidate) # Reference Interval data("calcium") diff --git a/tests/testthat/_snaps/autoplot/autoplot-basummary-with-absolute-diff.svg b/tests/testthat/_snaps/autoplot/autoplot-basummary-with-absolute-diff.svg index 17eccef..ff77eb0 100644 --- a/tests/testthat/_snaps/autoplot/autoplot-basummary-with-absolute-diff.svg +++ b/tests/testthat/_snaps/autoplot/autoplot-basummary-with-absolute-diff.svg @@ -172,7 +172,7 @@ - + Mean = 7.3300 Mean = 7.3300 Mean = 7.3300 diff --git a/tests/testthat/_snaps/autoplot/autoplot-basummary-with-relative-diff.svg b/tests/testthat/_snaps/autoplot/autoplot-basummary-with-relative-diff.svg index 3437b93..235740a 100644 --- a/tests/testthat/_snaps/autoplot/autoplot-basummary-with-relative-diff.svg +++ b/tests/testthat/_snaps/autoplot/autoplot-basummary-with-relative-diff.svg @@ -176,7 +176,7 @@ - + Mean = 0.0636 Mean = 0.0636 Mean = 0.0636 diff --git a/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-default-arguments.svg b/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-default-arguments.svg deleted file mode 100644 index 74af939..0000000 --- a/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-default-arguments.svg +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -200 -400 -600 -800 -1000 -1200 -1400 - - - - - - - - - - - - - - - - -0 -200 -400 -600 -800 -1000 -1200 -1400 -Method1 -Method2 - -Deming RegressionFit (n=120) - - - - - - -Identity -Y = 1.01 * X + 4.34 - - diff --git a/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-multiple-arguments.svg b/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-multiple-arguments.svg deleted file mode 100644 index d7a17d8..0000000 --- a/tests/testthat/_snaps/autoplot/autoplot-mcresult-with-multiple-arguments.svg +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -200 -400 -600 -800 -1000 -1200 -1400 - - - - - - - - - - - - - - - - -0 -200 -400 -600 -800 -1000 -1200 -1400 -Method1 -Method2 - - - - - - - -Identity -Y = 1.031 * X + 3.189 - - diff --git a/tests/testthat/test-autoplot.R b/tests/testthat/test-autoplot.R index d09eeea..4c2d9ec 100644 --- a/tests/testthat/test-autoplot.R +++ b/tests/testthat/test-autoplot.R @@ -31,33 +31,33 @@ test_that("autoplot works as expected for BAsummary class with multiple argument vdiffr::expect_doppelganger("autoplot_BAsummary with multiple arguments", result) }) -test_that("autoplot works as expected for MCResult class with default arguments", { - data(creatinine, package = "mcr") - object <- mcreg2( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" - ) - - result <- autoplot(object) - vdiffr::expect_doppelganger("autoplot_MCResult with default arguments", result) -}) - -test_that("autoplot works as expected for MCResult class with multiple arguments", { - data(creatinine, package = "mcr") - object <- mcreg2( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "PaBa", method.ci = "bootstrap" - ) +# test_that("autoplot works as expected for MCResult class with default arguments", { +# data(creatinine, package = "mcr") +# object <- mcreg2( +# x = platelet$Comparative, y = platelet$Candidate, +# method.reg = "Deming", method.ci = "jackknife" +# ) +# +# result <- autoplot(object) +# vdiffr::expect_doppelganger("autoplot_MCResult with default arguments", result) +# }) - result <- autoplot( - object, - identity.params = list(col = "blue", linetype = "solid"), - reg.params = list(col = "red", linetype = "solid"), - equal.axis = TRUE, - legend.title = FALSE, - legend.digits = 3, - x.title = "Reference", - y.title = "Test" - ) - vdiffr::expect_doppelganger("autoplot_MCResult with multiple arguments", result) -}) +# test_that("autoplot works as expected for MCResult class with multiple arguments", { +# data(creatinine, package = "mcr") +# object <- mcreg2( +# x = platelet$Comparative, y = platelet$Candidate, +# method.reg = "PaBa", method.ci = "bootstrap" +# ) +# +# result <- autoplot( +# object, +# identity.params = list(col = "blue", linetype = "solid"), +# reg.params = list(col = "red", linetype = "solid"), +# equal.axis = TRUE, +# legend.title = FALSE, +# legend.digits = 3, +# x.title = "Reference", +# y.title = "Test" +# ) +# vdiffr::expect_doppelganger("autoplot_MCResult with multiple arguments", result) +# }) diff --git a/tests/testthat/test-mcr.R b/tests/testthat/test-mcr.R index 8e2f17c..064ccc8 100644 --- a/tests/testthat/test-mcr.R +++ b/tests/testthat/test-mcr.R @@ -1,71 +1,71 @@ # mcreg ---- -test_that("mcreg works as expected with Deming regression", { - data(platelet) - fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" - ) - expect_class(fit, "MCResultJackknife") - object <- matrix( - c( - 4.335885, 1.568968372, 1.2289002, 7.442869, - 1.012951, 0.009308835, 0.9945175, 1.031386 - ), - nrow = 2, - byrow = TRUE, - dimnames = list( - c("Intercept", "Slope"), - c("EST", "SE", "LCI", "UCI") - ) - ) - expect_equal(fit@para, object, tolerance = 0.00001) -}) +# test_that("mcreg works as expected with Deming regression", { +# data(platelet) +# fit <- mcreg( +# x = platelet$Comparative, y = platelet$Candidate, +# method.reg = "Deming", method.ci = "jackknife" +# ) +# expect_class(fit, "MCResultJackknife") +# object <- matrix( +# c( +# 4.335885, 1.568968372, 1.2289002, 7.442869, +# 1.012951, 0.009308835, 0.9945175, 1.031386 +# ), +# nrow = 2, +# byrow = TRUE, +# dimnames = list( +# c("Intercept", "Slope"), +# c("EST", "SE", "LCI", "UCI") +# ) +# ) +# expect_equal(fit@para, object, tolerance = 0.00001) +# }) # getCoefficients ---- -test_that("getCoefficients works as expected with default settings", { - data(platelet) - fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" - ) - object <- matrix( - c( - 4.335885, 1.568968372, 1.2289002, 7.442869, - 1.012951, 0.009308835, 0.9945175, 1.031386 - ), - nrow = 2, - byrow = TRUE, - dimnames = list( - c("Intercept", "Slope"), - c("EST", "SE", "LCI", "UCI") - ) - ) - expect_equal(getCoefficients(fit), object, tolerance = 0.00001) -}) +# test_that("getCoefficients works as expected with default settings", { +# data(platelet) +# fit <- mcreg( +# x = platelet$Comparative, y = platelet$Candidate, +# method.reg = "Deming", method.ci = "jackknife" +# ) +# object <- matrix( +# c( +# 4.335885, 1.568968372, 1.2289002, 7.442869, +# 1.012951, 0.009308835, 0.9945175, 1.031386 +# ), +# nrow = 2, +# byrow = TRUE, +# dimnames = list( +# c("Intercept", "Slope"), +# c("EST", "SE", "LCI", "UCI") +# ) +# ) +# expect_equal(getCoefficients(fit), object, tolerance = 0.00001) +# }) # calcBias ---- -test_that("calcBias works as expected with default settings", { - data(platelet) - fit <- mcreg( - x = platelet$Comparative, y = platelet$Candidate, - method.reg = "Deming", method.ci = "jackknife" - ) - object <- matrix( - c( - 30, 4.724429, 1.378232, 1.995155, 7.453704, - 200, 6.926183, 1.288534, 4.374535, 9.477832 - ), - nrow = 2, - byrow = TRUE, - dimnames = list( - c("X1", "X2"), - c("Level", "Bias", "SE", "LCI", "UCI") - ) - ) - expect_equal(calcBias(fit, x.levels = c(30, 200)), object, tolerance = 0.00001) -}) +# test_that("calcBias works as expected with default settings", { +# data(platelet) +# fit <- mcreg( +# x = platelet$Comparative, y = platelet$Candidate, +# method.reg = "Deming", method.ci = "jackknife" +# ) +# object <- matrix( +# c( +# 30, 4.724429, 1.378232, 1.995155, 7.453704, +# 200, 6.926183, 1.288534, 4.374535, 9.477832 +# ), +# nrow = 2, +# byrow = TRUE, +# dimnames = list( +# c("X1", "X2"), +# c("Level", "Bias", "SE", "LCI", "UCI") +# ) +# ) +# expect_equal(calcBias(fit, x.levels = c(30, 200)), object, tolerance = 0.00001) +# }) diff --git a/tests/testthat/test-pkg_methods.R b/tests/testthat/test-pkg_methods.R index 6334b17..71e02da 100644 --- a/tests/testthat/test-pkg_methods.R +++ b/tests/testthat/test-pkg_methods.R @@ -65,11 +65,10 @@ test_that("getOutlier works as expected with sample id", { }) test_that("getOutlier works as expected with 4E method", { - data("creatinine", package = "mcr") - ba <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) + ba <- blandAltman(x = c(1:10), y = c(2:8, 50, 20, 30)) object <- getOutlier(ba, method = "4E") - expect_equal(dim(object$stat), c(6, 8)) - expect_identical(object$ord, c(4L, 51L, 96L, 97L, 106L, 108L)) + expect_equal(dim(object$stat), c(1, 8)) + expect_identical(object$ord, c(8L)) }) test_that("getOutlier works as expected to print no outlier", { diff --git a/vignettes/mcradds.Rmd b/vignettes/mcradds.Rmd index 760107d..54b779b 100644 --- a/vignettes/mcradds.Rmd +++ b/vignettes/mcradds.Rmd @@ -1,5 +1,5 @@ --- -title: "Introduction to `mcradds`" +title: "Introduction to mcradds" package: mcradds output: rmarkdown::html_document: @@ -32,7 +32,7 @@ This vignette shows the general purpose and usage of the `mcradds` R package. `mcradds` is a successor of the `mcr` R package that is developed by Roche, and therefore the fundamental coding ideas for method comparison regression have been borrowed from it. In addition, I supplement a series of useful functions and methods based on several reference documents from CLSI and NMPA guidance. You can perform the statistical analysis and graphics in different IVD trials utilizing these analytical functions. -```{r} +```{r eval = FALSE} browseVignettes(package = "mcradds") ``` @@ -71,7 +71,7 @@ The data sets with different purposes used in this vignette are: ```{r} data("qualData") data("platelet") -data(creatinine, package = "mcr") +# data(creatinine, package = "mcr") data("calcium") data("ldlroc") data("PDL1RP") @@ -186,9 +186,11 @@ tb %>% getAccuracy(ref = "nr", nr_ci = "wilson") #### Estimating Regression coefficient -Regression agreement is a very important criteria in method comparison trials that can be achieved by `mcr` package that has provided a series of regression methods, such as 'Deming', 'Passing-Bablok',' weighted Deming' and so on. The main and key functions have been wrapped in the `mcradds`, such as `mcreg`, `getCoefficients` and `calcBias`. If you would like to utilize the entire functions in `mcr` package, just adding the specific package name in front of each of them, like `mcr::calcBias()`, so that it looks the function is called from `mcr` package. +Regression agreement is a very important criteria in method comparison trials that can be achieved by `mcr` package that has provided a series of regression methods, such as 'Deming', 'Passing-Bablok',' weighted Deming' and so on. The main and key functions have been wrapped in the `mcradds`, such as `mcreg`, `getCoefficients` and `calcBias`. If you would like to utilize the entire functions in `mcr` package, just adding the specific package name in front of each of them, like `mcr::calcBias()`, so that it looks the function is called from `mcr` package. -```{r} +Please to be noted that the `mcr` package is not available in CRAN, so the `mcreg` or `mcreg2` function can not be used temporarily. + +```{r eval = FALSE} # Deming regression fit <- mcreg( x = platelet$Comparative, y = platelet$Candidate, @@ -202,7 +204,9 @@ getCoefficients(fit) Once you have obtained this regression equation, whether 'Deming' or 'Passing-Bablok', you can use it to estimate the bias in medical decision level. Suppose that you know the medical decision level of one assay is `30`, obviously this is a make-up number. Then you can use the `fit` object above to estimate the bias using `calcBias` function. -```{r} +Please to be noted that the `mcr` package is not available in CRAN, so the `calcBias` function can not be used temporarily. + +```{r eval = FALSE} # absolute bias. calcBias(fit, x.levels = c(30)) @@ -248,7 +252,7 @@ out$stat out$outmat # 4E approach -ba2 <- blandAltman(x = creatinine$serum.crea, y = creatinine$plasma.crea) +ba2 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate) out2 <- getOutlier(ba2, method = "4E") out2$stat out2$outmat @@ -445,9 +449,11 @@ autoplot( ### Regression plot -To generate the regression plot, you should create the object from `mcreg()` function and then call `autoplot` straightforward. +To generate the regression plot, you should create the object from `mcreg()` function and then call `autoplot` straightforward. -```{r} +Please to be noted that the `mcr` package is not available in CRAN, so the `mcreg` or `mcreg2` function can not be used temporarily. + +```{r eval = FALSE} fit <- mcreg2( x = platelet$Comparative, y = platelet$Candidate, method.reg = "PaBa", method.ci = "bootstrap" @@ -457,7 +463,7 @@ autoplot(fit) More arguments can be used as shown below. -```{r} +```{r eval = FALSE} autoplot( fit, identity.params = list(col = "blue", linetype = "solid"),