[Genabel-commits] r934 - pkg/PredictABEL/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 30 10:24:11 CEST 2012


Author: lckarssen
Date: 2012-07-30 10:24:11 +0200 (Mon, 30 Jul 2012)
New Revision: 934

Modified:
   pkg/PredictABEL/R/PredictABEL.R
Log:
In PredictABEL.R: added 'require(PBSmodelling)' line and adjusted code layout in the 'plotPredictivenessCurve()' function (only whitespace changes).

Modified: pkg/PredictABEL/R/PredictABEL.R
===================================================================
--- pkg/PredictABEL/R/PredictABEL.R	2012-07-30 08:17:10 UTC (rev 933)
+++ pkg/PredictABEL/R/PredictABEL.R	2012-07-30 08:24:11 UTC (rev 934)
@@ -1185,68 +1185,76 @@
 #'  rangeyaxis=rangeyaxis, labels=labels)
 #'
 "plotPredictivenessCurve" <-
-function(predrisk, rangeyaxis, labels, plottitle, xlabel, ylabel, fileplot, plottype)
- {
-   if (missing(plottitle)) {plottitle <- "Predictiveness curve"}
-  if (missing(xlabel)) {xlabel<- "Cumulative percentage"}
-  if (missing(ylabel)) {ylabel<- "Predicted risks"}
-  if (missing(rangeyaxis)) {rangeyaxis<- c(0,1)}
- if (class(predrisk) == "numeric") {predrisk<- cbind(predrisk)}
-# if (missing(labels)) {labels <- c(1:dim(predrisk)[2])}
-a<-c(1:dim(predrisk)[2])
-for(i in 1:dim(predrisk)[2])
-		{
-  x<-predrisk[,i]
-   if (i==1)
-   {
-    xlim = c(0, 1)
-    ylim = c(0, 1)
-    xlab = xlabel
-    ylab = ylabel
-    x <- sort(x)
-    n <- length(x)
-    y <- (1:n)/n
-    z <- y >= ylim[1] & y <= ylim[2]
-
-resetGraph()
-evalCall(plot, argu = list(x = y[z], y = x[z], type = "n",
-xlab = "", ylab = "", las = 1, mgp = c(0, 0.6, 0),cex.axis =1.1, col=16+i,lty=i,
-ylim=rangeyaxis,main =plottitle), checkdef=TRUE, checkpar = TRUE)
-
-    evalCall(lines, argu = list(x = y[z], y = x[z],col=16+i,lty=i, lwd=2),
-    checkdef = TRUE, checkpar = TRUE)
-    mtext(xlab, side = 1, line = 2.75, cex = 1.2)
-    mtext(ylab, side = 2, line = 2.5, cex = 1.2)
-    invisible(data.frame(x = x, y = y))
-   }
-     else
-   {
-    xlim = c(0, 1)
-    ylim = c(0, 1)
-    x <- sort(x)
-    n <- length(x)
-    y <- (1:n)/n
-    z <- y >= ylim[1] & y <= ylim[2]
-
-    evalCall(lines, argu = list(x = y[z], y = x[z],col=16+i,lty=i,lwd=2,
-    add= TRUE), checkdef = TRUE, checkpar = TRUE)
-    mtext(xlab, side = 1, line = 2.75, cex = 1.2)
-    mtext(ylab, side = 2, line = 2.5, cex = 1.2)
-    invisible(data.frame(x = x, y = y))
-   }
-  	}
-  		  if (!missing(labels)){
-legend("bottomright",legend= labels,  col = c(17:(16+dim(predrisk)[2])),
-lty=c(1:(dim(predrisk)[2])),lwd = 2,cex=1)
-}
- if (missing(plottype)) {plottype<- "jpg"}
- 	if (!missing(fileplot))
+  function(predrisk, rangeyaxis, labels, plottitle, xlabel, ylabel, fileplot, plottype)
+  {
+    require(PBSmodelling)
+    
+    if (missing(plottitle)) {plottitle <- "Predictiveness curve"}
+    if (missing(xlabel)) {xlabel <- "Cumulative percentage"}
+    if (missing(ylabel)) {ylabel <- "Predicted risks"}
+    if (missing(rangeyaxis)) { rangeyaxis<- c(0,1)}
+    if (class(predrisk) == "numeric") {predrisk <- cbind(predrisk)}
+#    if (missing(labels)) {labels <- c(1:dim(predrisk)[2])}
+    a <- c(1:dim(predrisk)[2])
+    for(i in 1:dim(predrisk)[2])
+      {
+        x <- predrisk[,i]
+        if (i==1)
+          {
+            xlim <- c(0, 1)
+            ylim <- c(0, 1)
+            xlab <- xlabel
+            ylab <- ylabel
+            x <- sort(x)
+            n <- length(x)
+            y <- (1:n)/n
+            z <- y >= ylim[1] & y <= ylim[2]
+            
+            resetGraph()
+            evalCall(plot,
+                     argu = list(x = y[z], y = x[z], type = "n",
+                       xlab = "", ylab = "", las = 1, mgp = c(0, 0.6, 0),
+                       cex.axis =1.1, col=16+i, lty=i,
+                       ylim = rangeyaxis, main = plottitle),
+                     checkdef = TRUE,
+                     checkpar = TRUE)
+           
+            evalCall(lines,
+                     argu = list(x = y[z], y = x[z], col=16+i, lty=i, lwd=2),
+                     checkdef = TRUE,
+                     checkpar = TRUE)
+            mtext(xlab, side = 1, line = 2.75, cex = 1.2)
+            mtext(ylab, side = 2, line = 2.5, cex = 1.2)
+            invisible(data.frame(x = x, y = y))
+          }
+        else
+          {
+            xlim <- c(0, 1)
+            ylim <- c(0, 1)
+            x <- sort(x)
+            n <- length(x)
+            y <- (1:n)/n
+            z <- y >= ylim[1] & y <= ylim[2]
+            
+            evalCall(lines,
+                     argu = list(x = y[z], y = x[z], col=16+i,lty=i,lwd=2,
+                       add= TRUE), checkdef = TRUE, checkpar = TRUE)
+            mtext(xlab, side = 1, line = 2.75, cex = 1.2)
+            mtext(ylab, side = 2, line = 2.5, cex = 1.2)
+            invisible(data.frame(x = x, y = y))
+          }
+      }
+    if (!missing(labels)){
+      legend("bottomright", legend = labels, col = c(17:(16+dim(predrisk)[2])),
+             lty = c(1:(dim(predrisk)[2])), lwd = 2, cex = 1)
+    }
+    if (missing(plottype)) {plottype <- "jpg"}
+    if (!missing(fileplot))
       savePlot(filename = fileplot,
-	 type =plottype,
-	 device = dev.cur())
+               type = plottype,
+               device = dev.cur())
+  }
 
-
- }
 #' Function to plot histogram of risks separated for individuals with and without the outcome of interest.
 #'
 #'



More information about the Genabel-commits mailing list