forked from rbcan/MARsym_paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig2.Rmd
59 lines (46 loc) · 1.4 KB
/
Fig2.Rmd
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
51
52
53
54
55
56
57
58
59
---
title: "Plots_for_Figure5"
author: "Rebecca_Ansorge"
date: "July 14, 2019"
output: html_document
editor_options:
chunk_output_type: console
---
```{r load libs}
### load libraries
library(ggplot2)
library(data.table)
library(ggfortify)
```
```{r Pi corePCA}
# Fig. 2a PCA plot
# all sites within and between individual pi
PiCo <- read.csv("/PATH/Pi.Core_all.id95.100x.list", sep="\t")
t_PiCo <- t(PiCo)
write.table(t_PiCo, file = "t_PiCo", sep = "\t")
system("sed -i '1d' t_PiCo")
reload_PiCo <- read.csv("t_PiCo", sep="\t")
# consider only column 2-1184
reload_PiCo.col <- reload_PiCo[,2:1185]
# transform to PCA
PiCo.pca <- prcomp(reload_PiCo.col, center = TRUE)
# plot the PCA, color by site
x<-autoplot(PiCo.pca, data = reload_PiCo, colour = 'site', size = 2.5)
# show plot
x
# get summary of PCA
summary(PiCo.pca)
```
```{r}
# FST Fig. 2b
mFstpoints<- read.csv('/PATH/mFst.list', sep="\t")
mFstpointsBaz2<- read.csv('/PATH/mFstBaz_diffSpots.list', sep="\t")
avmFst_line<- read.csv('/PATH/mFst_avline.list', sep="\t")
mFstplot <-ggplot(mFstpoints, aes(ind, mFst)) +
geom_point(aes(colour = site), size = 2) +
ylim(0,0.3) +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
geom_point(data=mFstpointsBaz2, aes(colour = site), shape=5, size = 2) +
geom_line(data=avmFst_line, aes(colour = site), size=0.3)
mFstplot
```