1. 程式人生 > 其它 >R語言統計 plink格式資料樣本缺失率

R語言統計 plink格式資料樣本缺失率

1、R指令碼

dir()
dat <- read.table("outcome.ped")
dat
id <- dat[,2]
dat <- dat[, -(1:6)]

result <- data.frame()

for (i in 1:nrow(dat)) {
  count = 0
  for (j in 1:ncol(dat)) {
    if (dat[i,j] == 0) {
      count = count + 1
    }
  }
  temp <- c(count/2,ncol(dat)/2, count/ncol(dat))
  result 
<- rbind(result, temp) } result <- cbind(id, result) colnames(result)[2:4] <- c("misssite","totalsite","rate") result

2、plink驗證

[root@centos79 test]# ls
outcome.map  outcome.ped  result.txt  test.sh
[root@centos79 test]# plink --file outcome --missing --out verify > /dev/null; rm *.log *
.nosex [root@centos79 test]# ls outcome.map outcome.ped result.txt test.sh verify.imiss verify.lmiss [root@centos79 test]# cat verify.imiss FID IID MISS_PHENO N_MISS N_GENO F_MISS DOR 1 Y 4 8 0.5 DOR 2 Y 4 8 0.5 DOR 3 Y 3
8 0.375 DOR 4 Y 2 8 0.25 DOR 5 Y 1 8 0.125 DOR 6 Y 1 8 0.125