metsROC: Creates ROC curves using ggplot()

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/metsROC.R

Description

Users provide a binary outcome, metabolites, and covariates. Logistic regression models are fit for each of the metabolites and ROC curves are returned. Users have the choice of plotting single or multiple curves on each figure.

Usage

1
2
3
metsROC(dat, outcome, compid, covariates, normalize=T, xlabel = "1 - Specificity",
ylabel = "Sensitivity", title = NULL, colors = NULL, title_size = 10,
subtitle_size = 10, xaxis_size = 9, yaxis_size = 9, plot_theme = NULL)

Arguments

dat

Data frame containing outcome, metabolites, and covariates data

outcome

Binary outcome variable, must be coded [0,1] for a logistic regression.

compid

Vector of metabolite COMP_IDs. If you include more than one COMP_ID, all will be plotted on a single figure.

covariates

Vector of covariate names.

normalize

Logical. Set to TRUE if you haven't already mean-centered and glog transformed your metabolite data. Default is TRUE.

xlabel

X-axis title - defaults to "1 - Specificity"

ylabel

Y-axis title - defaults to "Sensitivity"

title

Optional title. If you don't include a title, the function will provide one for you.

colors

Optional vector of colors for each curve. length(colors) must equal length(compid)

title_size

Optional text size for title.

subtitle_size

Optional text size for subtitle.

xaxis_size

Optional text size for x-axis.

yaxis_size

Optional text size for y-axis.

plot_theme

Optional ggplot theme object. Users can create their own custom theme. This provides the ability to edit parts of the figure as needed.

Details

the metsROC() function uses ggplot2 to create ROC curves for any number of metabolites. Users should be able to edit the most important aspects of the plot using the arguments in the function; others can be adjusted using theme() elements, or accept the defaults. The function returns a ggplot2 object, so you can edit the plot after running the function.

Value

a ggplot2 object

Author(s)

Brian Carter and Becky Hodge

See Also

ggplot2, plotROC, normalizeMets

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
breast_metabolomics <- getMetabolites("breast_metabolomics")

biochem <- breast_metabolomics$biochem

metdata <- dplyr::left_join(survey,breast_metabolomics$metabolites,"ID")

comp.id <- sample(biochem$COMP_ID,50,replace=T)

# categorize BMI
metdata$BMIBIN <- metdata$BMIBIN-1



png("test ROC.png",height=6,width=6,units="in",res=400)
metsROC(dat=metdata,
        outcome="BMIBIN",
        compid=comp.id[1:5],
        covariates="AGE_INT",
        normalize=T,
        xlabel="1 - Specificity",
        ylabel="Sensitivity",
        title=NULL,
        colors=NULL,
        title_size=10,
        #subtitle_size=12,
        #xaxis_size=12,
        #yaxis_size=12,
        plot_theme=NULL)
dev.off()

buddha2490/BERGMets documentation built on Sept. 6, 2020, 5:11 p.m.