[R] analyzing suvival data using splines (a.k.a., piecewise log-hazard-ratio models)
I'm looking for software that makes plots such as fig 4 (a)-(e), fig 5 anf fig 7 of Gray, Robert, "Flexible Methods for Analyzing Survival Data Using Splines, with Applications to Breast Cancer Prognosis," 1992, J Am Stat Assoc, pp 942-51. In other words, I'm looking for software that takes survival data and a continuous covariate as input and computes a curve giving log hazard ratio (or rate of failure for a specific time) as a function of the continuous covariate, as well as curves giving +-SE for that curve. A plot of this nature can also be found as figure 4 in Paik, et al., "A Multigene Assay to Predict Recurrence of Tamoxifen-Treated, Node-Negative Breast Cancer," 2004, New England Journal of Medicine, pp 2817-26. Any help would be greatly appreciated. Thanks. -Ben Ben Wittner Research fellow, MGH & Harvard Medical School [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem building dendrograms to use with heatmap()
Hi, I'm trying to build dendrograms to pass to heatmap(). The dendrograms I build plot properly, but when I pass them to heatmap() I get the error message "row dendrogram ordering gave index of wrong length" (see output log below). I looked in the code of heatmap() and saw that the error was due to a NULL return value from order.dendrogram(), which in turn got a NULL return value from unlist(). But I have no idea why unlist() is returning NULL. I've included code below which reproduces the problem and below that the output from a run of that code on my computer. Any help would be greatly appreciated. Thanks in advance. -Ben ### begin code ### version dendro.leaf <- function(label) { ans <- list() attr(ans, 'members') <- 1 attr(ans, 'height') <- 0 attr(ans, 'leaf') <- T attr(ans, 'midpoint') <- 0 attr(ans, 'label') <- label attr(ans, 'class') <- 'dendrogram' ans } dendro.merge <- function(d1, d2, height) { ans <- list(d1, d2) members <- attr(d1, 'members') + attr(d2, 'members') attr(ans, 'members') <- members attr(ans, 'height') <- height attr(ans, 'leaf') <- F attr(ans, 'midpoint') <- (members - 1)/2 attr(ans, 'class') <- 'dendrogram' ans } lc1 <- dendro.leaf('c1') lc2 <- dendro.leaf('c2') lc3 <- dendro.leaf('c3') nc1 <- dendro.merge(lc1, lc2, 0.1) nc2 <- dendro.merge(nc1, lc3, 0.2) plot(nc2) lr1 <- dendro.leaf('r1') lr2 <- dendro.leaf('r2') lr3 <- dendro.leaf('r3') nr1 <- dendro.merge(lr2, lr3, 0.1) nr2 <- dendro.merge(lr1, nr1, 0.3) plot(nr2) x <- matrix(seq(-1, 1, length.out=9), nrow=3) rownames(x) <- paste('r', 1:3, sep='') colnames(x) <- paste('c', 1:3, sep='') heatmap(x, Rowv=nr2, Colv=nc2, scale='none') order.dendrogram(nr2) unlist(nr2) ### begin output from run of code above ## > version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major2 minor1.1 year 2005 month06 day 20 language R > > dendro.leaf <- function(label) { + ans <- list() + attr(ans, 'members') <- 1 + attr(ans, 'height') <- 0 + attr(ans, 'leaf') <- T + attr(ans, 'midpoint') <- 0 + attr(ans, 'label') <- label + attr(ans, 'class') <- 'dendrogram' + ans + } > > dendro.merge <- function(d1, d2, height) { + ans <- list(d1, d2) + members <- attr(d1, 'members') + attr(d2, 'members') + attr(ans, 'members') <- members + attr(ans, 'height') <- height + attr(ans, 'leaf') <- F + attr(ans, 'midpoint') <- (members - 1)/2 + attr(ans, 'class') <- 'dendrogram' + ans + } > > lc1 <- dendro.leaf('c1') > lc2 <- dendro.leaf('c2') > lc3 <- dendro.leaf('c3') > nc1 <- dendro.merge(lc1, lc2, 0.1) > nc2 <- dendro.merge(nc1, lc3, 0.2) > plot(nc2) > > lr1 <- dendro.leaf('r1') > lr2 <- dendro.leaf('r2') > lr3 <- dendro.leaf('r3') > nr1 <- dendro.merge(lr2, lr3, 0.1) > nr2 <- dendro.merge(lr1, nr1, 0.3) > plot(nr2) > > x <- matrix(seq(-1, 1, length.out=9), nrow=3) > rownames(x) <- paste('r', 1:3, sep='') > colnames(x) <- paste('c', 1:3, sep='') > > heatmap(x, Rowv=nr2, Colv=nc2, scale='none') Error in heatmap(x, Rowv = nr2, Colv = nc2, scale = "none") : row dendrogram ordering gave index of wrong length > > order.dendrogram(nr2) NULL > > unlist(nr2) NULL > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem building dendrograms to use with heatmap()
Thanks Paul. It seems there's an undocumented requirement that in order to use a dendrogram as an argument to heatmap(), (a) the leaf nodes must be integers indicating the leaf's position in the left-to-right ordering of the leafs and/or (b) only the root of the dendrogram can be of class dendrogram. I discovered this by doing as you suggested below and with some help from Jeff Gentry. -Ben > -Original Message- > From: Paul Murrell [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 25, 2005 7:37 PM > To: Wittner, Ben > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] problem building dendrograms to use with heatmap() > > Hi > > > Wittner, Ben wrote: > > Hi, > > > > I'm trying to build dendrograms to pass to heatmap(). > > The dendrograms I build plot properly, but when I pass them to heatmap() > I get > > the error message "row dendrogram ordering gave index of wrong length" > (see > > output log below). > > > Looks like you're not building the dendrograms "properly". Compare > unclass(nr2) with unclass() of a dendrogram from > as.dendrogram(hclust()). You might need to look closely at > stats:::as.dendrogram.hclust to get it right. > > Paul > > > > I looked in the code of heatmap() and saw that the error was due to a > NULL > > return value from order.dendrogram(), which in turn got a NULL return > value from > > unlist(). But I have no idea why unlist() is returning NULL. > > > > I've included code below which reproduces the problem and below that the > output > > from a run of that code on my computer. > > > > Any help would be greatly appreciated. Thanks in advance. > > > > -Ben > > > > ### begin code > ### > > > > version > > > > dendro.leaf <- function(label) { > > ans <- list() > > attr(ans, 'members') <- 1 > > attr(ans, 'height') <- 0 > > attr(ans, 'leaf') <- T > > attr(ans, 'midpoint') <- 0 > > attr(ans, 'label') <- label > > attr(ans, 'class') <- 'dendrogram' > > ans > > } > > > > dendro.merge <- function(d1, d2, height) { > > ans <- list(d1, d2) > > members <- attr(d1, 'members') + attr(d2, 'members') > > attr(ans, 'members') <- members > > attr(ans, 'height') <- height > > attr(ans, 'leaf') <- F > > attr(ans, 'midpoint') <- (members - 1)/2 > > attr(ans, 'class') <- 'dendrogram' > > ans > > } > > > > lc1 <- dendro.leaf('c1') > > lc2 <- dendro.leaf('c2') > > lc3 <- dendro.leaf('c3') > > nc1 <- dendro.merge(lc1, lc2, 0.1) > > nc2 <- dendro.merge(nc1, lc3, 0.2) > > plot(nc2) > > > > lr1 <- dendro.leaf('r1') > > lr2 <- dendro.leaf('r2') > > lr3 <- dendro.leaf('r3') > > nr1 <- dendro.merge(lr2, lr3, 0.1) > > nr2 <- dendro.merge(lr1, nr1, 0.3) > > plot(nr2) > > > > x <- matrix(seq(-1, 1, length.out=9), nrow=3) > > rownames(x) <- paste('r', 1:3, sep='') > > colnames(x) <- paste('c', 1:3, sep='') > > > > heatmap(x, Rowv=nr2, Colv=nc2, scale='none') > > > > order.dendrogram(nr2) > > > > unlist(nr2) > > > > ### begin output from run of code above ## > > > > > >>version > > > > _ > > platform i686-pc-linux-gnu > > arch i686 > > os linux-gnu > > system i686, linux-gnu > > status > > major2 > > minor1.1 > > year 2005 > > month06 > > day 20 > > language R > > > >>dendro.leaf <- function(label) { > > > > + ans <- list() > > + attr(ans, 'members') <- 1 > > + attr(ans, 'height') <- 0 > > + attr(ans, 'leaf') <- T > > + attr(ans, 'midpoint') <- 0 > > + attr(ans, 'label') <- label > > + attr(ans, 'class') <- 'dendrogram' > > + ans > > + } > > > >>dendro.merge <- function(d1, d2, height) { > > > > + ans <- list(d1, d2) > > + members <- attr(d1, 'members') + attr(d2, 'members') > > + attr(ans, 'members')
[R] how to move x-axis labels down
Hi, In the code below, the labels I put on the x-axis are too high (they cross the axis). Can anyone tell me how to move them down? I've tried adj=, padj=, mar=, and various other things, but cannot move them down. Thanks. -Ben labs <- paste('sample', 1:10) plot(1:10, xaxt='n', xlab='') axis(1, at=1:10, labels=labs, padj=1, las=2)# las is a par() parameter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] how to move x-axis labels down
Bert, Your question below prompted me to run the same code to the postscript device and sure enough, the file created displays perfectly. So I guess the problem is specific to my system and I should not try to fix it by changing my code. My system is as follows: platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major2 minor0.1 year 2004 month11 day 15 language R Thanks. -Ben > -Original Message- > From: Berton Gunter [mailto:[EMAIL PROTECTED] > Sent: Monday, January 31, 2005 4:49 PM > To: Wittner, Ben > Subject: RE: [R] how to move x-axis labels down > > I have no such problem on Windows, R2.01. What system and version are you > on? > > -- Bert Gunter > Genentech Non-Clinical Statistics > South San Francisco, CA > > "The business of the statistician is to catalyze the scientific learning > process." - George E. P. Box > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Wittner, Ben > > Sent: Monday, January 31, 2005 1:33 PM > > To: '[EMAIL PROTECTED]' > > Subject: [R] how to move x-axis labels down > > > > Hi, > > > > In the code below, the labels I put on the x-axis are too > > high (they cross the > > axis). Can anyone tell me how to move them down? I've tried > > adj=, padj=, mar=, > > and various other things, but cannot move them down. > > > > Thanks. > > > > -Ben > > > > labs <- paste('sample', 1:10) > > plot(1:10, xaxt='n', xlab='') > > axis(1, at=1:10, labels=labs, padj=1, las=2)# las is a > > par() parameter > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] looking for 3D plotting with real-time rotation
I would like to plot points in 3D and then be able to rotate the plot in real time in order to understand the distribution of the points using the visual parallax that results from the rotation. The R-package scatterplot3d will plot in 3D, but I've not found a way to rotate the results in real time. (It also does not seem to get the projection from 3D to a viewing plane right.) The R-package rgl seems to support real-time 3D rendering using OpenGL, but it appears to be lower-level than I'm looking for (i.e., it provide graphics primitives, but not a plotting function that would take care of axis labels, etc.) Any help would be appreciated. Thanks. -Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] subset selection for logistic regression
R-packages leaps and subselect implement various methods of selecting best or good subsets of predictor variables for linear regression models, but they do not seem to be applicable to logistic regression models. Does anyone know of software for finding good subsets of predictor variables for linear regression models? Thanks. -Ben p.s., The leaps package references "Subset Selection in Regression" by Alan Miller. On page 2 of the 2nd edition of that text it states the following: "All of the models which will be considered in this monograph will be linear; that is they will be linear in the regression coefficients.Though most of the ideas and problems carry over to the fitting of nonlinear models and generalized linear models (particularly the fitting of logistic relationships), the complexity is greatly increased." __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] log-rank when var < 5 and power
I would like to determine whether there's a difference between survival data for two groups. I have been using the survival package and survdiff() with rho=0 and rho=1. Survdiff() with rho=0 is a non-continuity-corrected version of the log-rank test set forth in "Fundamentals of Biostatistics" by Bernard Rosner. On page 722 of the 5th edition, Rosner states, "This test should be used only if Var_LR >= 5." For my data with rho=0 or rho=1, survdiff()$var[1,1] is much less than 5. Can anyone suggest what to do in this case? Also, can anyone suggest a reference or software for doing power calculations regarding tests for difference between survival data for two groups. Thanks very much. -Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html