choishingwan / PRS-Tutorial

A tutorial on how to run basic polygenic risk score analysis
MIT License
68 stars 104 forks source link

'ind.col' and 'rows_along(A.col)' should have the same length. #31

Closed Sandyyy123 closed 2 years ago

Sandyyy123 commented 2 years ago

pred_auto <- NULL
for(chr in 1:22){
  obj.bigSNP <- snp_attach(paste0("courage_eur.qc01_chr",chr,".rds"))
  genotype <- obj.bigSNP$genotypes
  ind.test <- 1:nrow(genotype)
  chr.idx <- which(info_snp$chr == chr)
  ind.chr <- info_snp$`_NUM_ID_`[chr.idx]

  tmp <-
    big_prodMat(genotype,
                beta_auto,
                ind.row = ind.test,
                ind.col = ind.chr)
  pred_scaled <- apply(tmp, 2, sd)
  final_beta_auto <-
    rowMeans(tmp[chr.idx,
                 abs(pred_scaled -
                       median(pred_scaled)) <
                   3 * mad(pred_scaled)])
  tmp <-
    big_prodVec(genotype,
                final_beta_auto,
                ind.row = ind.test,
                ind.col = ind.chr)
  if(is.null(pred_auto)){
    pred_auto <- tmp
  }else{
    pred_auto <- pred_auto + tmp
  }
}
Sandyyy123 commented 2 years ago

Tried beta_auto[ind.chr],but that also didnt work.