-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPCAPlot.R
More file actions
19 lines (16 loc) · 798 Bytes
/
PCAPlot.R
File metadata and controls
19 lines (16 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
dataFile<-commandArgs()[6]
raceFile<-commandArgs()[7]
resultFile<-paste0(dataFile,".jpeg")
dataConent<- read.table(dataFile, header=F,skip=11, fill = TRUE)
raceConent<- read.delim(raceFile, header=F,as.is=T)
if (NROW(raceConent) != NROW(dataConent)) {
stop(paste0("The samples in race file (",NROW(raceConent),") is not equal to samples in PCA file (",NROW(dataConent),")\n"))
}
raceTypes<-(unique(raceConent[,3]))
col<-rainbow(length(raceTypes))
colPoints<-col[match(raceConent[,3],raceTypes)]
jpeg(resultFile,width=5, height=5,units="in",res=300)
plot(dataConent[,1],dataConent[,2],col=colPoints,las=1,xlab="PC1",ylab="PC2",cex=0.8)
legend("topright",legend=raceTypes,pch=16,col=col,bty="n")
result<-dev.off()
cat(paste(resultFile," was successfully generated.\n",sep=""))