Title: | Visualizing the Decision Rules Underlying Binary Classification |
---|---|
Description: | Visualization of decision rules for binary classification and Receiver Operating Characteristic (ROC) curve estimation under different generalizations proposed in the literature: - making the classification subsets flexible to cover those scenarios where both extremes of the marker are associated with a higher risk of being positive, considering two thresholds (gROC() function); - transforming the marker by a proper function trying to improve the classification performance (hROC() function); - when dealing with multivariate markers, considering a proper transformation to univariate space trying to maximize the resulting AUC of the TPR for each FPR (multiROC() function). The classification regions behind each point of the ROC curve are displayed in both static graphics (plot_buildROC(), plot_regions() or plot_funregions() function) or videos (movieROC() function). |
Authors: | Sonia Perez-Fernandez [aut, cre] |
Maintainer: | Sonia Perez-Fernandez <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-09-27 06:19:02 UTC |
Source: | CRAN |
This is one of the main functions of the movieROC package.
It builds a univariate ROC curve (standard or general) and returns a
‘groc’ object, a list of class ‘groc’.
This object can be print
ed, plot
ted, or predict
ed
for a particular point. It may be also passed to other functions:
plot_regions()
, plot_buildROC()
, movieROC()
,
plot_densities()
, and plot_densityROC()
.
gROC(X, D, ...) ## Default S3 method: gROC(X, D, side = c("right", "left", "both", "both2"), restric = FALSE, optim = TRUE, t0 = NULL, t0max = FALSE, verbose = FALSE, ...)
gROC(X, D, ...) ## Default S3 method: gROC(X, D, side = c("right", "left", "both", "both2"), restric = FALSE, optim = TRUE, t0 = NULL, t0max = FALSE, verbose = FALSE, ...)
X |
Vector of marker values. |
D |
Vector of response values. Two levels; if more, the two first ones are used. |
side |
Type of ROC curve. One of |
restric |
If TRUE, the gROC curve with restriction (C) is computed. Default: FALSE. |
optim |
If TRUE (and |
t0 |
An integer number between 1 and |
t0max |
If TRUE, the computation of the gROC curve under restriction (C) is performed
departing from every possible |
verbose |
If TRUE, a progress bar is displayed for computationally intensive methods. Default: FALSE. |
... |
Other parameters to be passed. Not used. |
This function's main job is to estimate an ROC curve for a univariate marker
under one of these considerations: larger values of the marker are associated
with a higher probability of being positive (resulting in the right-sided
ROC curve, ), the opposite (left-sided ROC curve,
), when both smaller and larger values of the marker are
associated with having more probability of being positive (gROC curve,
), the opposite (opposite gROC curve,
).
A list of class ‘groc’ with the following fields:
controls , cases
|
Marker values of negative and positive subjects, respectively. |
levels |
Levels of response values. |
side |
Type of ROC curve. |
t |
Vector of false-positive rates. |
roc |
Vector of values of the ROC curve for |
c |
Vector of marker thresholds resulting in ( |
xl , xu
|
Vectors of marker thresholds resulting in ( |
auc |
Area under the curve estimate. |
aucfree |
Area under the curve estimate without restrictions. |
aucs |
Area under the curve with restriction (C) departing from every
false-positive rate, |
If side = "both"
and optim = TRUE
, the allShortesPaths()
function in the e1071 package is used. Also the combinations()
function in gtools and %[]%
in intrval.
P. Martínez-Camblor, N. Corral, C. Rey, J. Pascual, and E. Cernuda-Morollón (2017) “Receiver operating characteristic curve generalization for non-monotone relationships”. Statistical Methods in Medical Research, 26(1):113–123. DOI: doi:10.1177/0962280214541095.
S. Pérez-Fernández, P. Martínez-Camblor, P. Filzmoser, and N. Corral (2021). “Visualizing the decision rules behind the ROC curves: understanding the classification process”. AStA Advances in Statistical Analysis, 105(1):135-161. DOI: doi:10.1007/s10182-020-00385-2.
R. W. Floyd (1962) “Algorithm 97: Shortest path”. Communications of the ACM, 5: 345–345. DOI: doi:10.1145/367766.368168.
data(HCC) # ROC curve estimates for gene 03515901 and response tumor gROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Standard right-sided ROC curve gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided ROC curve gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both") # gROC curve without restrictions ### Warning: Next line of code is time consuming. gROC curve with restriction (C) gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both", restric = TRUE)
data(HCC) # ROC curve estimates for gene 03515901 and response tumor gROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Standard right-sided ROC curve gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided ROC curve gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both") # gROC curve without restrictions ### Warning: Next line of code is time consuming. gROC curve with restriction (C) gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both", restric = TRUE)
This function builds a univariate ROC curve (standard or general) assuming the binormal scenario with parameters being the sample estimates. It returns a ‘groc’ object, a list of class ‘groc’.
gROC_param(X, D, side = c("right", "left", "both", "both2"), N = NULL, ...)
gROC_param(X, D, side = c("right", "left", "both", "both2"), N = NULL, ...)
X |
Vector of marker values. |
D |
Vector of response values. Two levels; if more, the two first ones are used. |
side |
Type of ROC curve. One of |
N |
Number indicating the length of the vector of FPR considered to build the ROC curve:
|
... |
Other parameters to be passed. Not used. |
This function's main job is to estimate an ROC curve for a univariate marker
under one of these considerations: larger values of the marker are associated
with a higher probability of being positive (resulting in the right-sided
ROC curve, ), the opposite (left-sided ROC curve,
), when both smaller and larger values of the marker are
associated with having more probability of being positive (gROC curve,
), the opposite (opposite gROC curve,
).
A list of class ‘groc’ with the following fields:
controls , cases
|
Marker values of negative and positive subjects, respectively. |
levels |
Levels of response values. |
side |
Type of ROC curve. |
t |
Vector of false-positive rates. |
roc |
Vector of values of the ROC curve for |
c |
Vector of marker thresholds resulting in ( |
xl , xu
|
Vectors of marker thresholds resulting in ( |
auc |
Area under the curve estimate. |
a , b
|
Estimates for parameters |
p0 |
Estimate of the "central value", |
P. Martínez-Camblor and J. C. Pardo-Fernández (2019) “Parametric estimates for the receiver operating characteristic curve generalization for non-monotone relationships”. Statistical Methods in Medical Research, 28(7): 2032–2048. DOI: doi:10.1177/0962280217747009.
data(HCC) # ROC curve estimates for gene 03515901 and response tumor assuming the binormal scenario gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor) # Standard right-sided ROC curve gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided ROC curve gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both") # gROC curve
data(HCC) # ROC curve estimates for gene 03515901 and response tumor assuming the binormal scenario gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor) # Standard right-sided ROC curve gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided ROC curve gROC_param(X = HCC[,"cg03515901"], D = HCC$tumor, side = "both") # gROC curve
This dataset is derived from gene expression arrays of tumor and adjacent non-tumor tissues of 62 Taiwanese cases of hepatocellular carcinoma. The complete dataset was deposited in NCBI’s Gene Expression Omnibus (GEO) and it is available through series accession number GSE37988. This dataset contains 948 from the 27,578 autosomal CpG sites screened.
data("HCC")
data("HCC")
A data frame with 124 observations on 952 variables. First 4 variables are tissue
(identification number for the tissue; from 1 to 62), sex
(female or male), age
(age in years of the patient), and tumor
(status of the tissue; nontumor or tumor). The following 948 from cg03409548
to cg20240860
are numeric variables containing the relative gene expression intensities of the corresponding gene.
NCBI’s Gene Expression Omnibus (GEO) - Series accession number GSE37988 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE37988)
data(HCC) str(HCC) # Data structure table(HCC$tumor) # Number of non-tumor and tumor tissues # Histograms of gene 18384097 expression intensities for non-tumor and tumor tissues oldpar <- par(mfrow = c(2,1)) x <- subset(HCC, tumor == "nontumor")$cg18384097 y <- subset(HCC, tumor == "tumor")$cg18384097 hist(x, xlim = c(0,1), main = "Gene 18384097 in non-tumor tissues") hist(y, xlim = c(0,1), main = "Gene 18384097 in tumor tissues") par(oldpar)
data(HCC) str(HCC) # Data structure table(HCC$tumor) # Number of non-tumor and tumor tissues # Histograms of gene 18384097 expression intensities for non-tumor and tumor tissues oldpar <- par(mfrow = c(2,1)) x <- subset(HCC, tumor == "nontumor")$cg18384097 y <- subset(HCC, tumor == "tumor")$cg18384097 hist(x, xlim = c(0,1), main = "Gene 18384097 in non-tumor tissues") hist(y, xlim = c(0,1), main = "Gene 18384097 in tumor tissues") par(oldpar)
This is one of the main functions of the movieROC package.
It builds a univariate ROC curve for a transformed marker
and returns a ‘hroc’ object, a list of class ‘hroc’.
This object can be
print
ed, plot
ted, or predict
ed
for a particular point. It may be also passed to
plot_funregions()
and plot_regions()
functions.
hROC(X, D, ...) ## Default S3 method: hROC(X, D, type = c("lrm", "overfitting", "kernel", "h.fun"), formula.lrm = "D ~ pol(X,3)", h.fun = function(x) {x}, kernel.h = 1, plot.h = FALSE, plot.roc = FALSE, new.window = FALSE, main = NULL, xlab = "x", ylab = "h(x)", xaxis = TRUE, ...)
hROC(X, D, ...) ## Default S3 method: hROC(X, D, type = c("lrm", "overfitting", "kernel", "h.fun"), formula.lrm = "D ~ pol(X,3)", h.fun = function(x) {x}, kernel.h = 1, plot.h = FALSE, plot.roc = FALSE, new.window = FALSE, main = NULL, xlab = "x", ylab = "h(x)", xaxis = TRUE, ...)
X |
Vector of marker values. |
D |
Vector of response values. Two levels; if more, the two first ones are used. |
type |
Type of transformation considered. One of
|
formula.lrm |
If |
kernel.h |
If |
h.fun |
If |
plot.h |
If TRUE, the transformation employed is illustrated. |
plot.roc |
If TRUE, the resulting ROC curve is illustrated. |
new.window |
If TRUE, two previous graphics are plotted separately in different windows. |
main |
A main title for the plot used if |
xlab , ylab
|
A label for the x and y axis of the plot used if |
xaxis |
Graphical parameter used if |
... |
Other parameters to be passed. Not used. |
A theoretical and practical discussion about the type
of transformation considered and its basis may be found in Martínez-Camblor et al. (2019) and Martínez-Camblor et al. (2021).
The overfitting function estimate is defined as follows:
where denotes the indicator function (which takes the value 1 if
is true and 0 otherwise),
is the cardinal of the subset
,
are the positive sample values without ties and
are the positive sample values with ties with any negative sample value. Classification based on this transformation is the optimal one in the AUC sense, but the resulting decision rules cannot be extended to any other sample.
A list of class ‘hroc’ with the following fields:
levels |
Levels of response values. |
X , Y
|
Original and transformed marker values, respectively. |
Sp , Se
|
Vector of true-negtive and true-positive rates, respectively. |
auc |
Area under the curve estimate. |
model |
If |
If type = "lrm"
, the lrm()
function in the rms package is used. This library is also loaded to consider special transformation functions such as pol()
and rcs()
.
P. Martínez-Camblor, S. Pérez-Fernández, and S. Díaz-Coto (2019) “Improving the biomarker diagnostic capacity via functional transformations”. Journal of Applied Statistics, 46(9): 1550–1566. DOI: doi:10.1080/02664763.2018.1554628.
P. Martínez-Camblor, S. Pérez-Fernández, and S. Díaz-Coto (2021) “Optimal classification scores based on multivariate marker transformations”. AStA Advances in Statistical Analysis, 105(4): 581–599. DOI: doi:10.1007/s10182-020-00388-z.
data(HCC) # ROC curve for gene 18384097 to identify tumor by considering 4 different transformations: X <- HCC$cg18384097; D <- HCC$tumor ## 1. Ordinary cubic polynomial formula for binary logistic regression hROC(X, D) ## 2. Linear tail-restricted cubic splines for binary logistic regression hROC(X, D, formula.lrm = "D ~ rcs(X,8)") ## 3. Overfitting transformation for this particular sample hROC(X, D, type = "overfitting") ## 4. Optimal transformation in terms of likelihood ratio ## by kernel density estimation with bandwidth 3 hROC(X, D, type = "kernel", kernel.h = 3)
data(HCC) # ROC curve for gene 18384097 to identify tumor by considering 4 different transformations: X <- HCC$cg18384097; D <- HCC$tumor ## 1. Ordinary cubic polynomial formula for binary logistic regression hROC(X, D) ## 2. Linear tail-restricted cubic splines for binary logistic regression hROC(X, D, formula.lrm = "D ~ rcs(X,8)") ## 3. Overfitting transformation for this particular sample hROC(X, D, type = "overfitting") ## 4. Optimal transformation in terms of likelihood ratio ## by kernel density estimation with bandwidth 3 hROC(X, D, type = "kernel", kernel.h = 3)
Save a video as a GIF illustrating the construction of the ROC curve. Particularly, for each
element in vector fpr
(optional input parameter), the function executed is
- for ‘groc’ objects:
plot_buildROC(obj, FPR = fpr[i], build.process = TRUE,...)
;
- for ‘multiroc’ objects:
plot_buildROC(obj, FPR = fpr[i], build.process = TRUE, display.method, displayOV,...)
movieROC(x, ...) ## S3 method for class 'groc' movieROC(x, fpr = NULL, h = c(1,1), histogram = FALSE, breaks = 15, reduce = TRUE, completeROC = FALSE, videobar = TRUE, file = "animation1.gif", save = TRUE, legends = FALSE, speedcorrection = FALSE, tpause = 1, interval = 0.2, ani.width, ani.height, xlab = "Marker", main.density = "Density functions", cex.lab = 2.5, cex.axis = 1.75, cex.main = 2.25 + as.numeric(reduce), xlim = NULL, ylim = NULL, cex.point = 1.5, lwd.curve = 2, mar = NULL, lim.density = 0.01, col.controlscases = c("#485C99", "#8F3D52"), col.curve = "black", col.threshold = "#FCBA04", verbose = FALSE, ...) ## S3 method for class 'multiroc' movieROC(x, fpr = NULL, display.method = c("PCA", "OV"), displayOV = c(1,2), border = TRUE, completeROC = FALSE, videobar = TRUE, file = "animation1.gif", save = TRUE, legends = FALSE, tpause = 1, interval = 0.2, ani.width, ani.height, xlab = NULL, ylab = NULL, cex = 0.8, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, alpha.points = 1, alpha.contour = 0.25, lwd.curve = 2, lty.curve = 1, lf = NULL, col.controlscases = c('#485C99','#8F3D52'), col.curve = 'black', col.threshold = '#FCBA04', verbose = FALSE, ...)
movieROC(x, ...) ## S3 method for class 'groc' movieROC(x, fpr = NULL, h = c(1,1), histogram = FALSE, breaks = 15, reduce = TRUE, completeROC = FALSE, videobar = TRUE, file = "animation1.gif", save = TRUE, legends = FALSE, speedcorrection = FALSE, tpause = 1, interval = 0.2, ani.width, ani.height, xlab = "Marker", main.density = "Density functions", cex.lab = 2.5, cex.axis = 1.75, cex.main = 2.25 + as.numeric(reduce), xlim = NULL, ylim = NULL, cex.point = 1.5, lwd.curve = 2, mar = NULL, lim.density = 0.01, col.controlscases = c("#485C99", "#8F3D52"), col.curve = "black", col.threshold = "#FCBA04", verbose = FALSE, ...) ## S3 method for class 'multiroc' movieROC(x, fpr = NULL, display.method = c("PCA", "OV"), displayOV = c(1,2), border = TRUE, completeROC = FALSE, videobar = TRUE, file = "animation1.gif", save = TRUE, legends = FALSE, tpause = 1, interval = 0.2, ani.width, ani.height, xlab = NULL, ylab = NULL, cex = 0.8, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, alpha.points = 1, alpha.contour = 0.25, lwd.curve = 2, lty.curve = 1, lf = NULL, col.controlscases = c('#485C99','#8F3D52'), col.curve = 'black', col.threshold = '#FCBA04', verbose = FALSE, ...)
x |
An ROC curve object from the movieROC package. Possible classes are: ‘groc’ (output of |
fpr |
A vector of false-positive rates for which the building process of the ROC curve is displayed. Default: if length of |
h |
A vector of length 2 with the bandwidth used to compute kernel density estimation for controls and cases, respectively. See |
histogram |
If TRUE, histograms are displayed on the left instead of kernel density estimates. Default: FALSE. Only available for a ‘groc’ object. |
breaks |
If |
reduce |
If FALSE, two extra graphics are displayed at the bottom (see Details for more information). Default: TRUE. Only available for a ‘groc’ object. |
completeROC |
A logical value indicating if the whole ROC curve should be displayed in light gray or not. Default: FALSE. |
videobar |
If TRUE, a text progress bar is shown in the R console. Default: TRUE. |
verbose |
If TRUE, a progress bar is displayed for computationally intensive methods. Default: FALSE. |
file |
File name of the movie (with the extension). Default: |
save |
If TRUE, video is saved as a GIF by using the |
legends |
If TRUE, a legend with colors meaning is displayed on the left graphic and the AUC is shown on the right graphic. Default: FALSE. |
speedcorrection |
If TRUE, only some FPR in |
tpause |
If |
interval |
If |
ani.width , ani.height
|
If |
xlab , ylab
|
Label for x- and y-axis on the left plot. |
main.density |
Title for the left plot. Only available for a ‘groc’ object. |
cex.lab , cex.axis , cex.main
|
The magnification to be used for labels, axis annotation and main titles, respectively, relative to the current setting of |
cex |
A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. Default: 0.8. Not available for object of class ‘groc’ ( |
cex.point |
The magnification to be used for the particular point on the ROC curve and its text, relative to the current setting of |
xlim , ylim
|
Range for x- and y-axis on the left plot. Only available for a ‘groc’ object. |
lim.density |
If |
lty.curve , lwd.curve , col.curve
|
The line type, width and color for ROC curve. Default: |
mar |
A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. Only available for a ‘groc’ object. |
col.controlscases |
Vector of length 2 with the color used to control and case group, respectively. Default: |
col.threshold |
Color for the chosen point. Default: |
border |
If TRUE, a border for the classification subsets is drawn. Default: TRUE. Not available for object of class ‘groc’. |
alpha.points , alpha.contour
|
Number in [0,1] modifying the opacity alpha of the color for the points and classification region. The |
lf |
Epsilon value for steps. Not used. |
display.method |
Method to display the marker values from a ‘multiroc’ object on the left plot. Methods available: |
displayOV |
If |
... |
Other parameters to be passed to the |
A video with the building procedure of the ROC curve estimate with the selected graphical parameters
If save = TRUE
(by default), the saveGIF()
function in the animation package is used.
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor, side = "right") ### The video will be saved as a GIF with the name "video_cg20202438" movieROC(roc_cg20202438, file = "video_cg20202438.gif", save = FALSE) # Multivariate ROC curve for genes 0202438, 18384097, and 03515901 multiroc_PT <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") # Two first components from PCA: ### The video will be saved as a GIF with the name "video_multiroc_pca" movieROC(multiroc_PT, file = "video_multiroc_pca.gif", save = FALSE) ### The video will be saved as a GIF with the name "video_multiroc_orig" movieROC(multiroc_PT, display.method = "OV", displayOV = c(1,3), file = "video_multiroc_orig.gif", cex = 1.2, xlab = "Gene 20202438", ylab = "Gene 03515901", lwd.curve = 4, save = FALSE)
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor, side = "right") ### The video will be saved as a GIF with the name "video_cg20202438" movieROC(roc_cg20202438, file = "video_cg20202438.gif", save = FALSE) # Multivariate ROC curve for genes 0202438, 18384097, and 03515901 multiroc_PT <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") # Two first components from PCA: ### The video will be saved as a GIF with the name "video_multiroc_pca" movieROC(multiroc_PT, file = "video_multiroc_pca.gif", save = FALSE) ### The video will be saved as a GIF with the name "video_multiroc_orig" movieROC(multiroc_PT, display.method = "OV", displayOV = c(1,3), file = "video_multiroc_orig.gif", cex = 1.2, xlab = "Gene 20202438", ylab = "Gene 03515901", lwd.curve = 4, save = FALSE)
This function tracks the construction of the standard ROC curve (right- or left-sided, depending on the side
of the object of class ‘groc’ included) resulting from the kernel density function estimation for controls and cases. Four graphics are displayed: top-left, the kernel density estimates; top-right, the resulting ROC curve; bottom-left, boxplots and points for controls and cases and classification subset in gray color; bottom-right, classification subsets for every FPR until the current one. It makes use of the plot_densityROC()
function for each screenshot.
movieROC2_densities(obj, h = c(1, 1), cut.off = NULL, completeROC = FALSE, legends = FALSE, videobar = TRUE, file = "animation1.gif", clean = FALSE, interval = 0.2, ani.width = 500, ani.height = 750, save = TRUE, tpause = 1, verbose = FALSE, ...)
movieROC2_densities(obj, h = c(1, 1), cut.off = NULL, completeROC = FALSE, legends = FALSE, videobar = TRUE, file = "animation1.gif", clean = FALSE, interval = 0.2, ani.width = 500, ani.height = 750, save = TRUE, tpause = 1, verbose = FALSE, ...)
obj |
An object of class ‘groc’ with |
h |
A vector of length 2 with the bandwidth used to compute kernel density estimation for controls and cases, respectively. See |
cut.off |
Vector with marker cutoffs for which the graphics are displayed. Default: if number of unique marker values is lower than 150, these are considered; otherwise, a equally-spaced grid of length 102 in the range of the marker is used. |
save |
If TRUE, video is saved as a GIF by using the |
completeROC |
A logical value indicating if the whole ROC curve should be displayed in light gray or not. Default: FALSE. |
legends |
If TRUE, legends with the meaning of colors are displayed. Default: FALSE. |
videobar |
If TRUE, a text progress bar is shown in the R console. Default: TRUE. |
file |
File name of the movie (with the extension). Default: |
clean |
Whether to delete the individual image frames in animation package. Default: FALSE. |
interval |
A positive number to set the time interval of the animation (unit in seconds) in animation package. Default: 0.2. |
ani.width , ani.height
|
Width and height of image frames (unit in px) in animation package. |
tpause |
If |
verbose |
If TRUE, a progress bar is displayed for computationally intensive methods. Default: FALSE. |
... |
Other parameters to be passed to the |
A video with the building procedure of the smooth ROC curve estimate with the selected graphical parameters
If save = TRUE
(by default), the saveGIF()
function in the animation package is used.
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) ### The video will be saved as a GIF with the name "video_cg20202438_smooth" movieROC2_densities(roc_cg20202438, file = "video_cg20202438_smooth.gif", save = FALSE)
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) ### The video will be saved as a GIF with the name "video_cg20202438_smooth" movieROC2_densities(roc_cg20202438, file = "video_cg20202438_smooth.gif", save = FALSE)
This is one of the main functions of the movieROC package.
It builds a multivariate ROC curve by considering one of these methods:
i) fitting a binary logistic regression model with a particular combination
(fixed by the user) of the two components on the right-hand side,
ii) linear combinations with fixed parameters, or
iii) linear combinations with dynamic parameters, or
iv) estimating optimal transformation based on kernel density estimation, or
v) quadratic combinations with fixed parameters (if ).
It returns a ‘multiroc’ object, a list of class ‘multiroc’.
This object can be
print
ed or plot
ted. It may be also
passed to plot_buildROC()
and movieROC()
function.
multiROC(X, D, ...) ## Default S3 method: multiROC(X, D, method = c("lrm", "fixedLinear", "fixedQuadratic", "dynamicEmpirical", "dynamicMeisner", "kernelOptimal"), formula.lrm = "D ~ X.1 + I(X.1^2) + X.2 + I(X.2^2) + I(X.1*X.2)", stepModel = TRUE, methodLinear = c("coefLinear", "SuLiu", "PepeThompson", "logistic", "minmax"), coefLinear = rep(1,ncol(X)), coefQuadratic = c(1,1,0,1,1), K = 201, alpha = 0.5, approxh = 0.5, multiplier = 2, kernelOptimal.H = c("Hbcv", "Hscv", "Hpi", "Hns", "Hlscv", "Hbcv.diag", "Hscv.diag", "Hpi.diag", "Hlscv.diag"), eps = sqrt(.Machine$double.eps), verbose = FALSE, ...)
multiROC(X, D, ...) ## Default S3 method: multiROC(X, D, method = c("lrm", "fixedLinear", "fixedQuadratic", "dynamicEmpirical", "dynamicMeisner", "kernelOptimal"), formula.lrm = "D ~ X.1 + I(X.1^2) + X.2 + I(X.2^2) + I(X.1*X.2)", stepModel = TRUE, methodLinear = c("coefLinear", "SuLiu", "PepeThompson", "logistic", "minmax"), coefLinear = rep(1,ncol(X)), coefQuadratic = c(1,1,0,1,1), K = 201, alpha = 0.5, approxh = 0.5, multiplier = 2, kernelOptimal.H = c("Hbcv", "Hscv", "Hpi", "Hns", "Hlscv", "Hbcv.diag", "Hscv.diag", "Hpi.diag", "Hlscv.diag"), eps = sqrt(.Machine$double.eps), verbose = FALSE, ...)
X |
Matrix (dimension |
D |
Vector of response values. Two levels; if more, the two first ones are used. |
method |
Method used to build the classification regions. One of |
formula.lrm |
If |
stepModel |
If TRUE and |
methodLinear |
If |
coefLinear |
If |
coefQuadratic |
If |
alpha , approxh , multiplier
|
If |
K |
If |
kernelOptimal.H |
If |
eps |
Epsilon value to consider. Default: |
verbose |
If TRUE, a progress bar is displayed for computationally intensive methods. Default: FALSE. |
... |
Other parameters to be passed. Not used. |
A list of class ‘multiroc’ with the following fields:
controls , cases
|
Marker values of negative and positive subjects, respectively. |
levels |
Levels of response values. |
t |
Vector of false-positive rates. |
roc |
Vector of values of the ROC curve for |
auc |
Area under the curve estimate. |
Z |
If |
c |
If |
CoefTable |
If |
If method = "lrm"
, the glm()
function in the stats package is used.
If method = "kernelOptimal"
, the kde()
function in the ks package is used.
J. Q. Su and J. S. Liu. (1993) “Linear combinations of multiple diagnostic markers”. Journal of the American Statistical Association, 88(424): 1350–1355. DOI: doi:10.1080/01621459.1993.10476417.
M. S. Pepe and M. L. Thompson (2000) “Combining diagnostic test results to increase accuracy”. Biostatistics, 1 (2):123–140. DOI: doi:10.1093/biostatistics/1.2.123.
C. Liu, A. Liu, and S. Halabi (2011) “A min–max combination of biomarkers to improve diagnostic accuracy”. Statistics in Medicine, 30(16): 2005–2014. DOI: doi:10.1002/sim.4238.
P. Martínez-Camblor, S. Pérez-Fernández, and S. Díaz-Coto (2021) “Optimal classification scores based on multivariate marker transformations”. AStA Advances in Statistical Analysis, 105(4): 581–599. DOI: doi:10.1007/s10182-020-00388-z.
A. Meisner, M. Carone, M. S. Pepe, and K. F. Kerr (2021) “Combining biomarkers by maximizing the true positive rate for a fixed false positive rate”. Biometrical Journal, 63(6): 1223–1240. DOI: doi:10.1002/bimj.202000210.
data(HCC) # ROC curve for genes 20202438 and 18384097 (p=2) to identify tumor by 4 different methods: X <- cbind(HCC$cg20202438, HCC$cg18384097); D <- HCC$tumor ## 1. Linear combinations with fixed parameters by Pepe and Thompson (2000) multiROC(X, D, method = "fixedLinear", methodLinear = "PepeThompson") ## 2.Linear combinations with dynamic parameters by Meisner et al. (2021) ### Time consuming multiROC(X, D, method = "dynamicMeisner") ## 3. Logistic regression model with quadratic formula by default multiROC(X, D) ## 4. Optimal transformation with multivariate KDE by Martínez-Camblor et al. (2021) multiROC(X, D, method = "kernelOptimal") # ROC curve for genes 20202438, 18384097, and 03515901 (p=3) to identify tumor # by 4 different methods: X <- cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901); D <- HCC$tumor ## 1. Linear combinations with fixed parameters by Pepe and Thompson (2000) multiROC(X, D, method = "fixedLinear", methodLinear = "PepeThompson") ## 2.Linear combinations with dynamic parameters by Meisner et al. (2021) ### Time consuming multiROC(X, D, method = "dynamicMeisner") ## 3. Logistic regression model with quadratic formula by default multiROC(X, D) ## 4. Optimal transformation with multivariate KDE by Martínez-Camblor et al. (2021) multiROC(X, D, method = "kernelOptimal")
data(HCC) # ROC curve for genes 20202438 and 18384097 (p=2) to identify tumor by 4 different methods: X <- cbind(HCC$cg20202438, HCC$cg18384097); D <- HCC$tumor ## 1. Linear combinations with fixed parameters by Pepe and Thompson (2000) multiROC(X, D, method = "fixedLinear", methodLinear = "PepeThompson") ## 2.Linear combinations with dynamic parameters by Meisner et al. (2021) ### Time consuming multiROC(X, D, method = "dynamicMeisner") ## 3. Logistic regression model with quadratic formula by default multiROC(X, D) ## 4. Optimal transformation with multivariate KDE by Martínez-Camblor et al. (2021) multiROC(X, D, method = "kernelOptimal") # ROC curve for genes 20202438, 18384097, and 03515901 (p=3) to identify tumor # by 4 different methods: X <- cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901); D <- HCC$tumor ## 1. Linear combinations with fixed parameters by Pepe and Thompson (2000) multiROC(X, D, method = "fixedLinear", methodLinear = "PepeThompson") ## 2.Linear combinations with dynamic parameters by Meisner et al. (2021) ### Time consuming multiROC(X, D, method = "dynamicMeisner") ## 3. Logistic regression model with quadratic formula by default multiROC(X, D) ## 4. Optimal transformation with multivariate KDE by Martínez-Camblor et al. (2021) multiROC(X, D, method = "kernelOptimal")
This is one of the core functions of the movieROC package. It displays the empirical ROC curve estimate from an object of class ‘groc’, ‘hroc’, or ‘multiroc’.
## S3 method for class 'groc' plot(x, xlim = c(0, 1), ylim = c(0, 1), lwd = 3, xlab = "False-Positive Rate", ylab = "True-Positive Rate", main = "ROC curve", cex.lab = 1.25, cex.main = 1.5, type = NULL, new = TRUE, ...) ## S3 method for class 'hroc' plot(x, type = 'S', xlim = c(0,1), ylim = c(0,1), lwd = 3, xlab = "False-Positive Rate", ylab = "True-Positive Rate", main = "ROC Curve", cex.lab = 1.25, cex.main = 1.5, new = TRUE, ...) ## S3 method for class 'multiroc' plot(x, ...)
## S3 method for class 'groc' plot(x, xlim = c(0, 1), ylim = c(0, 1), lwd = 3, xlab = "False-Positive Rate", ylab = "True-Positive Rate", main = "ROC curve", cex.lab = 1.25, cex.main = 1.5, type = NULL, new = TRUE, ...) ## S3 method for class 'hroc' plot(x, type = 'S', xlim = c(0,1), ylim = c(0,1), lwd = 3, xlab = "False-Positive Rate", ylab = "True-Positive Rate", main = "ROC Curve", cex.lab = 1.25, cex.main = 1.5, new = TRUE, ...) ## S3 method for class 'multiroc' plot(x, ...)
x |
An ROC curve object from movieROC package. Possible classes are: ‘groc’ (output of |
xlim , ylim
|
Range for x- and y-axis. Default: unit interval. |
lwd |
Line width of the ROC curve. Default: 3. |
xlab , ylab
|
Label for x- and y-axis. |
main |
Title for the plot. |
cex.lab , cex.main
|
The magnification to be used for labels and main title, respectively, relative to the current setting of |
type |
What type of plot should be drawn (see help from |
new |
If TRUE, a new plot is displayed; otherwise, the ROC curve is plotted over the existing graphic. Default: TRUE. |
... |
Other graphical parameters to be passed. |
A plot of the ROC curve with the selected graphical parameters
data(HCC) # ROC curve estimates for gene 03515901 and response tumor rroc <- gROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Right-sided lroc <- gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided hroc <- hROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Transformed by a cubic polinomial plot(rroc, lty = 2, frame = FALSE) plot(lroc, new = FALSE) plot(hroc, new = FALSE, col = "blue") legend("topleft", legend = c("Right-sided", "Left-sided", "Transformed marker"), col = c("black", "black", "blue"), lty = c(1,2,1), lwd = 2, bty = "n") # ROC curve estimate for genes 20202438 and 18384097 to simultaneously identify tumor # by a logistic regression model with quadratic formula biroc <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097), D = HCC$tumor) plot(biroc) legend("bottomright", paste("AUC = ", format(biroc$auc, digits = 3))) # ROC curve estimate for genes 20202438, 18384097 and 03515901 to simultaneously # identify tumor by a linear combinations with fixed parameters by Pepe and Thompson (2000) multiroc <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") plot(multiroc) legend("bottomright", paste("AUC = ", format(multiroc$auc, digits = 3)))
data(HCC) # ROC curve estimates for gene 03515901 and response tumor rroc <- gROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Right-sided lroc <- gROC(X = HCC[,"cg03515901"], D = HCC$tumor, side = "left") # Left-sided hroc <- hROC(X = HCC[,"cg03515901"], D = HCC$tumor) # Transformed by a cubic polinomial plot(rroc, lty = 2, frame = FALSE) plot(lroc, new = FALSE) plot(hroc, new = FALSE, col = "blue") legend("topleft", legend = c("Right-sided", "Left-sided", "Transformed marker"), col = c("black", "black", "blue"), lty = c(1,2,1), lwd = 2, bty = "n") # ROC curve estimate for genes 20202438 and 18384097 to simultaneously identify tumor # by a logistic regression model with quadratic formula biroc <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097), D = HCC$tumor) plot(biroc) legend("bottomright", paste("AUC = ", format(biroc$auc, digits = 3))) # ROC curve estimate for genes 20202438, 18384097 and 03515901 to simultaneously # identify tumor by a linear combinations with fixed parameters by Pepe and Thompson (2000) multiroc <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") plot(multiroc) legend("bottomright", paste("AUC = ", format(multiroc$auc, digits = 3)))
This function tracks the ROC curve. It plots two graphics in the same figure: right, the empirical ROC curve estimate; left, classification subset for a particular FPR or threshold(s) for the marker (threshold only for object of class ‘groc’).
## S3 method for class 'groc' plot_buildROC(x, FPR = NULL, C = NULL, XL = NULL, XU = NULL, h = c(1,1), histogram = FALSE, breaks = 15, reduce = TRUE, build.process = FALSE, completeROC = FALSE, new.window = FALSE, legends = FALSE, type = 's', cex.point = 1.5, lwd.curve = 2, mar = NULL, lim.density = 0.01, xlim = NULL, ylim = NULL, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, xlab = "Marker", main.density = "Density functions", col.controlscases = c('#485C99','#8F3D52'), col.threshold = '#FCBA04', col.curve = 'black', eps = sqrt(.Machine$double.eps), ...) ## S3 method for class 'multiroc' plot_buildROC(x, FPR = 0.15, display.method = c("PCA", "OV"), displayOV = c(1,2), build.process = FALSE, completeROC = TRUE, new = FALSE, new.window = FALSE, border = FALSE, cutoff = TRUE, legends = FALSE, type = 's', col.controlscases = c('#485C99','#8F3D52'), col.threshold = '#FCBA04', col.curve = 'black', cex.point = 1.5, alpha.points = .75, alpha.contour = 0.25, lwd.curve = 2, lty.curve = 1, cex = 0.8, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, xlab = NULL, ylab = NULL, lf = NULL, eps = sqrt(.Machine$double.eps), ...)
## S3 method for class 'groc' plot_buildROC(x, FPR = NULL, C = NULL, XL = NULL, XU = NULL, h = c(1,1), histogram = FALSE, breaks = 15, reduce = TRUE, build.process = FALSE, completeROC = FALSE, new.window = FALSE, legends = FALSE, type = 's', cex.point = 1.5, lwd.curve = 2, mar = NULL, lim.density = 0.01, xlim = NULL, ylim = NULL, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, xlab = "Marker", main.density = "Density functions", col.controlscases = c('#485C99','#8F3D52'), col.threshold = '#FCBA04', col.curve = 'black', eps = sqrt(.Machine$double.eps), ...) ## S3 method for class 'multiroc' plot_buildROC(x, FPR = 0.15, display.method = c("PCA", "OV"), displayOV = c(1,2), build.process = FALSE, completeROC = TRUE, new = FALSE, new.window = FALSE, border = FALSE, cutoff = TRUE, legends = FALSE, type = 's', col.controlscases = c('#485C99','#8F3D52'), col.threshold = '#FCBA04', col.curve = 'black', cex.point = 1.5, alpha.points = .75, alpha.contour = 0.25, lwd.curve = 2, lty.curve = 1, cex = 0.8, cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, xlab = NULL, ylab = NULL, lf = NULL, eps = sqrt(.Machine$double.eps), ...)
x |
An ROC curve object from movieROC package. Possible classes are: ‘groc’ (output of |
FPR |
False-positive rate for which the left plot is computed. Default: 0.15. |
C |
Marker cutoff for which the left plot is computed. Only available for a ‘groc’ object. |
XL , XU
|
Marker cutoffs for which the left plot is computed. Only available for object of class ‘groc’ with |
h |
A vector of length 2 with the bandwidth used to compute kernel density estimation for controls and cases, respectively. See |
histogram |
If TRUE, histograms are displayed on the left instead of kernel density estimates. Default: FALSE. Only available for a ‘groc’ object. |
breaks |
If |
reduce |
If FALSE, two extra graphics are displayed at the bottom (see Details for more information). Default: TRUE. Only available for a ‘groc’ object. |
build.process |
If FALSE, the whole ROC curve is displayed; otherwise, if |
completeROC |
If |
new.window , new
|
If TRUE, graphics are displayed in a new window. Default: FALSE. |
legends |
If TRUE, a legend with colors meaning is displayed on the left graphic and the AUC is shown on the right graphic. Default: FALSE. |
type , lty.curve , lwd.curve , col.curve
|
The line type, width and color for ROC curve. Default: |
cex.lab , cex.axis , cex.main
|
The magnification to be used for labels, axis annotation and main titles, respectively, relative to the current setting of |
cex |
A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. Default: 0.8. Not available for object of class ‘groc’ ( |
cex.point |
The magnification to be used for the particular point on the ROC curve and its text, relative to the current setting of |
xlim , ylim
|
Range for x- and y-axis on the left plot. Only available for a ‘groc’ object. |
lim.density |
If |
xlab , ylab
|
Label for x- and y-axis on the left plot. |
main.density |
Title for the left plot. Only available for a ‘groc’ object. |
col.controlscases |
Vector of length 2 with the color used to control and case group, respectively. Default: |
col.threshold |
Color for the chosen point. Default: |
mar |
A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. Only available for a ‘groc’ object. |
eps |
Epsilon value to consider. Default: |
border |
If TRUE, a border for the classification subsets is drawn. Default: FALSE for ‘multiroc’ object (TRUE if |
cutoff |
If TRUE, the cutoff value for the resulting univariate marker is displayed on the right plot (ROC curve). Default: TRUE. Not available for object of class ‘groc’. |
alpha.points , alpha.contour
|
Number in [0,1] modifying the opacity alpha of the color for the points and classification region. The |
lf |
Epsilon value for steps. Not used. Not available for object of class ‘groc’. |
display.method |
Method to display the marker values from a ‘multiroc’ object on the left plot. Methods available: |
displayOV |
If |
... |
Other parameters to be passed. Not used. |
- For univariate ROC curves:
It plots two graphics in the same figure: left, density function estimates for the marker in both populations with the areas corresponding to FPR and TPR colored (blue and red, respectively) for a particular FPR or threshold(s) for the marker; right, the empirical ROC curve estimate.
For an object of class ‘groc’, if the input parameter reduce = FALSE
,
two more graphics are displayed at the bottom:
left, boxplots for the marker distribution in both populations;
right, classification subsets for every false-positive rate (grey color by default).
- For multivariate ROC curves:
Plot two graphics in the same figure: right, the ROC curve highlighting the point and the
threshold for the resulting univariate marker; left, scatterplot with the marker values for controls (blue color) and cases (red color), and the classification subset (in gold color) reporting the false-positive rate selected by the user (if FPR
is not NULL
).
If build.process = FALSE
, the whole ROC curve is displayed; otherwise, if completeROC = TRUE
,
the portion of the ROC curve until the fixed FPR is highlighted in black and the rest is
shown in gray, while if completeROC = FALSE
, only the first portion of the curve is illustrated.
A plot of the building procedure of the ROC curve with the selected graphical parameters
If method = "kernelOptimal"
in a ‘multiroc’ object, the na.locf()
function in the zoo package is used.
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor, side = "right") plot_buildROC(roc_cg20202438) plot_buildROC(roc_cg20202438, C = .77, build.process = TRUE, reduce = FALSE) # Multivariate ROC curve for genes 0202438, 18384097, and 03515901 multiroc_PT <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") plot_buildROC(multiroc_PT, cex = 1.2, lwd.curve = 4) # Two first components from PCA plot_buildROC(multiroc_PT, display.method = "OV", displayOV = c(1,3), cex = 1.2, xlab = "Gene 20202438", ylab = "Gene 03515901", lwd.curve = 4)
data(HCC) # Standard ROC curve for gene 20202438 roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor, side = "right") plot_buildROC(roc_cg20202438) plot_buildROC(roc_cg20202438, C = .77, build.process = TRUE, reduce = FALSE) # Multivariate ROC curve for genes 0202438, 18384097, and 03515901 multiroc_PT <- multiROC(X = cbind(HCC$cg20202438, HCC$cg18384097, HCC$cg03515901), D = HCC$tumor, method = "fixedLinear", methodLinear = "PepeThompson") plot_buildROC(multiroc_PT, cex = 1.2, lwd.curve = 4) # Two first components from PCA plot_buildROC(multiroc_PT, display.method = "OV", displayOV = c(1,3), cex = 1.2, xlab = "Gene 20202438", ylab = "Gene 03515901", lwd.curve = 4)
This function plots the kernel density function estimates for controls and cases from an object of class ‘groc’. It offers the possibility of plotting the histograms instead of the smooth estimates.
plot_densities(obj, h = c(1, 1), histogram = FALSE, breaks = 15, col = c("#485C99", "#8F3D52"), lwd = 2, xlim = NULL, ylim = NULL, xaxs = "i", yaxs = "i", xlab = "Marker", ylab = "f(x)", main = "Density functions", legend = FALSE, pos.legend = "topright", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, cex.legend = 1, eps = sqrt(.Machine$double.eps), new = TRUE, ...)
plot_densities(obj, h = c(1, 1), histogram = FALSE, breaks = 15, col = c("#485C99", "#8F3D52"), lwd = 2, xlim = NULL, ylim = NULL, xaxs = "i", yaxs = "i", xlab = "Marker", ylab = "f(x)", main = "Density functions", legend = FALSE, pos.legend = "topright", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2, cex.legend = 1, eps = sqrt(.Machine$double.eps), new = TRUE, ...)
obj |
An object of class ‘groc’. |
h |
A vector of length 2 with the bandwidth used to compute kernel density estimation for controls and cases, respectively. See |
histogram |
If TRUE, histograms are displayed instead of kernel density estimates. Default: FALSE. |
breaks |
If |
col |
A vector of length 2 with color used for controls and cases, respectively. Default: |
lwd |
Line width for the density function or histogram. Default: 2. |
xlim , ylim
|
Range for x- and y-axis. |
xaxs , yaxs
|
The style of axis interval calculation to be used for the x- and the y-axis, respectively. Default: |
xlab , ylab
|
Label for x- and y-axis. |
main |
Title for the plot. |
cex.lab , cex.axis , cex.main
|
The magnification to be used for labels, axis annotation and main titles, respectively, relative to the current setting of |
legend |
If TRUE, a legend with the meaning of colors is displayed on the left plot. Default: FALSE. |
pos.legend , cex.legend
|
The position and magnification to be used for legend, relative to the current setting of |
eps |
Epsilon value to consider. Default: |
new |
If TRUE, a new plot is displayed; otherwise, density estimates are displayed over the current plot. Default: TRUE. |
... |
Other parameters to be passed. Not used. |
A plot of the kernel density function estimates for both populations with the selected graphical parameters
data(HCC) roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) plot_densities(roc_cg20202438, main = "Density functions and histogram") plot_densities(roc_cg20202438, histogram = TRUE, new = FALSE)
data(HCC) roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) plot_densities(roc_cg20202438, main = "Density functions and histogram") plot_densities(roc_cg20202438, histogram = TRUE, new = FALSE)
This function estimates the standard ROC curve (right- or left-sided, depending on the side
of the object of class ‘groc’ included) resulting from the kernel density function estimation for controls and cases. Two graphics are displayed: left, the kernel density estimates; right, the resulting ROC curve. Two extra graphics may be shown at the bottom if the used introduces a value for the input parameter C
: left, boxplots and points for controls and cases and corresponding classification subset in gray color; right, classification subsets for every FPR until the one corresponding to the chosen C
.
plot_densityROC(obj, h = c(1, 1), C = NULL, build.process = FALSE, completeROC = TRUE, legends = FALSE, rel.tol = 0.001, par.specify = FALSE, cex.lab = 1.5, cex.axis = 1.25, cex.main = 1.75, lwd = 2, col = c("#485C99", "#8F3D52"), col.roc = "blue", ...)
plot_densityROC(obj, h = c(1, 1), C = NULL, build.process = FALSE, completeROC = TRUE, legends = FALSE, rel.tol = 0.001, par.specify = FALSE, cex.lab = 1.5, cex.axis = 1.25, cex.main = 1.75, lwd = 2, col = c("#485C99", "#8F3D52"), col.roc = "blue", ...)
obj |
An object of class ‘groc’ with |
h |
A vector of length 2 with the bandwidth used to compute kernel density estimation for controls and cases, respectively. See |
C |
Marker cutoff for which the graphics are displayed. Default: none. |
build.process |
If FALSE, the whole ROC curve is displayed; otherwise, if |
completeROC |
If |
legends |
If TRUE, legends with the meaning of colors are displayed. Default: FALSE. |
rel.tol |
Relative accuracy requested for the |
par.specify |
If FALSE, graphics are organized in one row and two columns. Default: FALSE. |
cex.lab , cex.axis , cex.main
|
The magnification to be used for labels, axis annotation and main titles, respectively, relative to the current setting of |
lwd , col.roc
|
Line width and color for the ROC curve. Default: |
col |
A vector of length 2 with color used for controls and cases, respectively. Default: |
... |
Other parameters to be passed. Not used. |
A plot of the standard smooth ROC curve estimate with the selected graphical parameters
data(HCC) roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) plot_densityROC(roc_cg20202438) plot_densityROC(roc_cg20202438, h = c(2,2))
data(HCC) roc_cg20202438 <- gROC(X = HCC$cg20202438, D = HCC$tumor) plot_densityROC(roc_cg20202438) plot_densityROC(roc_cg20202438, h = c(2,2))
This function plots the transformation function used for the marker for an object of class ‘hroc’ or class ‘groc’ (this one is only allowed for objects with self-contained classification subsets).
Over this graphic, the classification region for a particular FPR chosen by the user is displayed in blue color.
If the user specifies a second FPR (FPR2
), the classification region is displayed on the same graphic in red color.
## S3 method for class 'hroc' plot_funregions(x, FPR = 0.15, FPR2 = NULL, plot.subsets = TRUE, new.window = FALSE, main = NULL, ylim = NULL, ...) ## S3 method for class 'groc' plot_funregions(x, FPR = 0.15, FPR2 = NULL, plot.subsets = TRUE, new.window = FALSE, main = NULL, ylim = NULL, ...)
## S3 method for class 'hroc' plot_funregions(x, FPR = 0.15, FPR2 = NULL, plot.subsets = TRUE, new.window = FALSE, main = NULL, ylim = NULL, ...) ## S3 method for class 'groc' plot_funregions(x, FPR = 0.15, FPR2 = NULL, plot.subsets = TRUE, new.window = FALSE, main = NULL, ylim = NULL, ...)
x |
An object of class ‘hroc’ or ‘groc’. |
FPR |
False-positive rate used to display the classification region in blue. Default: 0.15. |
FPR2 |
Other false-positive rate used to display the classification region in red. Default: none. |
plot.subsets |
If TRUE, the classification subsets are displayed. Otherwise, only the transformation function. Default: TRUE. |
new.window |
If TRUE, graphics are displayed in a new window. Default: FALSE. |
main |
Title for the plot. |
ylim |
Range for the y-axis. |
... |
Other parameters to be passed. Not used. |
A plot of the transformation function used for the marker with the selected graphical parameters
data(HCC) hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") plot_funregions(hroc_cg18384097) plot_funregions(hroc_cg18384097, FPR = .1, FPR2 = .5)
data(HCC) hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") plot_funregions(hroc_cg18384097) plot_funregions(hroc_cg18384097, FPR = .1, FPR2 = .5)
This function plots the classification regions for univariate markers. It works for objects of class ‘groc’ and ‘hroc’. Two graphics are displayed in the same figure: left, classification subsets for every false-positive rate (grey color by default); right, 90º rotated ROC curve.
## S3 method for class 'groc' plot_regions(x, FPR = 0.15, plot.roc = TRUE, plot.auc = FALSE, col = c("white", "grey"), col.FPR = "blue", lwd = 2, new.window = TRUE, type.plotroc = "s", xlim = NULL, mar = c(5, 6, 4, 0.25), cex.lab = 1.5, cex.axis = 1.5, cex.main = 1.75, main = NULL, xlab = "", ylab = "False-Positive Rate", main.plotroc = "ROC curve", legend = TRUE, cex.legend = 1, ...) ## S3 method for class 'hroc' plot_regions(x, FPR = 0.15, plot.roc = TRUE, plot.auc = FALSE, col = c('white','grey'), col.FPR = 'blue', lwd = 2, new.window = TRUE, type.plotroc = 's', xlim = NULL, mar = c(5,6,4,0.25), cex.lab = 1.5, cex.axis = 1.5, cex.main = 1.75, main = NULL, xlab = "", ylab = "False-Positive Rate", main.plotroc = "ROC curve", legend = TRUE, cex.legend = 1, verbose = FALSE, ...)
## S3 method for class 'groc' plot_regions(x, FPR = 0.15, plot.roc = TRUE, plot.auc = FALSE, col = c("white", "grey"), col.FPR = "blue", lwd = 2, new.window = TRUE, type.plotroc = "s", xlim = NULL, mar = c(5, 6, 4, 0.25), cex.lab = 1.5, cex.axis = 1.5, cex.main = 1.75, main = NULL, xlab = "", ylab = "False-Positive Rate", main.plotroc = "ROC curve", legend = TRUE, cex.legend = 1, ...) ## S3 method for class 'hroc' plot_regions(x, FPR = 0.15, plot.roc = TRUE, plot.auc = FALSE, col = c('white','grey'), col.FPR = 'blue', lwd = 2, new.window = TRUE, type.plotroc = 's', xlim = NULL, mar = c(5,6,4,0.25), cex.lab = 1.5, cex.axis = 1.5, cex.main = 1.75, main = NULL, xlab = "", ylab = "False-Positive Rate", main.plotroc = "ROC curve", legend = TRUE, cex.legend = 1, verbose = FALSE, ...)
x |
An ROC curve object from a univariate marker. Possible classes are: ‘groc’ (output of |
FPR |
False-positive rate to be highlighted, both on the ROC curve (right plot) and classification subset (left plot). Default: 0.15. |
plot.roc |
If TRUE, the ROC curve is displayed. Default: TRUE. |
plot.auc |
If TRUE, the AUC is displayed on the plot of the bottomleft corner of the ROC curve plot. Default: FALSE. |
col |
Vector of length 2 with colors used for outside and inside of classification subsets, respectively. Default: |
col.FPR |
Color used to highlight the |
type.plotroc , lwd
|
Line type and width for the ROC curve. Default: |
new.window |
If TRUE, graphics are displayed in a new window. Default: TRUE. |
xlim |
Range for x-axis on the left plot. Default: range of the marker values. |
mar |
A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. |
cex.lab , cex.axis , cex.main
|
The magnification to be used for labels, axis annotation and main titles, respectively, relative to the current setting of |
xlab , ylab
|
Label for x- and y-axis on the left plot. |
main , main.plotroc
|
Title for the left and the right plot, respectively. |
legend |
If TRUE, a legend with the meaning of colors is displayed on the left plot. Default: TRUE. |
cex.legend |
The magnification to be used for legend, relative to the current setting of |
verbose |
If TRUE, a progress bar is displayed. Default: FALSE. |
... |
Other parameters to be passed. Not used. |
A plot of the classification regions underlying a ROC curve with the selected graphical parameters
data(HCC) # 1. Standard ROC curve roc_cg18384097 <- gROC(X = HCC$cg18384097, D = HCC$tumor) plot_regions(roc_cg18384097, plot.auc = TRUE) # 2. gROC curve groc_cg18384097 <- gROC(X = HCC$cg18384097, D = HCC$tumor, side = "both") plot_regions(groc_cg18384097, plot.auc = TRUE) # 3. hROC curve with a restricted cubic splines transformation hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") plot_regions(hroc_cg18384097, plot.auc = TRUE)
data(HCC) # 1. Standard ROC curve roc_cg18384097 <- gROC(X = HCC$cg18384097, D = HCC$tumor) plot_regions(roc_cg18384097, plot.auc = TRUE) # 2. gROC curve groc_cg18384097 <- gROC(X = HCC$cg18384097, D = HCC$tumor, side = "both") plot_regions(groc_cg18384097, plot.auc = TRUE) # 3. hROC curve with a restricted cubic splines transformation hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") plot_regions(hroc_cg18384097, plot.auc = TRUE)
This function prints the classification subsets corresponding to a particular false-positive rate FPR
or to cutoff value(s) C
or XL, XU
introduced by the user.
## S3 method for class 'groc' predict(object, FPR = NULL, C = NULL, XL = NULL, XU = NULL, ...) ## S3 method for class 'hroc' predict(object, FPR = 0.15, ...)
## S3 method for class 'groc' predict(object, FPR = NULL, C = NULL, XL = NULL, XU = NULL, ...) ## S3 method for class 'hroc' predict(object, FPR = 0.15, ...)
object |
An object of class ‘groc’ or ‘hroc’. |
FPR |
False-positive rate used to predict the classification region. Default: 0.15 if no cutoff value is provided by the next input parameters. |
C |
Cutoff value used to predict the classification region for ‘groc’ object with |
XL , XU
|
Cutoff values used to predict the classification region for ‘groc’ object with |
... |
Other parameters to be passed. Not used. |
A list of length 3 with the following fields:
ClassSubsets |
A matrix with the classification region. Number of rows indicate the number of intervals whose union defines the classification region. |
Specificity |
Resulting specificity value. |
Sensitivity |
Resulting sensitivity value. |
data(HCC) roc <- gROC(X = HCC$cg18384097, D = HCC$tumor) # Right-sided ROC curve predict(roc, FPR = 0.5) groc <- gROC(X = HCC$cg18384097, D = HCC$tumor, side = "both") # gROC curve predict(groc, FPR = 0.5) hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") predict(hroc_cg18384097, FPR = 0.5)
data(HCC) roc <- gROC(X = HCC$cg18384097, D = HCC$tumor) # Right-sided ROC curve predict(roc, FPR = 0.5) groc <- gROC(X = HCC$cg18384097, D = HCC$tumor, side = "both") # gROC curve predict(groc, FPR = 0.5) hroc_cg18384097 <- hROC(X = HCC$cg18384097, D = HCC$tumor, formula.lrm = "D ~ rcs(X,8)") predict(hroc_cg18384097, FPR = 0.5)
This function prints information about an ROC curve.
## S3 method for class 'groc' print(x, ...) ## S3 method for class 'hroc' print(x, ...) ## S3 method for class 'multiroc' print(x, ...)
## S3 method for class 'groc' print(x, ...) ## S3 method for class 'hroc' print(x, ...) ## S3 method for class 'multiroc' print(x, ...)
x |
An ROC curve object from the movieROC package. Possible classes are:
‘groc’ (output of |
... |
Other parameters to be passed. Not used. |
A character vector with the details of an ROC curve object.
## See examples for gROC(), hROC(), and multiROC() function
## See examples for gROC(), hROC(), and multiROC() function