Entering edit mode
Jenny Drnevich
★
2.2k
@jenny-drnevich-382
Last seen 10.2 years ago
Hi Jim,
I was trying to modify 'plotPCA' so it could take a matrix instead of
an
exprSet object, but in doing so somehow R can't find the function
'pca.legend', even though it pulls up the documentation for it when I
query
'?pca.legend". I didn't even touch the code that had to do with
'pca.legend'! Any ideas why and/or what I can do to get the legend?
Code
and sessionInfo() below.
Thanks,
Jenny
>plotPCA(rma.data)
# no problem with this - the legend was fine
> source("C:/Statistics/JDplotPCA.R")
> JDplotPCA(exprs(rma.data))
Error in JDplotPCA(exprs(rma.data)) : could not find function
"pca.legend"
> JDplotPCA
function (eset, groups = NULL, groupnames = NULL, addtext = NULL,
x.coord = NULL, y.coord = NULL, screeplot = FALSE, squarepca =
FALSE,
pch = NULL, col = NULL, ...)
{
require(affycoretools)
if (is.null(groupnames))
groupnames <- colnames(eset)
if (is.factor(groupnames))
groupnames <- as.character(groupnames)
pca <- prcomp(t(eset))
if (screeplot) {
plot(pca, main = "Screeplot")
}
else {
if (squarepca) {
ylim <- max(abs(range(pca$x[, 1])))
ylim <- c(-ylim, ylim)
}
else ylim <- NULL
if (!is.null(groups)) {
if (is.null(pch))
pch <- groups
if (is.null(col))
col <- groups
plot(pca$x[, 1:2], pch = pch, col = col, ylab = "PC2",
xlab = "PC1", main = "Principal Components Plot",
ylim = ylim, ...)
}
else {
if (is.null(pch))
pch <- 0:length(colnames(eset))
if (is.null(col))
col <- 1:length(colnames(eset))
plot(pca$x[, 1:2], pch = pch, col = col, ylab = "PC2",
xlab = "PC1", main = "Principal Components Plot",
ylim = ylim, ...)
}
if (is.null(addtext)) {
pca.legend(pca, groupnames, pch, col, x.coord = x.coord,
y.coord = y.coord, ...)
}
else {
smidge <- pca.legend(pca, groupnames, pch, col, x.coord =
x.coord,
y.coord = y.coord, saveup = TRUE, ...)
text(pca$x[, 1], pca$x[, 2] + smidge, label = addtext,
cex = 0.7)
}
}
}
> sessionInfo()
R version 2.4.0 (2006-10-03)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "splines" "tools" "methods" "stats" "graphics"
"grDevices"
[7] "utils" "datasets" "base"
other attached packages:
affyQCReport simpleaffy made4 scatterplot3d ade4
"1.12.0" "2.8.0" "1.8.0" "0.3-24" "1.4-2"
affyPLM gcrma matchprobes affydata affycoretools
"1.10.0" "2.6.0" "1.6.0" "1.10.0" "1.6.0"
biomaRt RCurl XML GOstats Category
"1.8.0" "0.7-0" "1.2-0" "2.0.3" "2.0.3"
genefilter survival KEGG RBGL annotate
"1.12.0" "2.29" "1.14.1" "1.10.0" "1.12.0"
GO graph limma affy affyio
"1.14.1" "1.12.0" "2.9.1" "1.12.1" "1.2.0"
Biobase RWinEdt
"1.12.2" "1.7-5"
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