generated from stajichlab/PopGenomics_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pophelper.R
50 lines (40 loc) · 1.42 KB
/
pophelper.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
41
42
43
44
45
46
47
48
49
50
#pophelper script
#Jan. 13th 2024
#jnadams
# install dependencies
#install.packages(c("ggplot2","gridExtra","label.switching","tidyr","remotes"),repos="https://cloud.r-project.org")
library(pacman)
p_load(ggplot2, gridExtra, label.switching, tidyr,
remotes, reshape2, dplyr, stringr, cowplot)
# install pophelper package from GitHub; one time install
remotes::install_github('royfrancis/pophelper')
# load library for use
library(pophelper)
# check version
packageDescription("pophelper", fields="Version")
#read in files
# use ADMIXTURE files (do not use this command to read local files)
afiles<- list.files(path="/bigdata/stajichlab/shared/projects/Population_Genomics/Asocialis_CCGP/vcf/admixture_runs", full.names=T)
alist <- readQ(files=afiles, indlabfromfile=T)
head(alist[[1]])
## tabulateQ
tr1 <- tabulateQ(qlist=alist)
head(tabulateQ(alist))
## summarizeQ
sr1 <- summariseQ(tr1, writetable=T, exportpath=getwd())
head(summariseQ(tabulateQ(alist)))
# choose plots to make
names(alist)
# pull group assignments for coloring pca
## merge K = 2
k2<-mergeQ(alignK(alist[c(10)]))
## merge K = 3
k3<-mergeQ(alignK(alist[c(12)]))
## merge K = 4
k4<-mergeQ(alignK(alist[c(14)]))
## merge K = 5
k5<-mergeQ(alignK(alist[c(16)]))
# align clusters b/t K
pop1 <- plotQ(alignK(c(k2, k3, k4, k5)),imgoutput="join", showindlab=T, returnplot=T,
exportplot=F,basesize=11, sortind="all", sharedindlab = F)
grid.arrange(pop1$plot[[1]])