reformatting to accommodate biplot

I am currently using a script that lets me input a fasta file, add a population trait, and plot a PCA.
I now need to modify this script so that I can input location and species information and plot a PCA with both of those factors. I would like my location to be colorful, and my species to be different shapes.
Here is the script I have so far (I put in individual population descriptors for all of my sequences)

library("ape")
library("adegenet")
setwd("~/Documents/R")
MyDNA <- read.FASTA("NoKIRGMB.fas")
MyDNA

class(MyDNA)
MyDNA <- as.matrix(MyDNA)

obj <- DNAbin2genind(MyDNA, polyThres=0.01)

sum(is.na(obj$tab))
X <- scaleGen(obj, NA.method="mean")

###Add Pops
pop(obj) <- c(INPUT)

col <- c("M" = "deepskyblue2" , "B" = "yellow1" , "O" = "springgreen")

pca1 <- dudi.pca(X,cent=FALSE,scale=FALSE,scannf=FALSE,nf=3)
barplot(pca1$eig[1:50],main="PCA eigenvalues", col=heat.colors(50))

pca1

s.class(pca1$li, pop(obj),xax=1,yax=2 , col=transp(col,.9), axesell=FALSE,
cstar=0, cpoint=1.3, grid=FALSE)
title("PCA\naxes 1-2")

s.class(pca1$li, pop(obj),xax=1,yax=3, col=transp(col,.9), axesell=FALSE,
cstar=0, cpoint=1.3, grid=FALSE)
title("PCA\naxes 1-3")

Hi,

I know fasta files can be large and you can't upload data on here, but could you find an online available file that could do the trick so we can recreate the issue.

Also, you have to show us where in the code the species and location comes in and what exactly these variable are (can't see them anywhere). Only when we can reproduce your issue can we help to fix it.

Read this post for help:

Kind regards

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.