Compute the proportion of (significant) signals shared by magnitude in each pair of conditions

get_pairwise_sharing_from_samples(
  m,
  factor = 0.5,
  lfsr_thresh = 0.05,
  FUN = identity
)

Arguments

m

the mash fit with samples from posteriors

factor

a number in [0,1] the factor within which effects are considered to be shared

lfsr_thresh

the lfsr threshold for including an effect in the assessment

FUN

a function to be applied to the estimated effect sizes before assessing sharing. The most obvious choice beside the default 'FUN=identity' would be 'FUN=abs' if you want to ignore the sign of the effects when assesing sharing.

Details

For each pair of conditions, compute the fraction of effects that are within a factor `factor` of one another. The results are returned as an R by R matrix.

Examples

simdata = simple_sims(50,5,1)
data = mash_set_data(simdata$Bhat, simdata$Shat)
m = mash(data, cov_canonical(data), posterior_samples=5, algorithm='R')
#>  - Computing 200 x 141 likelihood matrix.
#>  - Likelihood calculations took 0.03 seconds.
#>  - Fitting model with 141 mixture components.
#>  - Model fitting took 0.16 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.11 seconds.
get_pairwise_sharing_from_samples(m) # sharing by magnitude (same sign)
#>             condition_1 condition_2 condition_3 condition_4 condition_5
#> condition_1   1.0000000   0.8857143   0.8285714   0.8857143   0.9600000
#> condition_2   0.8857143   1.0000000   0.7714286   0.9714286   0.9666667
#> condition_3   0.8285714   0.7714286   1.0000000   0.7750000   0.8000000
#> condition_4   0.8857143   0.9714286   0.7750000   1.0000000   0.9714286
#> condition_5   0.9600000   0.9666667   0.8000000   0.9714286   1.0000000
get_pairwise_sharing_from_samples(m, factor=0) # sharing by sign
#>             condition_1 condition_2 condition_3 condition_4 condition_5
#> condition_1   1.0000000   0.9714286   0.8285714   0.9714286         1.0
#> condition_2   0.9714286   1.0000000   0.9142857   1.0000000         1.0
#> condition_3   0.8285714   0.9142857   1.0000000   0.8750000         0.9
#> condition_4   0.9714286   1.0000000   0.8750000   1.0000000         1.0
#> condition_5   1.0000000   1.0000000   0.9000000   1.0000000         1.0
get_pairwise_sharing_from_samples(m, FUN=abs) # sharing by magnitude when sign is ignored
#>             condition_1 condition_2 condition_3 condition_4 condition_5
#> condition_1   1.0000000   0.8857143   0.8285714   0.8857143   0.9600000
#> condition_2   0.8857143   1.0000000   0.7714286   0.9714286   0.9666667
#> condition_3   0.8285714   0.7714286   1.0000000   0.7750000   0.8000000
#> condition_4   0.8857143   0.9714286   0.7750000   1.0000000   0.9714286
#> condition_5   0.9600000   0.9666667   0.8000000   0.9714286   1.0000000