choishingwan / PRS-Tutorial

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

'y.col' and 'ind.col' should have the same length. #32

Closed Sandyyy123 closed 2 years ago

Sandyyy123 commented 3 years ago
pred_inf <- NULL
for(chr in 1:22){
  obj.bigSNP <- snp_attach(paste0("courage_eur.qc01_chr",chr,".rds"))
  genotype <- obj.bigSNP$genotypes
  # calculate PRS for all samples
  ind.test <- 1:nrow(genotype)
  # Extract SNPs in this chromosome
  chr.idx <- which(info_snp$chr == chr)
  ind.chr <- info_snp$`_NUM_ID_`[chr.idx]
  tmp <- big_prodVec(genotype,
                     beta_inf,
                     ind.row = ind.test,
                     ind.col = ind.chr)
  if(is.null(pred_inf)){
    pred_inf <- tmp
  }else{
    pred_inf <- pred_inf + tmp
  }
}
Sandyyy123 commented 3 years ago

Tried beta_inf[ind.chr], which worked. But, I am not sure, if its the correct way as it didnt work for other models.

choishingwan commented 3 years ago

it might be helpful if you can combine the three issues and let me know what exactly goes wrong, e.g. the error messages etc.

Also, the tutorial on LDpred was on version 1.4.7, which might have changed quite a bit since I last updated the script. So if it is more of an LDpred2 issue, I'd suggest you to consult their authors instead