[BioC] suggestions for plotPCA / pca.legend
Jenny Drnevich
drnevich at uiuc.edu
Tue Jan 16 23:03:17 CET 2007
Hi Jim,
I've been playing around with the versatility of plotPCA - thanks for
adding support for matrices! Say I have a 2x2 factorial design, and I want
to plot the 4 groups, but not using 4 separate symbols, each with its own
color. Instead, I want use 2 symbols to indicate the levels of the first
factor and 2 colors to indicate the levels of the second factor. I can do
this by using the arguments "pch" and "col" instead of "groups". However,
the legend doesn't come out correctly - instead of the 4 symbol/color
groups, there are only 2 - one symbol in one color and the other symbol in
the other color. I looked at pca.legend and I think I've come up with a
fix. At the very beginning, instead of:
pch <- sort(unique(pch))
col <- sort(unique(col))
this worked to give the correct legend:
gps <- sort(unique(paste(pch,col,sep="A")))
pch <- as.numeric(sapply(strsplit(gps,"A"),function(x) x[1]))
col <- as.numeric(sapply(strsplit(gps,"A"),function(x) x[2]))
It might also be good to include some sort of warning if
length(groupnames)!=length(gps); if you forget to put in groupnames in the
original call to plotPCA, it defaults to the names of the columns, and the
legend symbols get recycled so that the legend is incorrect.
Cheers,
Jenny
Jenny Drnevich, Ph.D.
Functional Genomics Bioinformatics Specialist
W.M. Keck Center for Comparative and Functional Genomics
Roy J. Carver Biotechnology Center
University of Illinois, Urbana-Champaign
330 ERML
1201 W. Gregory Dr.
Urbana, IL 61801
USA
ph: 217-244-7355
fax: 217-265-5066
e-mail: drnevich at uiuc.edu
More information about the Bioconductor
mailing list