xinhe-lab / ctwas

package for the causal TWAS project
https://xinhe-lab.github.io/ctwas/
MIT License
32 stars 12 forks source link

Question about SNP-gene correlation matrix #15

Closed Xinyu-Sun closed 6 months ago

Xinyu-Sun commented 7 months ago

Thanks for developing this useful tools! In ctwas_process_regions.R at line 270, the code include R_snp[x,x] in the denominator. This term is not present in the equation from the paper's Supplementary Notes. Could you explain what is this term used for?

            R_snp_gene[,i] <- sapply(1:nrow(R_snp),
                                     function(x){crossprod(wgt,R_snp[ld.idx,x])/sqrt(crossprod(wgt,R.s)%*%wgt*R_snp[x,x])})

,Xinyu

simingz commented 6 months ago

Hi Xinyu, thanks for using our software. In the supplement, we assume R is the correlation matrix, so R_snp[x,x]= 1. That's why this term didn't show up in the equation. I think at the time when we implemented this part, we didn't require that (can be covariance or correlation matrix). As now we are requiring R should be the correlation matrix (LD matrix), this term shouldn't matter.

Xinyu-Sun commented 6 months ago

Got it. Thank you!