Collapses a functional SuSiE (fsusieR::susiF) fit back to a
variants x features weight matrix usable for TWAS prediction of each
molecular feature. fSuSiE fits the regression in the wavelet domain, storing
per-SNP posterior-mean wavelet effects fitted_wc[[l]]
(nSNP x n_wac) and inclusion probabilities alpha[[l]]. Because
the inverse wavelet transform wr() is linear, the posterior-mean
prediction pushes through to a per-SNP, per-feature weight matrix:
$$W[j, f] = \sum_l alpha[[l]][j] \cdot
\mathrm{wr}\!\left(fitted\_wc[[l]][j, ] / csd\_X[j]\right)[f].$$
This is the exact analog of coef.susie for scalar SuSiE (all SNPs,
alpha-weighted), which spreads weight across the credible set – more robust
for out-of-sample TWAS than fSuSiE's in-sample lead-SNP summary
(update_cal_indf).
Usage
fsusieWeights(
fsusieFit = NULL,
X = NULL,
Y = NULL,
variantIds = NULL,
featureNames = NULL,
retainFit = FALSE
)Arguments
- fsusieFit
A fitted
fsusieR::susiFobject. Must retainfitted_wc,alpha,csd_X,n_wac, andouting_grid(i.e. an untrimmed fit). Required.- X, Y
Accepted for call-compatibility with the multivariate weight-method dispatch in
learnTwasWeights, which invokes every method asfn(X = ., Y = ., ...). fSuSiE is a functional method that cannot be refit from a bare(X, Y)pair (it needs feature positions and the wavelet model), so these are ignored: a fittedfsusieFitis always required.- variantIds
Optional character vector of variant IDs (length = number of SNPs in the fit) for the matrix row names. Defaults to
names(fsusieFit$csd_X)/names(fsusieFit$pip).- featureNames
Optional character vector of feature (outcome) names for the matrix column names. Defaults to the fit's
outing_grid.- retainFit
If TRUE, stores the fit as an attribute on the result.
Details
The reconstruction uses the raw posterior wavelet coefficients
fitted_wc, so it is independent of the post_processing mode
("smash"/"TI"/"HMM"/"none") – that smoothing
only denoises the alpha-collapsed display curve fitted_func, never the
per-SNP predictive coefficients. The $D/$C coefficient layout
and wavelet basis mirror out_prep.susiF, so the feature-domain output
matches fSuSiE's own conventions.
Examples
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:50]
n <- nrow(X)
nPos <- 16
base <- sin(seq(0, 2 * pi, length.out = nPos))
Y <- matrix(rep(base, each = n), n, nPos) +
X[, 1] %o% (0.5 * cos(seq(0, pi, length.out = nPos)))
pos <- seq_len(nPos)
fit <- fsusieWrapper(X, Y, pos = pos, L = 2,
prior = "mixture_normal_per_scale", maxSnpEm = 10,
covLev = 0.95, minPurity = 0.5, maxScale = 6)
#> [1] "Scaling columns of X and Y to have unit variance"
#> [1] "Starting initialization"
#> [1] "Data transform"
#> [1] "Discarding 0 wavelet coefficients out of 16"
#> [1] "Data transform done"
#> [1] "Initializing prior"
#> [1] "Initialization done"
#> [1] "Fitting effect 1 , iter 1"
#> [1] "Fitting effect 2 , iter 1"
#> [1] "Discarding 1 effects"
#> [1] "Greedy search and backfitting done"
#> [1] "Fine mapping done, refining effect estimates using cylce spinning wavelet transform"
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
#> Warning: essentially perfect fit: summary may be unreliable
fsusieWeights(fsusieFit = fit, X = X, Y = Y,
variantIds = colnames(X))
#> 1 2 3 4 5 6
#> chr22:32119788:T:C 0.9432148 0.9432148 0.9432148 0.9432148 0.9432148 0.9432148
#> chr22:32119867:T:G 0.9432148 0.9432148 0.9432148 0.9432148 0.9432148 0.9432148
#> chr22:32119961:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120053:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120593:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120636:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120932:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120975:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121290:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121498:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121635:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121702:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121936:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122351:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122676:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123055:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123164:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123383:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123461:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123806:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124049:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124126:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124147:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124381:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124644:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124683:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124952:C:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125308:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125638:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125730:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126169:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126200:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126215:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126386:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126486:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127195:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127370:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127374:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127405:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127470:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128069:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128246:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128368:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128733:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129602:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129674:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129864:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129921:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130038:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130229:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> 7 8 9 10 11
#> chr22:32119788:T:C 0.9432148 0.9432148 -0.9432148 -0.9432148 -0.9432148
#> chr22:32119867:T:G 0.9432148 0.9432148 -0.9432148 -0.9432148 -0.9432148
#> chr22:32119961:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120053:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120593:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120636:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120932:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120975:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121290:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121498:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121635:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121702:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121936:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122351:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122676:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123055:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123164:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123383:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123461:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123806:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124049:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124126:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124147:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124381:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124644:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124683:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124952:C:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125308:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125638:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125730:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126169:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126200:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126215:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126386:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126486:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127195:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127370:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127374:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127405:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127470:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128069:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128246:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128368:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128733:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129602:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129674:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129864:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129921:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130038:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130229:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> 12 13 14 15 16
#> chr22:32119788:T:C -0.9432148 -0.9432148 -0.9432148 -0.9432148 -0.9432148
#> chr22:32119867:T:G -0.9432148 -0.9432148 -0.9432148 -0.9432148 -0.9432148
#> chr22:32119961:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120053:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120593:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120636:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120932:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32120975:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121290:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121498:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121635:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121702:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32121936:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122351:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32122676:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123055:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123164:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123383:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123461:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32123806:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124049:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124126:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124147:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124381:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124644:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124683:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32124952:C:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125308:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125638:A:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32125730:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126169:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126200:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126215:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126386:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32126486:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127195:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127370:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127374:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127405:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32127470:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128069:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128246:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128368:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32128733:T:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129602:C:T 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129674:G:A 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129864:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32129921:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130038:A:G 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> chr22:32130229:T:C 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000