GenomicsBootCamp

Update SNP map file with PLINK

Apr 9th, 2021
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.78 KB | None | 0 0
  1. ##########################
  2. #update SNP chip map data
  3. ##########################
  4.  
  5. # Clear workspace
  6. rm(list = ls())
  7. # Set working directory
  8. setwd("d:/analysis/2020_GenomicsBootCamp_Demo/")
  9. #load packages
  10. library(tidyverse)
  11.  
  12.  
  13. # #prepare ped+map
  14. # system("plink --bfile ADAPTmap_genotypeTOP_20160222_full --chr-set 29 --keep-fam breed1.txt --recode --out testData_full")
  15. #
  16. # # prepare the "faulty" map file
  17. # read_delim("testData_full.map",delim = "\t", col_names = F) %>%
  18. #   mutate(X1=1, X4=row_number()) %>%
  19. #   write_delim("testData_faulty.map", quote=F, col_names = F)
  20. #
  21. # # the ped file testData_faulty.ped for this example is just a renamed copy of testData_full.ped
  22.  
  23. ##################################################################
  24. # MAP file update - method 1 - from pre-prepared conversion file
  25. ##################################################################
  26.  
  27. # prepare file for update from a map file
  28. read_delim("testData_full.map",delim = "\t", col_names = F) %>%
  29.   dplyr::select(X2, X1) %>%
  30.   write_delim("chrUpdate.txt", quote=F, col_names = F)
  31.  
  32. # run PLINK update
  33. system("plink --file testData_faulty --chr-set 29 --update-chr chrUpdate.txt --make-bed --out testData_chrUpdated")
  34.  
  35. ##################################################################
  36. # MAP file update - method 2 - update from an existing map file
  37. ##################################################################
  38.  
  39. # run PLINK update - chromosomes
  40. system("plink --file testData_faulty --chr-set 29 --update-chr testData_full.map 1 2 --make-bed --out testData_chrUpdatedV2")
  41.  
  42.  
  43. # run PLINK update - chromosomes + positions together
  44. system("plink --file testData_faulty --chr-set 29 --update-chr testData_full.map 1 2 --update-map testData_full.map 4 2 --make-bed --out testData_chrUpdatedV3")
  45.  
Advertisement
Add Comment
Please, Sign In to add comment