Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Transform PLINK to 23andMe-format
- # Clear workspace
- rm(list = ls())
- # Set working directory
- setwd("d:/analysis/2020_GenomicsBootCamp_Demo/")
- #load packages
- library(tidyverse)
- # prepare data
- system("plink --file hereford --cow --chr 1 --make-bed --out humanDataForSure")
- ###
- # single individual from PLINK to 23andMe-format
- ###
- # select individual + change format
- system("plink --bfile humanDataForSure --keep selectedIndividual.txt --recode 23 --out recoded_23andMe")
- ###
- # all individuals from PLINK to 23andMe-format
- ###
- individuals <- read_delim("humanDataForSure.fam", delim = " ", col_names = F)
- # cycle through each individual in the data file
- for (i in 1:nrow(individuals)) {
- #write one individual at the time to a file
- currentInd <- individuals %>%
- slice(i) %>%
- write_delim("selectedIndividual.txt", col_names = F) %>%
- select(X2)
- # select this individual only and write out into a specific file
- system(str_c("plink --bfile humanDataForSure --keep selectedIndividual.txt --recode 23 ",
- "--out recoded_23andMe_",currentInd))
- }
Advertisement
Add Comment
Please, Sign In to add comment