Entering edit mode
Dick Beyer
★
1.4k
@dick-beyer-26
Last seen 10.4 years ago
Hi Jim,
I am using the pdmclass package and had a question. I'd like to be
able to plot the output from pdmClass when there are only 2 levels.
However, that generates an error.
Here is the example from the pdf documentation with a change to show
the problem:
library("pdmclass")
data("fibroEset")
y <- as.factor(pData(fibroEset)[, 2])
x <- t(exprs(fibroEset))
gn.class <- pdmClass(y ~ x, method = "pls")
plot(gn.class, pch = levels(y))
Now change the levels of y so there are only two:
y <- as.character(pData(fibroEset)[, 2])
> y
[1] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "g" "g" "g" "g" "g"
"g" "g" "g" "g" "g" "g" "g" "h" "h" "h" "h" "h" "h" "h" "h" "h" "h"
"h" "h" "h"
[37] "h" "h" "h" "h" "h" "h" "h" "h" "h" "h"
y[y=="g"] <- "b"
y <- as.factor(y)
y
[1] b b b b b b b b b b b b b b b b b b b b b b b h h h h h h h h h
h h h h h h h h h h h h h h
Levels: b h
gn.class <- pdmClass(y ~ x, method = "pls")
plot(gn.class, pch = levels(y))
Error in rbind(vars[, coord.pair], means[, coord.pair]) :
subscript out of bounds
predict(gn.class)
[1] b b b b b b b b b b b b b b b b b b b b b b b h h h h h h h h h
h h h h h h h h h h h h h h
Levels: b h
I've poked around the mda:::plot.fda function and I can see why I get
an error. But I was wondering, given predict still works with 2
levels, how to plot the predictions?
Thanks much,
Dick
**********************************************************************
*********
Richard P. Beyer, Ph.D. University of Washington
Tel.:(206) 616 7378 Env. & Occ. Health Sci. , Box 354695
Fax: (206) 685 4696 4225 Roosevelt Way NE, # 100
Seattle, WA 98105-6099
http://depts.washington.edu/ceeh/members_fc_bioinfo.html
http://staff.washington.edu/~dbeyer
***