| Title: | Bayesian Mendelian Randomization for Causal Cell-Cell Communication |
|---|---|
| Description: | Implements MR-CCC, a Bayesian Mendelian randomization framework for inferring causal ligand-receptor signalling between cell types from population-scale single-cell expression and genotype data. For each ligand-receptor-pathway triplet, cis-eQTL genotypes instrument ligand expression in the sender cell type and receptor expression in the receiver cell type. A working model with a ligand-by-receptor interaction is then fitted to downstream pathway activity by a blocked Gibbs sampler. A spike-and-slab prior on the causal block yields a posterior inclusion probability that serves as the communication score. The retained draws support credible intervals, sign probabilities, the receptor level at which the ligand effect reverses sign, and Bayesian false discovery rate control across many triplets. Inputs are taken from SummarizedExperiment objects of donor-level expression and genotype dosages, and cis-eQTL instruments can be selected within the package. |
| Authors: | Bitan Sarkar [aut, cre] (ORCID: <https://orcid.org/0009-0000-5178-5934>), Yang Ni [aut] (ORCID: <https://orcid.org/0000-0003-0636-2363>), National Institutes of Health [fnd] (Grants R01GM148974 and R01GM163238) |
| Maintainer: | Bitan Sarkar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.0 |
| Built: | 2026-11-24 04:32:34 UTC |
| Source: | https://github.com/bioc/MRCCC |
For a vector of posterior inclusion probabilities from many
ligand-receptor-pathway triplets, computes the Bayesian false discovery
rate (bFDR) of every nested set obtained by declaring the top-
triplets by PIP, for .
bayesFDR(pip)bayesFDR(pip)
pip |
Posterior inclusion probabilities, one per triplet: a
numeric vector in |
For a declared set , the posterior expected number of false
discoveries is , so the Bayesian
false discovery rate is
Ranking the triplets by decreasing PIP and accumulating gives, for each
possible cut-off, the bFDR incurred by declaring everything at or above
it. Because the PIPs are posterior probabilities, this controls the
expected proportion of false discoveries without a separate multiplicity
correction. The value returned for triplet is the bFDR of the
smallest nested set that contains . It is non-decreasing in the
rank of . Ties in PIP are broken by input order.
A numeric vector of the same length as pip, in the order of the
input, giving the bFDR of the nested set that ends at each triplet.
Newton MA, Noueiry A, Sarkar D, Ahlquist P (2004). Detecting differential gene expression with a semiparametric hierarchical mixture method. Biostatistics 5(2):155-176.
pip <- c(0.9, 0.8, 0.5) bayesFDR(pip) # Unsorted input is handled. Results are returned in input order. bayesFDR(c(0.5, 0.9, 0.8))pip <- c(0.9, 0.8, 0.5) bayesFDR(pip) # Unsorted input is handled. Results are returned in input order. bayesFDR(c(0.5, 0.9, 0.8))
Selects the largest nested set of triplets, ranked by decreasing posterior
inclusion probability, whose Bayesian false discovery rate does not exceed
alpha. The rule is monotone: if the top- set qualifies, so does
every smaller top- set. If no set qualifies, nothing is selected.
bfdrSelect(pip, alpha)bfdrSelect(pip, alpha)
pip |
Posterior inclusion probabilities, one per triplet: a
numeric vector in |
alpha |
Target Bayesian false discovery rate in |
A logical vector of the same length as pip, in input order,
that is TRUE for the selected triplets.
pip <- c(0.9, 0.8, 0.5, 0.2) bayesFDR(pip) bfdrSelect(pip, alpha = 0.2) bfdrSelect(pip, alpha = 0.05)pip <- c(0.9, 0.8, 0.5, 0.2) bayesFDR(pip) bfdrSelect(pip, alpha = 0.2) bfdrSelect(pip, alpha = 0.05)
Assembles the MRCCCData object for one ligand-receptor-pathway
triplet from donor-level (pseudo-bulk) expression of a sender and a
receiver cell type and from donor genotypes. Donors are matched across
the three objects by column name, covariates are taken from colData,
the pathway activity score is computed from the receiver's expression of
the pathway genes, and, unless supplied, the cis-eQTL instruments of the
ligand and the receptor are chosen with selectInstruments().
buildTriplet( sender, receiver, genotypes, ligand, receptor, pathway, covariates, ligandSNPs = NULL, receptorSNPs = NULL, assay = 1L, genotypeAssay = 1L, pathwayMethod = c("mean", "pc1"), pathwayName = NA_character_, senderName = NA_character_, receiverName = NA_character_, ... )buildTriplet( sender, receiver, genotypes, ligand, receptor, pathway, covariates, ligandSNPs = NULL, receptorSNPs = NULL, assay = 1L, genotypeAssay = 1L, pathwayMethod = c("mean", "pc1"), pathwayName = NA_character_, senderName = NA_character_, receiverName = NA_character_, ... )
sender |
A |
receiver |
A |
genotypes |
A |
ligand |
Name of the ligand gene (a row name of |
receptor |
Name of the receptor gene (a row name of |
pathway |
The pathway activity, given in one of three ways. It can
be a character vector of pathway genes, scored in |
covariates |
Character vector naming donor covariates in
|
ligandSNPs, receptorSNPs
|
Optional instruments: character vectors of
SNP identifiers (row names of |
assay |
Assay of |
genotypeAssay |
Assay of |
pathwayMethod |
How a character |
pathwayName, senderName, receiverName
|
Optional labels used in printed output. |
... |
Further arguments passed to |
Only donors present in sender, receiver and genotypes are used, and
a message reports how many were dropped. The instrument screens use the
same donors and covariates as the model, so the analysis is one-sample.
The selection tables are kept in the metadata slot of the result under
ligandInstruments and receptorInstruments.
An MRCCCData object.
selectInstruments(), MRCCCData(), mrccc(),
simulateMRCCC()
sim <- simulateMRCCC(n = 120, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2"), pathwayName = "Simulated pathway") datsim <- simulateMRCCC(n = 120, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2"), pathwayName = "Simulated pathway") dat
Computes equal-tailed posterior credible intervals for ,
and from the pooled retained draws of an
MR-CCC fit.
credibleIntervals(x, ...) ## S4 method for signature 'MRCCCFit' credibleIntervals(x, level = 0.95, standardized = TRUE, included = FALSE, ...)credibleIntervals(x, ...) ## S4 method for signature 'MRCCCFit' credibleIntervals(x, level = 0.95, standardized = TRUE, included = FALSE, ...)
x |
|
... |
Not used. |
level |
Credible level in |
standardized |
Logical. If |
included |
Logical. If |
The prior on is a spike-and-slab mixture, so
the marginal posterior of each of these coefficients mixes draws
concentrated near zero () with slab draws
(). An interval that covers zero therefore reflects the
posterior weight of the spike as much as the uncertainty within the slab.
See signProbabilities() for a decomposition. With included = TRUE the
spike draws are left out, so the intervals describe the size of the
effects given that the ligand acts on the pathway.
A data frame with columns parameter (beta_X, beta_XZ,
beta_Z), lower, median and upper. With included = TRUE and no
draw with , the bounds are NA.
mrccc(), effectSizes(), signProbabilities()
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) credibleIntervals(fit) credibleIntervals(fit, level = 0.9, standardized = FALSE) credibleIntervals(fit, included = TRUE)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) credibleIntervals(fit) credibleIntervals(fit, level = 0.9, standardized = FALSE) credibleIntervals(fit, included = TRUE)
Extract the components of an MRCCCData object. All components are aligned by donor.
donors(x) ligandExpression(x) receptorExpression(x) pathwayActivity(x) ligandGenotypes(x) receptorGenotypes(x) covariates(x) tripletLabels(x) ## S4 method for signature 'MRCCCData' donors(x) ## S4 method for signature 'MRCCCData' ligandExpression(x) ## S4 method for signature 'MRCCCData' receptorExpression(x) ## S4 method for signature 'MRCCCData' pathwayActivity(x) ## S4 method for signature 'MRCCCData' ligandGenotypes(x) ## S4 method for signature 'MRCCCData' receptorGenotypes(x) ## S4 method for signature 'MRCCCData' covariates(x) ## S4 method for signature 'MRCCCData' tripletLabels(x)donors(x) ligandExpression(x) receptorExpression(x) pathwayActivity(x) ligandGenotypes(x) receptorGenotypes(x) covariates(x) tripletLabels(x) ## S4 method for signature 'MRCCCData' donors(x) ## S4 method for signature 'MRCCCData' ligandExpression(x) ## S4 method for signature 'MRCCCData' receptorExpression(x) ## S4 method for signature 'MRCCCData' pathwayActivity(x) ## S4 method for signature 'MRCCCData' ligandGenotypes(x) ## S4 method for signature 'MRCCCData' receptorGenotypes(x) ## S4 method for signature 'MRCCCData' covariates(x) ## S4 method for signature 'MRCCCData' tripletLabels(x)
x |
An MRCCCData object (or, for |
donors() returns the donor identifiers.
ligandExpression(), receptorExpression() and pathwayActivity()
return named numeric vectors. ligandGenotypes() and
receptorGenotypes() return donors-by-SNPs dosage matrices.
covariates() returns the donors-by-covariates matrix.
tripletLabels() returns the named character vector of labels.
sim <- simulateMRCCC(n = 120, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) head(donors(dat)) colnames(ligandGenotypes(dat)) head(covariates(dat)) tripletLabels(dat)sim <- simulateMRCCC(n = 120, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) head(donors(dat)) colnames(ligandGenotypes(dat)) head(covariates(dat)) tripletLabels(dat)
Fits the Bayesian Mendelian randomization model for causal cell-cell communication to one triplet stored in an MRCCCData object. The cis-eQTL genotypes instrument ligand expression in the sender cell type and receptor expression in the receiver cell type. The model asks whether the genetically predicted ligand level, modulated by the genetically predicted receptor level, shifts pathway activity in the receiver. Several Gibbs chains are run and pooled, and the posterior inclusion probability (PIP) is returned with its Monte Carlo standard error and convergence diagnostics.
mrccc(x, ...) ## S4 method for signature 'MRCCCData' mrccc( x, nIter = 20000L, burnIn = 2000L, thin = 1L, nChains = 4L, initScale = 1, pipThreshold = 0.5, hyper = mrcccHyperparameters(), seed = NULL, verbose = FALSE, BPPARAM = BiocParallel::SerialParam(), ... )mrccc(x, ...) ## S4 method for signature 'MRCCCData' mrccc( x, nIter = 20000L, burnIn = 2000L, thin = 1L, nChains = 4L, initScale = 1, pipThreshold = 0.5, hyper = mrcccHyperparameters(), seed = NULL, verbose = FALSE, BPPARAM = BiocParallel::SerialParam(), ... )
x |
An MRCCCData object, usually from |
... |
Not used. |
nIter |
Total number of Gibbs iterations per chain. |
burnIn |
Number of initial iterations discarded per chain. Must be
smaller than |
thin |
Thinning interval: every |
nChains |
Number of independent chains, pooled for all posterior
summaries. With two or more chains the Gelman-Rubin statistic is
reported and the chains start from dispersed values. Pooling |
initScale |
Standard deviation of the normal distribution from which
|
pipThreshold |
Threshold in |
hyper |
Prior hyperparameters, as returned by
|
seed |
Optional integer. If supplied, the fit is reproducible: one
seed per chain is derived from it, each chain runs under its own seed
wherever it is evaluated, and the caller's random number state is
restored afterwards. With the default |
verbose |
Logical. If |
BPPARAM |
A BiocParallel::BiocParallelParam object that
controls how the chains are run. The default
|
Model. For donor , with and
the genetically predicted ligand and receptor
levels, the outcome model is
where is ligand expression, receptor expression,
pathway activity, and the instrument dosages and
the covariates. The causal block has a
spike-and-slab prior with inclusion indicator
. Under the prior variance of
the block is multiplied by nu1 ( by default), so the
coefficients are concentrated tightly at zero. The PIP is the
communication score. The receptor-modulated ligand effect is
, which changes sign at
. See signReversal().
Centring and scale. Neither first stage carries an intercept, so the
expression, pathway, genotype and covariate data are all centred
internally. Effects are reported on the centred input scale and on a
standardised scale (per standard deviation of and , in
standard deviations of ). See effectSizes().
Priors. The first-stage blocks and the covariate block carry Zellner
g-priors on their designs. The second-stage blocks are scaled by a fixed
diagonal computed once from the least-squares first stage, so every
Gibbs update is an exact conjugate step. Unless overridden in hyper,
every scale is . See mrcccHyperparameters().
Instrument strength. The first-stage partial F statistic of each
instrument set, after the covariates, is reported by
instrumentStrength(). A message is issued when either F is below 10.
MR-CCC does not require F > 10, but PIPs are less decisive with weak
instruments and longer chains may be needed.
Chains, Monte Carlo error and convergence. Odd-numbered chains start
with and even-numbered chains with .
The Monte Carlo standard error (MCSE) of the PIP is estimated by
non-overlapping batch means within each chain and combined across chains.
It is NA when the indicator never changes value in any chain, so that
the PIP is exactly 0 or 1. A warning is issued when
for threshold ,
because the discovery status is then not resolved at the current chain
length, and when any Gelman-Rubin exceeds
1.01. is reported for , ,
and the joint log-likelihood. It requires at least two
chains. The default chain length is a starting point. Reported analyses
should use chains long enough that neither warning is issued.
Which R-hat. is the classic Gelman-Rubin potential scale
reduction factor (Gelman and Rubin, 1992), without the correction for
sampling variability, which is the statistic defined and reported in the
paper. The threshold 1.01 is the one recommended for the rank-normalised
split of Vehtari et al. (2021). For the classic statistic,
the conventional threshold is 1.1, so the check here is stricter than
usual and errs on the side of longer chains.
Settings used in the paper. The real-data analysis ran four chains of 100,000 iterations per triplet with a burn-in of 2,000. The simulation studies ran one chain per fit, of 20,000 iterations when the instruments are strong (scenarios S1 to S3) and of 400,000 iterations under weak or otherwise misspecified instruments (scenarios S4 to S7), with a burn-in of 2,000. A comparison with MR-CCC should use chains of these lengths, or longer, for the corresponding setting.
An MRCCCFit object. See MRCCCFit-accessors.
Sarkar B, Ni Y (2026). MR-CCC: Bayesian Mendelian Randomization for Causal Cell-Cell Communication. Bioinformatics (in press). arXiv:2604.23917.
Gelman A, Rubin DB (1992). Inference from iterative simulation using multiple sequences. Statistical Science 7(4):457-472.
Vehtari A, Gelman A, Simpson D, Carpenter B, Burkner P-C (2021). Rank-normalization, folding, and localization: an improved R-hat for assessing convergence of MCMC. Bayesian Analysis 16(2):667-718.
buildTriplet(), MRCCCFit-accessors, credibleIntervals(),
signProbabilities(), signReversal(), plotEffectCurve(),
mrcccScreen(), bayesFDR()
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) fit pip(fit) effectSizes(fit)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) fit pip(fit) effectSizes(fit)
Constructs the input object for one ligand-receptor-pathway triplet from
donor-level vectors and matrices. Donors are matched by name rather than
by position, so components supplied in a different donor order are
aligned automatically and components that refer to different donors are
rejected. Most users will create the object
from SummarizedExperiment data with buildTriplet() instead.
MRCCCData( ligandExpression, receptorExpression, pathwayActivity, ligandGenotypes, receptorGenotypes, covariates, labels = NULL, metadata = list() )MRCCCData( ligandExpression, receptorExpression, pathwayActivity, ligandGenotypes, receptorGenotypes, covariates, labels = NULL, metadata = list() )
ligandExpression |
Numeric vector (or one-column matrix), one value per donor: ligand expression in the sender cell type, typically normalised pseudo-bulk expression. |
receptorExpression |
Numeric vector: receptor expression in the receiver cell type. |
pathwayActivity |
Numeric vector: activity score of the downstream pathway in the receiver cell type. |
ligandGenotypes |
Numeric matrix or data frame, donors in rows and
SNPs in columns: allele dosages (0, 1 or 2 copies of the alternative
allele, or an imputed dosage between 0 and 2) of the cis-eQTL SNPs that
instrument the ligand. See |
receptorGenotypes |
Numeric matrix or data frame, donors by SNPs: allele dosages of the cis-eQTL SNPs that instrument the receptor. |
covariates |
Numeric matrix or data frame, donors in rows: donor covariates such as sex, age and genotype principal components. Factor, character and logical columns of a data frame are expanded to indicator columns (treatment contrasts). At least one covariate is required. |
labels |
Optional named character vector or list with any of the
elements |
metadata |
Optional list of additional information, read back with
|
Donor matching. If every component carries donor names (names of the
vectors, row names of the matrices), the donors of ligandExpression
define the order and every other component is reordered to match. A
component that lacks any of these donors is an error. If no component
carries donor names, all must have the same length and are taken to be
in the same order, and donors are named donor1, donor2, and so on.
Supplying names for some components but not others is an error.
Units. Genotypes are individual-level allele dosages of the same
donors whose expression is analysed. MR-CCC is a one-sample method and
does not use external eQTL summary statistics. Expression and pathway
activity may be on any scale (for example log-normalised pseudo-bulk
expression). mrccc() centres all inputs and reports effects on both
the centred input scale and a standardised scale.
An MRCCCData object.
buildTriplet(), mrccc(), MRCCCData-accessors
set.seed(1) n <- 50 ids <- sprintf("D%02d", seq_len(n)) G <- matrix(rbinom(n * 3, 2, 0.3), n, 3, dimnames = list(ids, c("rs1", "rs2", "rs3"))) H <- matrix(rbinom(n * 2, 2, 0.4), n, 2, dimnames = list(ids, c("rs4", "rs5"))) cov <- data.frame(sex = sample(c("female", "male"), n, TRUE), age = round(runif(n, 20, 80)), row.names = ids) x <- setNames(drop(G %*% c(0.5, 0.3, 0.2)) + rnorm(n), ids) z <- setNames(drop(H %*% c(0.4, 0.4)) + rnorm(n), ids) y <- setNames(0.3 * x + 0.2 * x * z + rnorm(n), ids) dat <- MRCCCData(ligandExpression = x, receptorExpression = z, pathwayActivity = y, ligandGenotypes = G, receptorGenotypes = H, covariates = cov, labels = c(ligand = "LIG1", receptor = "REC1")) datset.seed(1) n <- 50 ids <- sprintf("D%02d", seq_len(n)) G <- matrix(rbinom(n * 3, 2, 0.3), n, 3, dimnames = list(ids, c("rs1", "rs2", "rs3"))) H <- matrix(rbinom(n * 2, 2, 0.4), n, 2, dimnames = list(ids, c("rs4", "rs5"))) cov <- data.frame(sex = sample(c("female", "male"), n, TRUE), age = round(runif(n, 20, 80)), row.names = ids) x <- setNames(drop(G %*% c(0.5, 0.3, 0.2)) + rnorm(n), ids) z <- setNames(drop(H %*% c(0.4, 0.4)) + rnorm(n), ids) y <- setNames(0.3 * x + 0.2 * x * z + rnorm(n), ids) dat <- MRCCCData(ligandExpression = x, receptorExpression = z, pathwayActivity = y, ligandGenotypes = G, receptorGenotypes = H, covariates = cov, labels = c(ligand = "LIG1", receptor = "REC1")) dat
An MRCCCData object holds everything MR-CCC needs for one
ligand-receptor-pathway triplet, aligned by donor: ligand expression in
the sender cell type, receptor expression and pathway activity in the
receiver cell type, the cis-eQTL genotypes that instrument the ligand and
the receptor, and the donor covariates. Objects are normally created from
SummarizedExperiment data with buildTriplet(), or from aligned
vectors and matrices with the constructor MRCCCData(). The validity
method checks that every component refers to the same donors in the same
order, that genotypes are allele dosages in [0, 2], and that no value is
missing.
## S4 method for signature 'MRCCCData' show(object)## S4 method for signature 'MRCCCData' show(object)
object |
An MRCCCData object. |
show() prints a description of the triplet and returns object
invisibly.
ligandExpressionNamed numeric vector, one value per donor: ligand expression in the sender cell type.
receptorExpressionNamed numeric vector: receptor expression in the receiver cell type.
pathwayActivityNamed numeric vector: pathway activity score in the receiver cell type.
ligandGenotypesNumeric matrix, donors by SNPs: allele dosages (0, 1 or 2 copies of the alternative allele, or an imputed value in between) of the cis-eQTL SNPs that instrument the ligand.
receptorGenotypesNumeric matrix, donors by SNPs: allele dosages of the cis-eQTL SNPs that instrument the receptor.
covariatesNumeric matrix, donors by covariates: donor-level covariates (for example sex, age and genotype principal components), with factors already expanded to indicator columns.
labelsNamed character vector with elements ligand, receptor,
pathway, sender and receiver (any may be NA), used in printed
output.
metadataList of additional information, inherited from
S4Vectors::Annotated and read with S4Vectors::metadata().
buildTriplet() records there the instrument-selection tables
(ligandInstruments, receptorInstruments), the pathway genes
(pathwayGenes) and how the pathway was scored (pathwayMethod).
MRCCCData(), buildTriplet(), mrccc()
An MRCCCFit object is returned by mrccc(). It stores the pooled
posterior draws of the causal effects and the inclusion indicator, the
posterior inclusion probability (PIP) with its Monte Carlo error, the
convergence diagnostics, the first-stage instrument strength, and the
settings of the run. Use the accessors rather than the slots: pip(),
pipMCSE(), effectSizes(), credibleIntervals(),
signProbabilities(), signReversal(), convergence(),
instrumentStrength(), firstStageEffects(), posteriorMeans(),
posteriorDraws(), inputScale(), fitSettings() and
plotEffectCurve().
## S4 method for signature 'MRCCCFit' show(object)## S4 method for signature 'MRCCCFit' show(object)
object |
An MRCCCFit object. |
show() prints a short summary of the fit and returns object
invisibly.
pipPosterior inclusion probability, pooled over chains.
pipMCSEMonte Carlo standard error of pip.
pipESSEffective sample size of the pooled indicator chain.
drawsData frame of retained draws, one row per draw, with columns
chain, beta_X, beta_XZ, beta_Z, gamma, mu (intercept) and
loglik (joint log-likelihood of the three equations), the
coefficients on the centred input scale. Read with posteriorDraws().
scaleList with the standard deviations (sdX, sdZ, sdY) and
means (meanX, meanZ, meanY) of ligand expression, receptor
expression and pathway activity, and the observed receptor range in
standard deviations from its mean (zRangeStd). Read with
inputScale().
diagnosticsData frame with columns parameter (beta_X,
beta_XZ, gamma, loglik) and rhat, the Gelman-Rubin statistic
(NA for a single chain). Read with convergence().
instrumentsData frame with one row per exposure and columns
exposure (ligand, receptor), nInstruments, F (first-stage
partial F statistic after the covariates) and weak (F < 10). Read
with instrumentStrength().
firstStageData frame with one row per instrument and columns
exposure, snp, mean, lower and upper: the posterior mean and
95% credible interval of the instrument's effect on expression per copy
of the alternative allele. Read with firstStageEffects().
posteriorMeansList of the posterior means of the remaining
parameters: covariateEffects (data frame with columns covariate,
ligand, receptor and pathway), residualVariances (named vector
for the ligand, receptor and pathway equations),
inclusionProbabilityPrior () and intercept
(). Read with posteriorMeans().
settingsList of the run settings: nIter, burnIn, thin,
nChains, nKeep (retained draws per chain), pipThreshold, hyper
(the hyperparameters), g (the g-prior scale used), initScale and
priorScale (the fixed second-stage prior scale d_X, d_XZ,
d_Z). Read with fitSettings().
labelsLabels copied from the MRCCCData object.
Constructs and validates the list of prior hyperparameters used by
mrccc(). The defaults are those used throughout the MR-CCC analyses and
are weakly informative for inputs on a scale of roughly unit variance:
with several hundred donors the likelihood then dominates the
inverse-gamma and beta priors. The inverse-gamma priors are not invariant
to the units of X, Z and Y, so inputs on very different scales
should be standardised before fitting.
mrcccHyperparameters( aSigma = 3, bSigma = 2, aRho = 3, bRho = 1, nu1 = 1e-04, g = NULL, ridge = 1e-08 )mrcccHyperparameters( aSigma = 3, bSigma = 2, aRho = 3, bRho = 1, nu1 = 1e-04, g = NULL, ridge = 1e-08 )
aSigma, bSigma
|
Shape and scale of the inverse-gamma prior on the
three residual variances |
aRho, bRho
|
Shape parameters of the beta prior on the prior
inclusion probability |
nu1 |
Spike variance multiplier in |
g |
Common g-prior scale applied to every coefficient block
(first-stage sender effects, first-stage receiver effects, covariate
effects, receptor main effect, and the causal block). If |
ridge |
Positive diagonal ridge added before every matrix inversion for numerical stability. |
Each first-stage block with observed design (the
genotype matrices , or the covariates ) has the
Zellner g-prior . The
second-stage blocks and use the
same scale but against a fixed diagonal computed once from the
least-squares first stage, because their regressors and
are themselves parameters of the model. See the Priors section
of mrccc(). The default follows the
unit-information convention for small samples and caps the prior
dispersion for large ones. The spike-and-slab prior on the causal block
uses scale in the slab and in the spike.
A named list of class mrcccHyperparameters with elements
aSigma, bSigma, aRho, bRho, nu1, g and ridge.
hyper <- mrcccHyperparameters() str(hyper) # A wider spike (less strict shrinkage under gamma = 0) and a fixed # g-prior scale of 50, which narrows the slab when there are more than # 50 donors mrcccHyperparameters(nu1 = 1e-3, g = 50)hyper <- mrcccHyperparameters() str(hyper) # A wider spike (less strict shrinkage under gamma = 0) and a fixed # g-prior scale of 50, which narrows the slab when there are more than # 50 donors mrcccHyperparameters(nu1 = 1e-3, g = 50)
Fits mrccc() to every triplet in a list and returns the fits, ready for
Bayesian false discovery rate control with bayesFDR(), bfdrSelect()
or screenTable(). Triplets are fitted in parallel through
BiocParallel, and the chains within each triplet are run one after
another.
mrcccScreen(triplets, ..., seed = NULL, BPPARAM = BiocParallel::SerialParam())mrcccScreen(triplets, ..., seed = NULL, BPPARAM = BiocParallel::SerialParam())
triplets |
A list of MRCCCData objects, usually named. Each
is typically made with |
... |
Further arguments passed to |
seed |
Optional integer. If supplied, one seed per triplet is derived from it, so the screen is reproducible whatever the back end. |
BPPARAM |
A BiocParallel::BiocParallelParam object that
controls how the triplets are distributed. The default
|
A list of MRCCCFit objects with the names of triplets.
When triplets is unnamed, the names are built from the ligand and
receptor labels.
screenTable(), bayesFDR(), bfdrSelect(), mrccc()
sims <- lapply(c(1, 2), function(s) simulateMRCCC(n = 200, seed = s)) triplets <- lapply(sims, function(sim) { buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) }) names(triplets) <- c("replicate1", "replicate2") fits <- mrcccScreen(triplets, nIter = 4000, burnIn = 1000, seed = 1) screenTable(fits)sims <- lapply(c(1, 2), function(s) simulateMRCCC(n = 200, seed = s)) triplets <- lapply(sims, function(sim) { buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) }) names(triplets) <- c("replicate1", "replicate2") fits <- mrcccScreen(triplets, nIter = 4000, burnIn = 1000, seed = 1) screenTable(fits)
Returned by summary(). Printing it shows the
posterior inclusion probability with its Monte Carlo error, the
standardised effects with credible intervals, the instrument strength and
the convergence diagnostics. as.data.frame() returns the table of
effects.
## S4 method for signature 'MRCCCSummary' show(object) ## S3 method for class 'MRCCCSummary' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S4 method for signature 'MRCCCSummary' show(object) ## S3 method for class 'MRCCCSummary' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
object |
An MRCCCSummary object. |
x |
An MRCCCSummary object. |
row.names, optional
|
Not used. |
... |
Not used. |
show() prints the summary and returns object invisibly.
as.data.frame() returns the table of effects.
tableData frame with one row per effect and columns parameter
(beta_X, beta_XZ, beta_Z), mean, lower and upper (posterior
mean and credible interval on the standardised scale) and rhat. The
rhat of beta_Z is NA because R-hat is computed for beta_X,
beta_XZ, gamma and the log-likelihood only.
diagnosticsData frame of Gelman-Rubin statistics, as returned by
convergence().
instrumentsData frame of first-stage instrument strength, as
returned by instrumentStrength().
infoList with title (the triplet labels), nChains, nKeep,
pip, pipMCSE, pipESS, pipThreshold and level (the credible
level).
Loads a small subset of the OneK1K cohort (Yazar et al., 2022) that ships with the package, for demonstrating MR-CCC on real data. It covers the NK cells (sender) to monocytes (receiver) axis analysed in the MR-CCC paper, restricted to the ligand-receptor pairs that CellPhoneDB classifies as "Signaling by Interleukin".
onek1kExample()onek1kExample()
Provenance. The data were derived from the files deposited on Zenodo
for the MR-CCC paper (doi:10.5281/zenodo.19675075) by the script
inst/scripts/make-onek1k-example.R, which can be found with
system.file("scripts", "make-onek1k-example.R", package = "MRCCC").
Donors pass the quality control of the paper. Expression is donor-level
(pseudo-bulk) counts divided by a library-size factor, as in the paper.
Genotypes are allele dosages of the SNPs within 200 kb of the
transcription start site of each ligand and receptor gene that are
carried by more than 5% of donors. The receiver colData holds the donor
covariates used in the paper (sex, ageBin for age in seven groups
coded 1 to 7, namely under 30, five 10-year bins and 80 or over, and the genotype principal components PC1, PC2 and
PC3) and two activity scores of the Reactome interleukin gene set:
interleukinPC1, the first principal component of the genes (centred,
scaled, and oriented so that higher scores mean higher mean expression),
and interleukinMean, their mean expression.
A list with elements
senderRangedSummarizedExperiment of NK-cell expression of
the ligand genes (assay normcounts), donors in columns.
receiverRangedSummarizedExperiment of monocyte expression
of the receptor genes (assay normcounts), with the covariates and
pathway scores in colData.
genotypesRangedSummarizedExperiment of allele dosages
(assay dosage), SNPs in rows.
tripletsData frame of the ligand-receptor-pathway triplets
with instruments for both genes, with columns ligand, receptor
and pathway.
Yazar S, Alquicira-Hernandez J, Wing K, et al. (2022). Single-cell eQTL mapping identifies cell type-specific genetic control of autoimmune disease. Science 376(6589):eabf3041.
Sarkar B, Ni Y (2026). MR-CCC: Bayesian Mendelian Randomization for Causal Cell-Cell Communication. Bioinformatics (in press). arXiv:2604.23917.
ex <- onek1kExample() ex$receiver ex$tripletsex <- onek1kExample() ex$receiver ex$triplets
Extract results from a fitted MR-CCC model.
pip(x) pipMCSE(x) effectSizes(x, ...) convergence(x) instrumentStrength(x) posteriorDraws(x, ...) firstStageEffects(x) posteriorMeans(x) inputScale(x) fitSettings(x) ## S4 method for signature 'MRCCCFit' pip(x) ## S4 method for signature 'MRCCCFit' pipMCSE(x) ## S4 method for signature 'MRCCCFit' effectSizes(x, standardized = TRUE, ...) ## S4 method for signature 'MRCCCFit' convergence(x) ## S4 method for signature 'MRCCCFit' instrumentStrength(x) ## S4 method for signature 'MRCCCFit' posteriorDraws(x, standardized = FALSE, ...) ## S4 method for signature 'MRCCCFit' tripletLabels(x) ## S4 method for signature 'MRCCCFit' firstStageEffects(x) ## S4 method for signature 'MRCCCFit' posteriorMeans(x) ## S4 method for signature 'MRCCCFit' inputScale(x) ## S4 method for signature 'MRCCCFit' fitSettings(x)pip(x) pipMCSE(x) effectSizes(x, ...) convergence(x) instrumentStrength(x) posteriorDraws(x, ...) firstStageEffects(x) posteriorMeans(x) inputScale(x) fitSettings(x) ## S4 method for signature 'MRCCCFit' pip(x) ## S4 method for signature 'MRCCCFit' pipMCSE(x) ## S4 method for signature 'MRCCCFit' effectSizes(x, standardized = TRUE, ...) ## S4 method for signature 'MRCCCFit' convergence(x) ## S4 method for signature 'MRCCCFit' instrumentStrength(x) ## S4 method for signature 'MRCCCFit' posteriorDraws(x, standardized = FALSE, ...) ## S4 method for signature 'MRCCCFit' tripletLabels(x) ## S4 method for signature 'MRCCCFit' firstStageEffects(x) ## S4 method for signature 'MRCCCFit' posteriorMeans(x) ## S4 method for signature 'MRCCCFit' inputScale(x) ## S4 method for signature 'MRCCCFit' fitSettings(x)
x |
|
... |
Not used. |
standardized |
Logical. If |
pip(): the posterior inclusion probability, a number in [0, 1].
pipMCSE(): a named numeric vector with the Monte Carlo standard error
(mcse) and effective sample size (ess) of the PIP.
effectSizes(): a data frame with columns parameter and mean, the
posterior mean. The parameters are beta_X, the ligand effect at the
mean receptor level, beta_XZ, the ligand-by-receptor interaction, and
beta_Z, the receptor main effect.
convergence(): a data frame of Gelman-Rubin statistics (rhat) for
beta_X, beta_XZ, gamma and the joint log-likelihood. The values
are NA for a single chain.
instrumentStrength(): a data frame with one row per exposure
(ligand, receptor) and columns nInstruments, F (first-stage
partial F statistic after the covariates) and weak (F < 10).
posteriorDraws(): a data frame of the pooled retained draws with
columns chain, beta_X, beta_XZ, beta_Z, gamma, mu and
loglik. With standardized = TRUE the three coefficients are
rescaled.
firstStageEffects(): a data frame with one row per instrument and
columns exposure (ligand or receptor), snp, mean, lower and
upper: the posterior mean and 95% credible interval of the effect of
one copy of the alternative allele on expression.
posteriorMeans(): a list with the posterior means of the remaining
parameters: covariateEffects (data frame with columns covariate,
ligand, receptor and pathway), residualVariances,
inclusionProbabilityPrior and intercept.
inputScale(): a list with the standard deviations (sdX, sdZ,
sdY) and means (meanX, meanZ, meanY) of ligand expression,
receptor expression and pathway activity, and the observed receptor
range in standard deviations from its mean (zRangeStd).
fitSettings(): a list of the run settings (nIter, burnIn,
thin, nChains, nKeep, pipThreshold, hyper, g, initScale
and priorScale).
tripletLabels(): the labels of the triplet.
mrccc(), credibleIntervals(), signProbabilities(),
signReversal(), plotEffectCurve()
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) pip(fit) pipMCSE(fit) effectSizes(fit) convergence(fit) instrumentStrength(fit) head(posteriorDraws(fit)) firstStageEffects(fit) posteriorMeans(fit)$residualVariances fitSettings(fit)$nKeepsim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) pip(fit) pipMCSE(fit) effectSizes(fit) convergence(fit) instrumentStrength(fit) head(posteriorDraws(fit)) firstStageEffects(fit) posteriorMeans(fit)$residualVariances fitSettings(fit)$nKeep
Plots the receptor-modulated ligand effect with its credible band. See
plotEffectCurve().
## S4 method for signature 'MRCCCFit,missing' plot(x, y, ...)## S4 method for signature 'MRCCCFit,missing' plot(x, y, ...)
x |
An MRCCCFit object. |
y |
Not used. |
... |
Further arguments passed to |
A ggplot object.
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) plot(fit)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) plot(fit)
Draws the posterior mean of the receptor-modulated ligand effect
over the observed range of receptor
expression, with a pointwise credible band from paired posterior draws.
plotEffectCurve(x, ...) ## S4 method for signature 'MRCCCFit' plotEffectCurve(x, level = 0.95, nDraws = 2000L, standardized = TRUE, ...)plotEffectCurve(x, ...) ## S4 method for signature 'MRCCCFit' plotEffectCurve(x, level = 0.95, nDraws = 2000L, standardized = TRUE, ...)
x |
|
... |
Not used. |
level |
Credible level in |
nDraws |
Maximum number of paired draws used for the band. A systematic subsample of the pooled draws of this size is taken. |
standardized |
Logical. If |
At each receptor level the band is the equal-tailed interval of
across paired draws, which accounts for the
posterior correlation of the two coefficients. The draws include both
spike and slab iterations. A dashed line marks an effect of zero. Where
the band crosses it, the direction of the ligand effect is uncertain.
A ggplot object.
sim <- simulateMRCCC(n = 200, betaX = 0.3, betaXZ = -0.3, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) plotEffectCurve(fit)sim <- simulateMRCCC(n = 200, betaX = 0.3, betaXZ = -0.3, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) plotEffectCurve(fit)
Collects the posterior inclusion probability, its Monte Carlo error and the largest Gelman-Rubin statistic of every fit, and applies Bayesian false discovery rate control across the triplets.
screenTable(fits, alpha = 0.1)screenTable(fits, alpha = 0.1)
fits |
A list of MRCCCFit objects, as returned by
|
alpha |
Target Bayesian false discovery rate for the selected set. |
A data frame with one row per fit, ordered by decreasing PIP, and
columns triplet (the name of the fit), ligand, receptor,
pathway, pip, pipMCSE, maxRhat (the largest Gelman-Rubin
statistic, NA for a single chain), bFDR (the Bayesian false
discovery rate of the PIP-ranked set ending at that triplet) and
selected (the largest set with Bayesian FDR at most alpha).
mrcccScreen(), bayesFDR(), bfdrSelect()
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fits <- mrcccScreen(list(example = dat), nIter = 4000, burnIn = 1000, seed = 1) screenTable(fits, alpha = 0.1)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fits <- mrcccScreen(list(example = dat), nIter = 4000, burnIn = 1000, seed = 1) screenTable(fits, alpha = 0.1)
Selects the cis-eQTL SNPs that serve as instrumental variables for the
expression of one gene (a ligand in the sender cell type or a receptor in
the receiver cell type), following the procedure of the MR-CCC paper:
SNPs in a window around the gene's promoter are screened in-sample by a
covariate-adjusted regression of the gene's donor-level expression on
allele dosage, ranked by p-value, and retained greedily subject to a
linkage-disequilibrium (LD) bound until at most maxSNPs are kept.
selectInstruments( expression, gene, genotypes, covariates = NULL, assay = 1L, genotypeAssay = 1L, window = 2e+05, maxSNPs = 10L, r2Max = 0.8, minCarrierFreq = 0.05, minCandidates = 1L )selectInstruments( expression, gene, genotypes, covariates = NULL, assay = 1L, genotypeAssay = 1L, window = 2e+05, maxSNPs = 10L, r2Max = 0.8, minCarrierFreq = 0.05, minCandidates = 1L )
expression |
A |
gene |
Name of the gene (a row name of |
genotypes |
A |
covariates |
Donor covariates to adjust the screen for: either a
character vector naming columns of |
assay |
Assay of |
genotypeAssay |
Assay of |
window |
Half-width in base pairs of the window around the transcription start site in which candidate SNPs are sought. The default 200 kb is the paper's setting. |
maxSNPs |
Maximum number of instruments retained. |
r2Max |
Maximum squared dosage correlation (LD |
minCarrierFreq |
SNPs carried (dosage of at least 0.5) by a fraction of donors no greater than this are removed before screening. |
minCandidates |
Minimum number of SNPs with a valid screening p-value required. With fewer, no instruments are returned. |
Only donors present in both expression and genotypes (and with
covariates, when supplied as a matrix) are used. The steps are:
Window. Candidate SNPs lie within window base pairs upstream or
downstream of the transcription start site of gene, as given by
IRanges::promoters() applied to its range.
Carrier filter. SNPs carried by at most minCarrierFreq of the
donors with a called genotype are removed. Remaining missing dosages
are imputed by the SNP's mean dosage.
Screen. For each candidate the gene's expression is regressed on the dosage and the covariates (with an intercept), and the two-sided p-value of the dosage coefficient is computed. SNPs whose dosage is constant or collinear with the covariates are skipped.
LD clumping. SNPs are visited in order of increasing p-value. A SNP
is kept if its squared dosage correlation with every SNP already kept
is at most r2Max, until maxSNPs are kept. The strongest SNP is
always kept.
No p-value threshold is applied: the strength of the selected set is
assessed in the model through the first-stage F statistic reported by
instrumentStrength(). Because the screen uses the same donors as the
model, MR-CCC is a one-sample analysis.
A DataFrame with one row per selected SNP, in the order of
selection, and columns snp (identifier), estimate (screening
coefficient per copy of the alternative allele) and pvalue. Its
metadata() records the gene, the window, the number of donors, the
number of SNPs in the window and the number screened. When fewer than
minCandidates SNPs can be screened, a zero-row DataFrame is
returned with a message.
Sarkar B, Ni Y (2026). MR-CCC: Bayesian Mendelian Randomization for Causal Cell-Cell Communication. Bioinformatics (in press). arXiv:2604.23917.
buildTriplet(), which calls this function for the ligand and
the receptor.
sim <- simulateMRCCC(n = 120, seed = 1) sel <- selectInstruments(sim$sender, "LIG1", sim$genotypes, covariates = c("sex", "age", "PC1", "PC2")) sel S4Vectors::metadata(sel)sim <- simulateMRCCC(n = 120, seed = 1) sel <- selectInstruments(sim$sender, "LIG1", sim$genotypes, covariates = c("sex", "age", "PC1", "PC2")) sel S4Vectors::metadata(sel)
Computes the posterior probability that the ligand-by-receptor
interaction is positive and that it is negative, both
marginally and conditionally on the causal block being included
().
signProbabilities(x, ...) ## S4 method for signature 'MRCCCFit' signProbabilities(x, ...)signProbabilities(x, ...) ## S4 method for signature 'MRCCCFit' signProbabilities(x, ...)
x |
|
... |
Not used. |
Under the spike-and-slab prior, the marginal posterior of
mixes draws taken while , which are
concentrated near zero and carry no directional information, with slab
draws taken while .
The marginal probabilities pPositive and pNegative use every
retained draw. They combine the evidence that there is an effect with
the evidence about its direction:
, and the last factor is close to one half.
The conditional probabilities pPositiveIncluded and
pNegativeIncluded use only the draws with . They
describe the direction of the interaction given that the ligand acts
on the pathway. They are NA when no draw has .
A one-row data frame with columns pip, pPositive,
pNegative, pPositiveIncluded, pNegativeIncluded and nIncluded
(the number of pooled draws with ).
mrccc(), credibleIntervals(), signReversal()
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) signProbabilities(fit)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) signProbabilities(fit)
Computes the posterior distribution of the sign-reversal threshold
, the receptor expression level at
which the receptor-modulated ligand effect
changes sign, from paired posterior draws.
signReversal(x, ...) ## S4 method for signature 'MRCCCFit' signReversal(x, level = 0.95, ...)signReversal(x, ...) ## S4 method for signature 'MRCCCFit' signReversal(x, level = 0.95, ...)
x |
|
... |
Not used. |
level |
Credible level in |
is a ratio of two correlated parameters, so its posterior is
computed from paired draws of . Draws whose
standardised interaction is negligible,
, are dropped, since diverges there. All remaining
draws are used, including those from the spike, so for a fit with a PIP
well below one the threshold is best read together with the PIP.
Scale. Receptor expression is centred before fitting, so
is reported in standard deviations of receptor expression relative to
its mean over donors: is a donor with average receptor
expression and a donor one standard deviation above
average. The observed receptor range, on the same scale, is returned as
zMin and zMax, and pInRange is the posterior probability that
lies inside it, which determines whether the reversal is
realised among the donors. The posterior of a ratio is heavy-tailed, so
the median and quantiles are reported rather than a mean. Note that the
interaction acts on the genetically predicted receptor level, whereas
the range refers to observed receptor expression.
A one-row data frame with columns tauMedian, tauLower,
tauUpper (equal-tailed credible bounds at level), level,
nDraws (paired draws used), zMin, zMax and pInRange. The
numeric summaries are NA when no usable draw is available.
mrccc(), plotEffectCurve(), signProbabilities()
sim <- simulateMRCCC(n = 200, betaX = 0.3, betaXZ = -0.3, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) signReversal(fit)sim <- simulateMRCCC(n = 200, betaX = 0.3, betaXZ = -0.3, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) signReversal(fit)
Generates donor-level pseudo-bulk expression for a sender and a receiver
cell type and donor genotypes, stored as RangedSummarizedExperiment
objects, under the MR-CCC data-generating process with an unmeasured
confounder. The output has the layout of real data and can be passed to
selectInstruments() and buildTriplet().
simulateMRCCC( n = 300L, nInstruments = 4L, betaX = 0.3, betaXZ = 0.3, betaZ = 0.5, instrumentEffect = 0.8, confounding = 0.7, nPathwayGenes = 8L, seed = NULL )simulateMRCCC( n = 300L, nInstruments = 4L, betaX = 0.3, betaXZ = 0.3, betaZ = 0.5, instrumentEffect = 0.8, confounding = 0.7, nPathwayGenes = 8L, seed = NULL )
n |
Number of donors. |
nInstruments |
Number of causal cis-eQTL SNPs for the ligand and for the receptor. |
betaX |
True ligand effect on the pathway at the mean receptor level. |
betaXZ |
True ligand-by-receptor interaction effect. |
betaZ |
True receptor main effect on the pathway. |
instrumentEffect |
Effect on expression of one standard deviation of each causal SNP's dosage (instrument strength). |
confounding |
Loading of an unmeasured confounder on ligand expression, receptor expression and pathway activity. Zero removes confounding. |
nPathwayGenes |
Number of genes in the downstream pathway. |
seed |
Optional integer. If supplied, the data are simulated under this seed and the caller's random number state is restored afterwards. |
Donors have covariates sex, age and two genotype principal components
PC1 and PC2, stored in the colData of both expression objects.
Genotypes are allele dosages (0, 1 or 2 copies of the alternative
allele). Around each of the ligand gene LIG1 (chromosome 1, plus strand)
and the receptor gene REC1 (chromosome 2, minus strand) the genotype
object contains nInstruments causal SNPs, one strongly linked proxy for
each causal SNP, six SNPs with no effect, one rare SNP and, outside the
200 kb window, five distant SNPs. With the confounder and
the standardised causal dosages,
where every element of is instrumentEffect, every element of
is 0.3, is confounding and the errors are standard
normal. The sender expresses LIG1 at . The receiver
expresses REC1 at and each pathway gene at plus
independent noise with standard deviation 0.5, so the mean expression of
the pathway genes tracks . Both objects also contain unrelated
genes. Setting betaX = betaXZ = 0 gives a null triplet.
A list with elements
senderRangedSummarizedExperiment of sender expression
(assay logcounts).
receiverRangedSummarizedExperiment of receiver expression
(assay logcounts).
genotypesRangedSummarizedExperiment of allele dosages
(assay dosage), SNPs in rows.
pathwayGenesNames of the pathway genes.
truthList with the generating values betaX, betaXZ,
betaZ, the causal SNP identifiers ligandCausal and
receptorCausal, and tauStd, the true sign-reversal threshold
in standard deviations of receptor
expression from its mean (NA when betaXZ is zero).
buildTriplet(), selectInstruments(), mrccc()
sim <- simulateMRCCC(n = 120, seed = 1) sim$sender sim$genotypes sim$truth$betaXZsim <- simulateMRCCC(n = 120, seed = 1) sim$sender sim$genotypes sim$truth$betaXZ
Collects the posterior inclusion probability with its Monte Carlo error, the standardised posterior means and credible intervals of the three effect sizes, the instrument strength and the convergence diagnostics.
## S4 method for signature 'MRCCCFit' summary(object, level = 0.95, ...)## S4 method for signature 'MRCCCFit' summary(object, level = 0.95, ...)
object |
|
level |
Credible level of the reported intervals. |
... |
Not used. |
An MRCCCSummary object, which prints the summary.
as.data.frame() extracts its table, with one row per effect
(beta_X, beta_XZ, beta_Z) and columns mean, lower and
upper on the standardised scale, and rhat.
sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) s <- summary(fit) s as.data.frame(s)sim <- simulateMRCCC(n = 200, seed = 1) dat <- buildTriplet(sim$sender, sim$receiver, sim$genotypes, ligand = "LIG1", receptor = "REC1", pathway = sim$pathwayGenes, covariates = c("sex", "age", "PC1", "PC2")) fit <- mrccc(dat, nIter = 4000, burnIn = 1000, seed = 1) s <- summary(fit) s as.data.frame(s)