[Analogue-commits] r160 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 2 16:47:59 CET 2010


Author: gsimpson
Date: 2010-03-02 16:47:59 +0100 (Tue, 02 Mar 2010)
New Revision: 160

Modified:
   pkg/R/plot.roc.R
   pkg/inst/ChangeLog
   pkg/man/plot.roc.Rd
Log:
add more flexible handling of line types in plot.roc

Modified: pkg/R/plot.roc.R
===================================================================
--- pkg/R/plot.roc.R	2010-03-02 08:30:14 UTC (rev 159)
+++ pkg/R/plot.roc.R	2010-03-02 15:47:59 UTC (rev 160)
@@ -6,6 +6,7 @@
                      abline.col = "grey",
                      inGroup.col = "red",
                      outGroup.col = "blue",
+                     lty = "solid",
                      caption = c("ROC curve",
                        "Dissimilarity profiles",
                      "TPF - FPF vs Dissimilarity",
@@ -34,12 +35,15 @@
         }
     }
     method <- attr(x, "method")
+    ## replicate lty if length 1
+    if(length(lty) == 1L)
+      lty <- rep(lty, 2)
     if(show[1]) {
         plot(x$roc[[group]]$FPE, x$roc[[group]]$TPF, type = "n",
              ylab = "TPF (sensitivity)",
              xlab = "1 - TNF (1 - specificity)")
         abline(0, 1, col = abline.col)
-        lines(x$roc[[group]]$FPE, x$roc[[group]]$TPF, ...)
+        lines(x$roc[[group]]$FPE, x$roc[[group]]$TPF, lty = lty[1L], ...)
         mtext(caption[1], side = 3, line = 1.7, font = 2)
         if(show.stats) {
             txt <- paste("AUC =", round(x$roc[[group]]$AUC, 3))
@@ -62,8 +66,8 @@
              xlab = paste("Dissimilarity (", attr(x, "method"), ")",
              sep = ""))
         abline(h = 0, col = abline.col)
-        lines(dens.in, col = inGroup.col)
-        lines(dens.out, col = outGroup.col)
+        lines(dens.in, col = inGroup.col, lty = lty[1L], ...)
+        lines(dens.out, col = outGroup.col, lty = lty[2L], ...)
         abline(v = x$roc[[group]]$optimal, lty = "dotted",
                col = abline.col)
         axis(side = 2)
@@ -72,9 +76,9 @@
         mtext(caption[2], side = 3, line = 1.7, font = 2)
         legend("topright", legend = c("Analogue", "Not Analogue"),
                col = c(inGroup.col, outGroup.col),
-               lty = "solid", lwd = 1,
+               lty = lty[c(1L,2L)],
                bty = "n", cex = 0.8,
-               inset = 0.01)
+               inset = 0.01, ...)
     }
     if(show[3]) {
         cutpoints <- unique(rev(x$roc[[group]]$roc.points))
@@ -84,7 +88,7 @@
              xlab = paste("Dissimilarity (", attr(x, "method"), ")",
              sep = ""))
         abline(h = 0, col = abline.col)
-        lines(cutpoints, roc.values)
+        lines(cutpoints, roc.values, lty = lty[1L], ...)
         abline(v = x$roc[[group]]$optimal, lty = "dotted",
                col = abline.col)
         mtext(caption[3], side = 3, line = 1.7, font = 2)
@@ -99,7 +103,7 @@
              sep = ""))
         abline(v = x$roc[[group]]$optimal, lty = "dotted",
                col = abline.col)
-        lines(dissims, pos, col = inGroup.col)
+        lines(dissims, pos, col = inGroup.col, lty = lty[1L], ...)
         axis(side = 1)
         axis(side = 2)
         usr <- par("usr")
@@ -108,22 +112,22 @@
                  min(neg[finite.vals])) * 0.04
         par(usr = c(usr[1:2], min(neg[finite.vals]) - rany,
             max(neg[finite.vals]) + rany))
-        lines(dissims, neg, col = outGroup.col)
+        lines(dissims, neg, col = outGroup.col, lty = lty[2L], ...)
         axis(side = 4)
         box()
         mtext(caption[4], side = 3, line = 1.7, font = 2)
         legend("topright", legend = c("LR (+)", "LR (-)"),
                col = c(inGroup.col, outGroup.col),
-               lty = "solid", lwd = 1,
+               lty = lty,
                bty = "n", cex = 0.8,
-               inset = 0.01)
+               inset = 0.01, ...)
     }
     if(show[5]) {
         plot(l.ratios, group = group,
              abline.col = abline.col, col = inGroup.col,
              ylab = "Pr (A+ | d)",
              xlab = paste("Dissimilarity (", attr(x, "method"), ")",
-             sep = ""))
+             sep = ""), lty = lty[1L], ...)
         ##mtext(caption[5], side = 3, line = 1.7, font = 2)
     }
     invisible()

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-03-02 08:30:14 UTC (rev 159)
+++ pkg/inst/ChangeLog	2010-03-02 15:47:59 UTC (rev 160)
@@ -19,6 +19,10 @@
 	statistics. Fixed to use the points established by 'table', used to
 	generate these other statistics. This affected the plot method.
 
+	* plot.roc: Allow user to specify the line types used to draw the
+	plots. Two line types can be specified for plots comparing analogue
+	with non-analogue statistics.
+
 Version 0.6-22
 
 	* tran.formula: bug in my implementation of the standard

Modified: pkg/man/plot.roc.Rd
===================================================================
--- pkg/man/plot.roc.Rd	2010-03-02 08:30:14 UTC (rev 159)
+++ pkg/man/plot.roc.Rd	2010-03-02 15:47:59 UTC (rev 160)
@@ -18,6 +18,7 @@
      abline.col = "grey",
      inGroup.col = "red",
      outGroup.col = "blue",
+     lty = "solid",
      caption = c("ROC curve", "Dissimilarity profiles",
                  "TPF - FPF vs Dissimilarity",
                  "Likelihood ratios"),
@@ -48,6 +49,13 @@
   \item{outGroup.col}{character string or numeric value; the colour used
     to draw the density curve for the dissimilarities between sites not in
     the same group.}
+  \item{lty}{vector of at most length 2 (elements past the second in
+    longer vectors are ignored) line types. The first element of
+    \code{lty} will be used where a single line is drawn on a
+    plot. Where two lines are drawn (for analogue and non-analogue
+    cases), the first element pertains to the analogue group and the
+    second element to the non-analogue group. See \code{\link{par}} for
+    the allowed line types.}
   \item{caption}{vector of character strings, containing the captions to
     appear above each plot.}
   \item{legend}{character; position of legends drawn on plots. See
@@ -130,7 +138,6 @@
   One or more plots, drawn on the current device.
 }
 \references{
-  
   Brown, C.D., and Davis, H.T. (2006) Receiver operating characteristics
   curves and related decision measures: A tutorial. \emph{Chemometrics
     and Intelligent Laboratory Systems} \bold{80}, 24--38.



More information about the Analogue-commits mailing list