Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################
- # Fst #
- ######################################
- ## Fixation index for population differentiation (Fst)
- ## Fst will be computed with PLINK for each loci - Weir and Cockerham 1984
- # Clear workspace
- rm(list = ls())
- # Set working directory - you need to adapt this...
- setwd("d:/analysis/2020_GenomicsBootCamp_Demo/")
- #
- if (!require("tidyverse")) {
- install.packages("tidyverse", dependencies = TRUE)
- library(tidyverse)
- }
- if (!require("qqman")) {
- install.packages("qqman", dependencies = TRUE)
- library(qqman)
- }
- ## POSSIBLE IMPROVEMENT CHALLANGE (feedback on completion welcomed in comments, but NOT the solution!)
- ## Run specifics
- #breed1 <- "ANG"
- #breed2 <- "GUM"
- #
- ## Create "breed1.txt" and "breed2.txt" files based on R input
- # write............... > "breed1.txt"
- # write............... > "breed2.txt"
- #####################
- # Create subsets
- #####################
- # Breed 1
- system("plink --bfile ADAPTmap_genotypeTOP_20160222_full --cow --keep-fam breed1.txt --make-bed --out breed1")
- # Breed 2
- system("plink --bfile ADAPTmap_genotypeTOP_20160222_full --cow --keep-fam breed2.txt --make-bed --out breed2")
- #####################
- # Breed specific QC
- #####################
- # breed 1 - no MAF! careful with HWE!
- system("plink --bfile breed1 --cow --autosome --geno 0.1 --mind 0.1 --hwe 0.000001 --nonfounders --allow-no-sex --make-bed --out breed1_QC")
- # breed 2 - no MAF! careful with HWE!
- system("plink --bfile breed2 --cow --autosome --geno 0.1 --mind 0.1 --hwe 0.000001 --nonfounders --allow-no-sex --make-bed --out breed2_QC")
- #####################
- # Merge both breeds
- #####################
- system("plink --bfile breed1_QC --cow --autosome --bmerge breed2_QC --nonfounders --allow-no-sex --make-bed --out inputForFst")
- system(paste0("plink --bfile breed1_QC --cow --autosome --bmerge breed2_QC ",
- "--list-duplicate-vars ids-only suppress-first --nonfounders ",
- "--allow-no-sex --make-bed --out inputForFst"))
- system(paste0("plink --bfile inputForFst --cow --autosome ",
- "--exclude inputForFst.dupvar --nonfounders ",
- "--allow-no-sex --make-bed --out inputForFst_dupRemoved"))
- #####################
- # compute Fst
- #####################
- system("plink --cow --bfile inputForFst_dupRemoved --fst --family --out FstResults")
- #####################
- # load and visualize Fst results
- #####################
- data <- read.delim("FstResults.fst") %>%
- drop_na()
- manhattan(data, chr = "CHR", bp = "POS", p = "FST", logp = F)
Advertisement
Add Comment
Please, Sign In to add comment