zoukankan      html  css  js  c++  java
  • R语言生成plink测试数据

    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

  • 相关阅读:
    老白关于rac性能调优的建议
    缓存融合(Cache Fusion)介绍
    交易所行情报盘程序配置
    SQLServer 断开指定会话
    缓存融合技术介绍
    机器学习参考书籍
    寒霜浸铁甲,英雄见白头
    希腊字母表
    windows命令
    大空头
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15496596.html
Copyright © 2011-2022 走看看