forked from JoniColeman/gwas_scripts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PC_Plot_1KG_Greyed.R
executable file
·40 lines (32 loc) · 2.27 KB
/
PC_Plot_1KG_Greyed.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
###Author: JRIC
###Date: 2018-07-13
###Purpose: Plot user data projected on 1KG PCs, greying out 1KG individuals
##Load packages
library(ggplot2)
library(colorspace)
##Initialise command line arguments
args <- commandArgs(TRUE)
##Load data
root <- args[1]
PCAEVEC<-read.table(paste(root,".1kg.LD_pop_strat.pca.evec_RENAMED",sep=""), head=T)
##Rename columns
colnames(PCAEVEC) <- c("ID","PC1","PC2","PC3","PC4","PC5","PC6","PC7","PC8","PC9","PC10","Pop")
##Define colour palette
ThousandGenomesPalette<-heat_hcl(length(unique(PCAEVEC$Pop)), h = c(300, 75), c. = c(35, 95), l = c(15, 90), power = c(0.8, 1.2), fixup = TRUE, gamma = NULL, alpha = 1)
names(ThousandGenomesPalette)<-unique(PCAEVEC$Pop)
ThousandGenomesPops<-c("LWK","MXL","PUR","TSI","YRI","ASW","CEU","CHB","CHS","CLM","FIN","GBR","IBS","JPT")
ThousandGenomesPalette[names(ThousandGenomesPalette) %in% ThousandGenomesPops] <- "#CCCCCC"
ThousandGenomesPalette[!names(ThousandGenomesPalette) %in% ThousandGenomesPops] <- heat_hcl(length(unique(PCAEVEC$Pop)) - 14, h = c(300, 75), c. = c(35, 95), l = c(15, 90), power = c(0.8, 1.2), fixup = TRUE, gamma = NULL, alpha = 1)
##Print pairwise comparisons of PC1-5 to pdf
pdf(paste(root,"1kg.LD_pop_strat_PCA.pdf",sep=""))
with(PCAEVEC, qplot(PC1,PC2,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC1,PC3,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC1,PC4,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC1,PC5,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC2,PC3,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC2,PC4,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC2,PC5,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC3,PC4,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC3,PC5,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
with(PCAEVEC, qplot(PC4,PC5,colour=Pop) + scale_colour_manual(values = ThousandGenomesPalette))
dev.off()