Advertisement
GenomicsBootCamp

snplist2ChrPosition_TASSEL.r

Mar 21st, 2022
905
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. # Clear and set up workspace
  3. rm(list = ls())
  4. library(tidyverse)
  5.  
  6. # set your working directory as appropriate for your computer
  7. #setwd("XXXXXXXXXXXXXXXXXXXXXX")
  8.  
  9. # ###
  10. # # generate an example list of SNPs for the demonstration
  11. # ###
  12. # # read in the tutorial data
  13. # fullMap <- read_tsv("mdp_genotype.plk.map", col_names = F)
  14. # # generate list of SNPs
  15. # nExample <- 50
  16. # fullMap[sample(1:nrow(fullMap), nExample),2] %>%
  17. #   write_tsv("exampleSnpList.txt", col_names = F)
  18.  
  19. ###
  20. # prepare a bed file from a SNP name list
  21. ###
  22. # read in the file with SNP names
  23. snpList <- read_table("exampleSnpList.txt", col_names = F) %>%
  24.   rename(snpName = X1)
  25. # read in the map file with SNP positions (full info)
  26. fullMap <- read_tsv("mdp_genotype.plk.map", col_names = F) %>%
  27.   rename(chromosome = X1, snpName = X2, morgan = X3, position = X4)
  28.  
  29. # write out a chromosome + position file to be loaded in TASSEL
  30. tmp <- inner_join(snpList, fullMap) %>%
  31.   select(chromosome, position) %>%
  32.   write_tsv(., "SnpName2ChrPosition_TASSEL.txt", col_names = F)
  33.  
Advertisement
RAW Paste Data Copied
Advertisement