# Here is some code for using colors or symbols to represent populations in # polysat. Ten populations are assumed. It is also assumed that you have # done a Principal Coordinates Analysis and named it "pca" as in the # "Getting Started" section of the tutorial manual. ## Using colors # generate ten colors; there are other ways to do this, or you can make a character vector containing # the color names that you want. (Google "R colors") popcolors <- rainbow(10) # take a look at the colors generated plot(1:10, 1:10, col=popcolors) # for a plot containing all individuals plot(pca[,1], pca[,2], col=popcolors[PopInfo(mydata)]) # for a plot containing a subset of individuals, called "subset" here pca2 <- cmdscale(testmat[subset,subset]) plot(pca2[,1], pca2[,2], col=popcolors[PopInfo(mydata)[subset]]) ## Using symbols # Choose the first ten symbols in R; there are others. popsym <- 0:9 # take a look at the symbols plot(1:10, 1:10, pch=popsym) # use the symbols in your plot plot(pca[,1], pca[,2], pch=popsym[PopInfo(mydata)]) ## Using a combination of colors and symbols popsym <- c(0,0,1,1,2,2,5,5,6,6) popcol <- rep(c("red","blue"), times=5) plot(1:10, 1:10, pch=popsym, col=popcol) plot(pca[,1], pca[,2], pch=popsym[PopInfo(mydata)], col=popcol[PopInfo(mydata)])