1.xlsx格式转化为plink格式
#下载tidyverse包
install.packages("tidyverse")
#调用程序包
library(tidyverse)
library(readxl)
#打开以All_sample_snp2.0命名的xlsx文件
MySheet <- read_excel("All_sample_snp2.0.xlsx")
#map数据整理
map = MySheet %>% select(2,3,x = 6,p = 6)
head(map)
#ped数据整理
ped = MySheet %>% select(-c(1:4)) %>% t() %>% as.data.frame() %>%
mutate(ID = rownames(.)) %>%
mutate(x3=0,x4=0,x5=0,x6=0) %>%
select(FID=ID,IID=ID,x3,x4,x5,x6,everything())
#导出数据
library(data.table)
fwrite(map, "file.map",col.names = F,quote = F,sep = " ")
fwrite(ped, "file.ped",col.names = F,quote = F,sep = " ",na = "##")
#打开plink测试
plink --file file --missing

test.png
测试成功!
参考:
https://blog.csdn.net/yijiaobani/article/details/125655533
https://blog.csdn.net/yijiaobani/article/details/124181848
https://dengfei2013.gitee.io/plink-cookbook/plink%E8%BD%AF%E4%BB%B6%E6%A0%BC%E5%BC%8F%E8%BD%AC%E5%8C%96.html