I am trying to save different PCA plots together in one PDF. I have tested the myPCs matrix and also plotted a few plots via the command line and it works from there.
*** I would like to have all the nine plots below in a single PDF file (9pages)
PCAPlots <-function(Object){
beta<-getBeta(Object)
beta <-t(beta)
myPCA=prcomp(beta,scale.=TRUE,center=TRUE)
myPCs=data.frame(myPCA$x)
pdf("PCA.pdf")
qplot(PC2,PC1,data=myPCs,colour=pheno$sex)
qplot(PC3,PC2,data=myPCs,colour=pheno$sex)
qplot(PC4,PC3,data=myPCs,colour=pheno$sex)
qplot(PC2,PC1,data=myPCs,colour=pheno$age)
qplot(PC3,PC2,data=myPCs,colour=pheno$age)
qplot(PC4,PC3,data=myPCs,colour=pheno$age)
qplot(PC2,PC1,data=myPCs,colour=pheno$treatment)
qplot(PC3,PC2,data=myPCs,colour=pheno$treatment)
qplot(PC4,PC3,data=myPCs,colour=pheno$treatment)
dev.off()
}
myPlots <-PCAPlots(Object)