forked from ecpolley/plotROC
-
Notifications
You must be signed in to change notification settings - Fork 0
Interactive ROC plots with ggplot + d3.js.
License
guhjy/plotROC
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
[![Build Status](https://travis-ci.org/sachsmc/plotROC.png?branch=master)](https://travis-ci.org/sachsmc/plotROC) # Generate interactive ROC plots from R using ggplot Most ROC curve plots obscure the cutoff values and inhibit interpretation and comparison of multiple curves. This attempts to address those shortcomings by providing plotting and interactive tools. Functions are provided to generate an interactive ROC curve plot for web use, and print versions. An interacive Shiny application is also included. ## Installation This package is not currently on CRAN. To install, use `devtools` ```{r install} devtools::install_github("sachsmc/plotROC") ``` ## Basic usage See examples live [here](http://sachsmc.github.io/plotROC) # Interactive SVG ROC Curves After installing, run the interactive Shiny app ```{r shiny, eval = FALSE} shiny_plotROC() ``` ## Hover over to view the cutoff values ```{r test-a, fig.keep='none', results = 'asis', echo = TRUE, fig.width=6, fig.height=6} library(plotROC) D.ex <- rbinom(100, 1, .5) rocdata <- calculate_roc(rnorm(100, mean = D.ex), D.ex) myrocplot <- ggroc(rocdata, label = "Example") cat(export_interactive_roc(myrocplot, cutoffs = rocdata$c, font.size = "12px", prefix = "a")) ``` ## Click to view confidence region ```{r test-a-ci, fig.keep='none', results = 'asis', echo = TRUE, fig.width=6, fig.height=6} rocdata <- calculate_roc(rnorm(100, mean = D.ex), D.ex, CI = TRUE) myrocplot <- ggroc(rocdata, label = "Example", ci = TRUE) cat(export_interactive_roc(myrocplot, cutoffs = rocdata$c, font.size = "12px", prefix = "aci")) ``` That is an svg element. Try zooming in! ## Generate an interactive plot to view in Rstudio viewer or web browser ```{r inter, eval = FALSE} plot_interactive_roc(rocdata) ``` # Themes and annotations ```{r test-b, fig.keep='none', results = 'asis', echo = TRUE, fig.width=6, fig.height=6} library(ggthemes) myplot2 <- myrocplot + theme_igray() cat(export_interactive_roc(myplot2, cutoffs = rocdata$c, font.size = "12px", prefix = "b")) ``` # For using in print ```{r print, fig.width = 6, fig.height = 6} plot_journal_roc(myrocplot, rocdata) ``` # Themes work in print too, but I don't recommend colors ```{r print2, fig.width = 6, fig.height = 6} plot_journal_roc(myrocplot, rocdata) + theme_igray() + ggtitle("My awesome new biomarker") ``` # Multiple ROC Curves ```{r multi, fig.width = 6, fig.height = 6} D.ex <- rbinom(100, 1, .5) fakedata <- data.frame(M1 = rnorm(100, mean = D.ex), M2 = rnorm(100, mean = D.ex, sd = .4), M3 = runif(100), D = D.ex) datalist <- calculate_multi_roc(fakedata, c("M1", "M2", "M3"), "D") rocplot <- multi_ggroc(datalist) plot_journal_roc(rocplot, datalist) ``` ```{r test-multi, fig.keep='none', results = 'asis', echo = TRUE, fig.width=6, fig.height=6} cat(export_interactive_roc(rocplot, cutoffs = lapply(datalist, function(d) d$c), font.size = "12px", prefix = "bmulti")) ``` ## Labels ```{r multi2, fig.width = 6, fig.height = 6} D.ex <- rbinom(100, 1, .5) fakedata <- data.frame(M1 = rnorm(100, mean = D.ex), M2 = rnorm(100, mean = D.ex, sd = .4), M3 = runif(100), D = D.ex) datalist <- calculate_multi_roc(fakedata, c("M1", "M2", "M3"), "D") rocplot <- multi_ggroc(datalist, label = c("M1", "M2", "M3")) plot_journal_roc(rocplot, datalist) ``` # Acknowledgements This package would not be possible without the following: - [ggplot2](http://ggplot2.org/) - [gridSVG](http://sjp.co.nz/projects/gridsvg/) - [d3.js](http://d3js.org) # License The MIT License (MIT) Copyright (c) 2014 Michael C Sachs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Interactive ROC plots with ggplot + d3.js.
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- HTML 99.1%
- R 0.9%