chr1swallace / coloc

Repo for the R package coloc
144 stars 44 forks source link

Sensitivity function returning non-numeric matrix extent when running with non-default p1,p2, and p12 #53

Open isaacg322 opened 3 years ago

isaacg322 commented 3 years ago

Dear Chris and collaborators,

I am trying to run sensitivity analysis over my coloc object. I obtained this using priors determined based on the number of SNPs in my testing region (5108), as p1=1/nsnps; p2=p1; p12= p1/10. With this, I set p1=1.957713e-04, p2=1.957713e-04, and p12=1.957713e-05. However, when I run sensitivity using these values I get the next error:

"Error in matrix(f(p12), nrow = nrow(pr1), ncol = ncol(pr1), byrow = TRUE) : non-numeric matrix extent"

This only happens when I set priors different to the coloc defaults.

Do you think this could be a bug or is it that I'm doing something wrong? Thanks in advance for your help with this issue, and thanks for such a useful package!

Best,

Isaac

chr1swallace commented 3 years ago

Dear Isaac,

I can take a look at this, but first, these priors don't make much sense. COuld you try finding a set of priors that meet the requirements here https://chr1swallace.shinyapps.io/coloc-priors/ and let me know if the problem persists?

THanks, C

On Fri, 2021-04-30 at 08:33 -0700, Isaac García wrote:

Dear Chris and collaborators,

I am trying to run sensitivity analysis over my coloc object. I obtained this using priors determined based on the number of SNPs in my testing region (5108), as p1=1/nsnps; p2=p1; p12= p1/10. With this, I set p1=1.957713e-04, p2=1.957713e-04, and p12=1.957713e-05. However, when I run sensitivity using these values I get the next error:

"Error in matrix(f(p12), nrow = nrow(pr1), ncol = ncol(pr1), byrow = TRUE) : non-numeric matrix extent"

This only happens when I set priors different to the coloc defaults.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

isaacg322 commented 3 years ago

Dear Chris, thank you for your prompt answer!

I'm a bit confused, the rule presented in the prior setting tool says that: 0 < p2 < 1/nsnps 0 < p1 < 1/nsnps

so I am setting p1=0.00019; p2=p1, which for 5108 SNPs would be: 0.00019 < 1/5108 [1] TRUE

and then I set p12 according to the rule: p1 * p2 < p12 < min(p1,p2)

for which I set p1/10; which would yield:

0.00019*0.00019 < 1.9e-05 [1] TRUE

and

1.9e-05 < 0.00019 [1] TRUE

But the tool returns an error too.

chr1swallace commented 3 years ago

The problem is that you are saying the probability exactly 1 SNP is causal for trait 1 is 1. And the probability exactly one SNP is causal for both traits is 0.1.

These are mutually exclusive events so the sum of their probabilities can't exceed 1.

You might find it easier to think about the priors in their marginal and conditional forms. See the documentation tab on the web link for more details.

http://chr1swallace.github.io

On 30 Apr 2021, 17:54, at 17:54, "Isaac García" @.***> wrote:

Dear Chris, thank you for your prompt answer!

I'm a bit confused, the rule presented in the prior setting tool says that: 0 < p2 < 1/nsnps 0 < p1 < 1/nsnps

so I am setting p1=0.00019; p2=p1, which for 5108 SNPs would be: 0.00019 < 1/5108 [1] TRUE

and then I set p12 according to the rule: p1 * p2 < p12 < min(p1,p2)

for which I set p1/10; which would yield:

0.00019*0.00019 < 1.9e-05 [1] TRUE

and

1.9e-05 < 0.00019 [1] TRUE

But the tool returns an error too.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/chr1swallace/coloc/issues/53#issuecomment-830227512

isaacg322 commented 3 years ago

Dear Chris, thank you for your patience with this issue.

I believe that I now understand a bit better how to set priors for different SNP set sizes. This time, for a set of 5201 SNPs, I determined p1=7.83e-05, p2=p1, and p12=1.95e-07. I double checked that the sum of P(H_i) was not bigger than 1 using the prior explorer app in here: https://chr1swallace.shinyapps.io/coloc-priors/. However, when running the sensitivity analysis I still get the error:

'Error in matrix(f(p12), nrow = nrow(pr1), ncol = ncol(pr1), byrow = TRUE) : non-numeric matrix extent'

Apologies should I am misinterpreting the prior values again.

Best,

Isaac

chr1swallace commented 3 years ago

I don't know if this is the cause but there is generally an assumption that p12> p1. It's not a hard requirement I don't think, but I might have coded something assuming it would hold. Of course I can't promise there's not a bug in my code, but can you say why you are looking at p12<p1?

http://chr1swallace.github.io

On 4 May 2021, 18:29, at 18:29, "Isaac García" @.***> wrote:

Dear Chris, thank you for your patience with this issue.

I believe that I now understand a bit better how to set priors for different SNP set sizes. This time, for a set of 5201 SNPs, I determined p1=7.83e-05, p2=p1, and p12=1.95e-07. I double checked that the sum of P(H_i) was not bigger than 1 using the prior explorer app in here: https://chr1swallace.shinyapps.io/coloc-priors/. However, when running the sensitivity analysis I still get the error:

'Error in matrix(f(p12), nrow = nrow(pr1), ncol = ncol(pr1), byrow = TRUE) : non-numeric matrix extent'

Apologies should I am misinterpreting the prior values again.

Best,

Isaac

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/chr1swallace/coloc/issues/53#issuecomment-832114614

isaacg322 commented 3 years ago

Sorry, I think I'm confused again . As coloc.abf() defaults to p1=1e-4 and p12=1e-5, I was assuming p12 is always smaller than p1.

chr1swallace commented 3 years ago

Sorry, yes, my mistake (long day!)

I'll take a look this week

http://chr1swallace.github.io

On 4 May 2021, 19:00, at 19:00, "Isaac García" @.***> wrote:

Sorry, I think I'm confused again . As coloc.abf() defaults to p1=1e-4 and p12=1e-5, I was assuming p12 is always smaller than p1.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/chr1swallace/coloc/issues/53#issuecomment-832133711

prplmnky commented 6 months ago

Hi Chris,

Is there any update/resolution to this issue? I am in a similar situation and the error continues to happen, it would be useful to see the sensitivity for my analysis

chr1swallace commented 5 months ago

I'm afraid I can't reproduce. Could you please give me an example dataset where this happens?

-- https://chr1swallace.github.iohttps://chr1swallace.github.io/


From: prplmnky @.> Sent: Friday, April 5, 2024 11:37 AM To: chr1swallace/coloc @.> Cc: Chris Wallace @.>; Comment @.> Subject: Re: [chr1swallace/coloc] Sensitivity function returning non-numeric matrix extent when running with non-default p1,p2, and p12 (#53)

Hi Chris,

Is there any update/resolution to this issue? I am in a similar situation and the error continues to happen, it would be useful to see the sensitivity for my analysis

— Reply to this email directly, view it on GitHubhttps://github.com/chr1swallace/coloc/issues/53#issuecomment-2039462509, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQWR2AKXQ3XPCV55JQMU6TY3Z5HNAVCNFSM434PU2ZKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBTHE2DMMRVGA4Q. You are receiving this because you commented.Message ID: @.***>

prplmnky commented 5 months ago

The dataset for trait 1 (PQTL data) contains around 7000 SNPs and trait 2 (GWAS summary) around 10,000 SNPs for a region defined as +/-500,000kb the index SNP in my PQTL data. Based on the results from afb.coloc the nspns is 6313. Is there any other information that would be helpful?