1、
result1 <- data.frame(1:100) for (i in 1:10) { temp1 <- sample(c("A", "C", "G", "T"), 2, replace = F) temp2 <- sample(c(temp1[1], temp1[2]), 100, replace = T) result1 <- cbind(result1, temp2) } result1 <- result1[,-1] ped <- data.frame() for (i in 1:(nrow(result1)/2)) { vec <- vector() for (j in 1:ncol(result1)) { vec <- c(vec, result1[2 * i -1, j], result1[2 * i, j]) } ped <- rbind(ped, vec) } colnames(ped) <- paste0("v", 1:ncol(ped)) dim(ped) fid <- rep("breed1", nrow(ped)) iid <- 1:nrow(ped) fa <- rep("0", nrow(ped)) ma <- rep("0", nrow(ped)) sex <- rep("0", nrow(ped)) phe <- rep("-9", nrow(ped)) ped <- cbind(fid, iid, fa, ma, sex, phe, ped) chr <- rep(1, (ncol(ped) - 6)/2) snp <- paste0("snp", 1:length(chr)) dis <- rep(0, length(chr)) pos <- 1:length(chr) map <- data.frame(chr, snp, dis, pos) ped map write.table(ped, "test.ped", row.names = F, col.names = F, quote = F, sep = "\t") write.table(map, "test.map", row.names = F, col.names = F, quote = F, sep = "\t")
2、plink验证
root@PC1:/home/test# ls test.map test.ped root@PC1:/home/test# plink --file test --recode --out 111