stephenslab / mashr

An R package for multivariate adaptive shrinkage.
https://stephenslab.github.io/mashr
Other
88 stars 19 forks source link

need better documentation for computing posterior for linear combinations of effects #130

Open stephens999 opened 2 months ago

stephens999 commented 2 months ago

We can compute the posterior summaries Ab for any matrix A, but this is not well documented.

Here was a user request (by email) we have a situation with stimulated and unstimulated cells. We've mapped eQTL for each cell type, and have run mash. What we're interested in is cases where the effect size differs in the stimulated and unstimulated condition. We've been identifying those based on the local false sign rates (e.g. requiring lfsr < 0.1 for discovery, and calling it a context-specific eQTL if the lfsr is > 0.2 or 0.5 in the other condition). It would be wonderful to have something more principled that doesn't rely on arbitrary cutoffs, such as a direct test of whether B1 = B2. Is it possible to extract those summaries from mash currently, or how can we go about doing so?

The answer is that we can do this using the matrix A in mash_compute_posterior_matrices Eg the following runs mash on simulted 5 conditions, but computes posterior for B1-B2

simdata = simple_sims(50,5,1)
data = mash_set_data(simdata$Bhat, simdata$Shat)
m = mash(data, cov_canonical(data))
mash_compute_posterior_matrices(m,data,A=rbind(c(1,-1,0,0,0)))

The role of A could be better documented in the function (eg add this example), and perhaps also in a vignette.

stephens999 commented 2 months ago

it seems the documentation for mash_compute_posterior_matrices and compute_posterior_matrices could be usefully combined?

gaow commented 2 months ago

A while ago, we looked into this with @yunqiyang0215 and generated a rough vignette mashr_posterior_demo.R.txt and a write-up on this application mashr_posterior.pdf. This may not be exactly what you need but might be similar?

What we hope to achieve is, that for a fine-mapped variant, we can get the posterior difference between contexts, and assess its significance in terms of lfsr. This can be summarized in a figure like the following:

image

I don't think all the technical details are correct now as you can see the lfsr is off. But if this is aligned with what you have in mind, we'd be happy to formalize this as a vignette to users.

TaurVil commented 1 month ago

Thank you, this was very useful! Can you clarify some things about the process and output for me?

gaow commented 1 month ago

@TaurVil I'm working with @yunqiyang0215 to polish up as a pull request to the mashr package for other co-authors to review ... please allow me to touch base with @yunqiyang0215 and get back on this. If it takes longer than I hope I'll get back on more details here.