opain / GenoPred

Genotype-based Prediction (GenoPred)
https://opain.github.io/GenoPred/
GNU General Public License v3.0
61 stars 20 forks source link

pt_clump Error when no SNPs are P < 1e-08 #60

Closed pazpark closed 2 years ago

pazpark commented 2 years ago

Hi, thank you for the great pipeline.

I've noticed that the prs_scoring_pt_clump rule fails when the GWAS study doesn't have any SNPs that are P < 1e-08.

Error in setnames(x, value) : Can't assign 12 names to a 11 column data.table Calls: names<- -> names<-.data.table -> setnames

The issues seems to be in polygenic_score_file_creator_plink2.R, in the following line names(scores)<-c('FID','IID',names(score)[-1:-2]), since the score will have 12 (default parameters), while scores will have 11 columns.

Actually, in seems the problem starts with the .sscore files. e.g. here's an example one. It seems like it truncates one column, but the R code assumes all P-value cutoff columns are present when reading them in sscore<-fread(paste0(opt$output,'.profiles.chr',i,'.sscore')) (maybe also the wrong column got cut in .sscore file, probably should have kept the SCORE_0_1_AVG)?

FID IID NMISS_ALLELE_CT NAMED_ALLELE_DOSAGE_SUM SCORE_0_1e-08_AVG SCORE_0_1e-06_AVG SCORE_0_1e-04_AVG SCORE_0_0.01_AVG SCORE_0_0.1_AVG SCORE_0_0.2_AVG SCORE_0_0.3_AVG SCORE_0_0.4_AVG SCORE_0_0.5_AVG

HG00096 HG00096 3988 2898 0 -2.34064e-05 5.89982e-05 0.000162722 0.000172173 0.000310967 0.000348686 0.000282273 0.000188143 HG00097 HG00097 3988 2903 0 -1.17032e-05 7.07014e-05 0.000144263 0.000250571 0.000404816 0.000436826 0.000386028 0.000278218

Thank you again!

opain commented 2 years ago

Hello,

Thank you for highlighting this error and apologies for not replying sooner. I am not receiving notifications on issues for some reason. Please email me (oliver.pain@kcl.ac.uk) if I do not reply within two weeks.

Indeed, the script failed if there were no variants surpassing a given pT. I have now edited the script to account for this.

# Retain pTs with at least one variant
opt$pTs<-opt$pTs[opt$pTs > min(GWAS$P)]

Let me know if you have any other issues.

Best wishes,

Ollie

pazpark commented 2 years ago

Thank you, works great now!