Title: | Negative binomial model for scRNA-seq |
---|---|
Description: | A model designed for dimensionality reduction and batch effect removal for scRNA-seq data. It is designed to be massively parallelizable using shared objects that prevent memory duplication, and it can be used with different mini-batch approaches in order to reduce time consumption. It assumes a negative binomial distribution for the data with a dispersion parameter that can be both commonwise across gene both genewise. |
Authors: | Federico Agostinis [aut, cre], Chiara Romualdi [aut], Gabriele Sales [aut], Davide Risso [aut] |
Maintainer: | Federico Agostinis <[email protected]> |
License: | GPL-3 |
Version: | 1.17.0 |
Built: | 2024-11-18 03:41:24 UTC |
Source: | https://github.com/bioc/NewWave |
Given a statistical model and some data, this function computes the AIC of the model given the data, i.e., the AIC of the data under the model.
newAIC(model, x) ## S4 method for signature 'newmodel,matrix' newAIC(model, x)
newAIC(model, x) ## S4 method for signature 'newmodel,matrix' newAIC(model, x)
model |
an object that describes a statistical model. |
x |
an object that describes data. |
the AIC of the model.
newAIC,newmodel,matrix-method
: returns the AIC of the NB model.
m <- newmodel(n=5, J=10) x <- newSim(m) newAIC(m, x$counts)
m <- newmodel(n=5, J=10) x <- newSim(m) newAIC(m, x$counts)
Given an object that describes a matrix of negative binomial distributions, returns the matrix of parameters associated with W for the mean part (mu)
newAlpha(object, ...)
newAlpha(object, ...)
object |
an object that describes a matrix of negative binomial distributions. |
... |
Additional parameters. |
the matrix of alpha parameters
a <- newmodel(n=5, J=10) newAlpha(a)
a <- newmodel(n=5, J=10) newAlpha(a)
Given an object that describes a matrix of negative binomial distributions, returns the matrix of parameters associated with X
newBeta(object, ...)
newBeta(object, ...)
object |
an object that describes a matrix of negative binomial distributions. |
... |
Additional parameters. |
the matrix of beta parameters
a <- newmodel(n=5, J=10) newBeta(a)
a <- newmodel(n=5, J=10) newBeta(a)
Given a statistical model and some data, this function computes the BIC of the model given the data, i.e., the BIC of the data under the model.
newBIC(model, x) ## S4 method for signature 'newmodel,matrix' newBIC(model, x)
newBIC(model, x) ## S4 method for signature 'newmodel,matrix' newBIC(model, x)
model |
an object that describes a statistical model. |
x |
an object that describes data. |
the BIC of the model.
newBIC,newmodel,matrix-method
: returns the BIC of the NB model.
m <- newmodel(n=5, J=10) x <- newSim(m) newBIC(m, x$counts)
m <- newmodel(n=5, J=10) x <- newSim(m) newBIC(m, x$counts)
Given an object describing a nb model, returns a vector of size the number
of rows in the parameter alpha
with the regularization parameters
associated to each row.
newEpsilon_alpha(object)
newEpsilon_alpha(object)
object |
an object that describes a matrix of negative binomial distributions. |
the regularization parameters for alpha
.
a <- newmodel(n=5, J=10) newEpsilon_alpha(a)
a <- newmodel(n=5, J=10) newEpsilon_alpha(a)
Given an object describing a nb model, returns a vector of size the number
of rows in the parameter beta
with the regularization parameters
associated to each row.
newEpsilon_beta(object)
newEpsilon_beta(object)
object |
an object that describes a matrix of negative binomial distributions. |
the regularization parameters for beta
.
a <- newmodel(n=5, J=10) newEpsilon_beta(a)
a <- newmodel(n=5, J=10) newEpsilon_beta(a)
Given an object describing a nb model, returns a vector of size the number
of columns in the parameter gamma
with the regularization
parameters associated to each row.
newEpsilon_gamma(object)
newEpsilon_gamma(object)
object |
an object that describes a matrix of negative binomial distributions. |
the regularization parameters for gamma
.
a <- newmodel(n=5, J=10) newEpsilon_gamma(a)
a <- newmodel(n=5, J=10) newEpsilon_gamma(a)
Given an object describing a nb model, returns a vector of size the number
of columns in the parameter W
with the regularization
parameters associated to each column.
newEpsilon_W(object)
newEpsilon_W(object)
object |
an object that describes a matrix of negative binomial distributions. |
the regularization parameters for W
.
a <- newmodel(n=5, J=10) newEpsilon_W(a)
a <- newmodel(n=5, J=10) newEpsilon_W(a)
The regularization parameter penalizes the variance of zeta, the log of the dispersion parameters across samples.
newEpsilon_zeta(object)
newEpsilon_zeta(object)
object |
an object that describes a matrix of negative binomial distributions. |
the regularization parameters for zeta
.
a <- newmodel(n=5, J=10) newEpsilon_zeta(a)
a <- newmodel(n=5, J=10) newEpsilon_zeta(a)
Given an object with the data, it fits a nb model.
newFit(Y, ...) ## S4 method for signature 'SummarizedExperiment' newFit( Y, X, V, K = 2, which_assay, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'matrix' newFit( Y, X, V, K = 2, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'DelayedMatrix' newFit( Y, X, V, K = 2, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'dgCMatrix' newFit(Y, ...)
newFit(Y, ...) ## S4 method for signature 'SummarizedExperiment' newFit( Y, X, V, K = 2, which_assay, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'matrix' newFit( Y, X, V, K = 2, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'DelayedMatrix' newFit( Y, X, V, K = 2, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... ) ## S4 method for signature 'dgCMatrix' newFit(Y, ...)
Y |
The matrix with the data |
... |
Additional parameters to describe the model, see
|
X |
The design matrix containing sample-level covariates, one sample per row. If missing, X will contain only an intercept. |
V |
The design matrix containing gene-level covariates, one gene per row. If missing, V will contain only an intercept. |
K |
integer. Number of latent factors(default 2). |
which_assay |
numeric or character. Which assay of Y to use. If missing, if 'assayNames(Y)' contains "counts" then that is used. Otherwise, the first assay is used. |
commondispersion |
Whether or not a single dispersion for all features is estimated (default TRUE). |
verbose |
Print helpful messages(default FALSE). |
maxiter_optimize |
maximum number of iterations for the optimization step (default 100). |
stop_epsilon |
stopping criterion in the optimization step, when the relative gain in likelihood is below epsilon (default 0.0001). |
children |
number of cores of the used cluster(default 1) |
random_init |
if TRUE no initializations is done(default FALSE) |
random_start |
if TRUE the setup of parameters is a random samplig(default FALSE) |
n_gene_disp |
number of genes used in mini-batch dispersion estimation approach(default NULL > all genes are used) |
n_cell_par |
number of cells used in mini-batch cell's related parameters estimation approach(default NULL > all cells are used) |
n_gene_par |
number of genes used in mini-batch gene's related parameters estimation approach(default NULL > all genes are used) |
By default, i.e., if no arguments other than Y
are passed,
the model is fitted with an intercept for the regression across-samples and
one intercept for the regression across genes.
If Y is a Summarized experiment, the function uses the assay named "counts", if any, or the first assay.
Currently, if Y is a sparseMatrix, this calls the newFit method on as.matrix(Y)
An object of class newmodel
that has been fitted by penalized
maximum likelihood on the data.
SummarizedExperiment
: Y is a
SummarizedExperiment
.
matrix
: Y is a matrix of counts (genes in rows).
DelayedMatrix
: Y is a DeleyedMatrix of counts (genes in rows).
dgCMatrix
: Y is a sparse matrix of counts (genes in rows).
se <- SummarizedExperiment(matrix(rpois(60, lambda=5), nrow=10, ncol=6), colData = data.frame(bio = gl(2, 3))) m <- newFit(se, X=model.matrix(~bio, data=colData(se))) bio <- gl(2, 3) m <- newFit(matrix(rpois(60, lambda=5), nrow=10, ncol=6), X=model.matrix(~bio))
se <- SummarizedExperiment(matrix(rpois(60, lambda=5), nrow=10, ncol=6), colData = data.frame(bio = gl(2, 3))) m <- newFit(se, X=model.matrix(~bio, data=colData(se))) bio <- gl(2, 3) m <- newFit(matrix(rpois(60, lambda=5), nrow=10, ncol=6), X=model.matrix(~bio))
Given an object that describes a matrix of negative binomial distributions, returns the matrix of parameters associated with V
newGamma(object, ...)
newGamma(object, ...)
object |
an object that describes a matrix of negative binomial distributions. |
... |
Additional parameters. |
the matrix of gamma parameters
a <- newmodel(n=5, J=10) newGamma(a)
a <- newmodel(n=5, J=10) newGamma(a)
Given a statistical model and some data, this function computes the log-likelihood of the model given the data, i.e., the log-probability of the data under the model.
newloglik(model, x, ...) ## S4 method for signature 'newmodel,matrix' newloglik(model, x)
newloglik(model, x, ...) ## S4 method for signature 'newmodel,matrix' newloglik(model, x)
model |
an object that describes a statistical model. |
x |
an object that describes data. |
... |
additional arguments. |
The log-likelihood of the model given the data.
model = newmodel,x = matrix
: return the log-likelihood of the nb model.
m <- newmodel(n=5, J=10) x <- newSim(m) newloglik(m, x$counts)
m <- newmodel(n=5, J=10) x <- newSim(m) newloglik(m, x$counts)
Given an object that describes a matrix of negative binomial distributions, returns the matrix of logarithm of mean parameters.
newLogMu(object)
newLogMu(object)
object |
an object that describes a matrix of negative binomial distributions. |
Note that although the user interface of newFit
requires a J x n matrix, internally this is stored as a n x J matrix (i.e.,
samples in row and genes in column). Hence the parameter matrix returned by
this function is of n x J dimensions.
the matrix of logarithms of mean parameters
a <- newmodel(n=5, J=10) newLogMu(a)
a <- newmodel(n=5, J=10) newLogMu(a)
Initialize an object of class newmodel
newmodel( X, V, W, beta, gamma, alpha, zeta, epsilon, epsilon_beta, epsilon_gamma, epsilon_W, epsilon_alpha, epsilon_zeta, n, J, K )
newmodel( X, V, W, beta, gamma, alpha, zeta, epsilon, epsilon_beta, epsilon_gamma, epsilon_W, epsilon_alpha, epsilon_zeta, n, J, K )
X |
matrix. The design matrix containing sample-level covariates, one sample per row. |
V |
matrix. The design matrix containing gene-level covariates, one gene per row. |
W |
matrix. The factors of sample-level latent factors. |
beta |
matrix or NULL. The coefficients of X in the regression of mu. |
gamma |
matrix or NULL. The coefficients of V in the regression of mu. |
alpha |
matrix or NULL. The coefficients of W in the regression of mu. |
zeta |
numeric. A vector of log of inverse dispersion parameters. |
epsilon |
nonnegative scalar. Regularization parameter. |
epsilon_beta |
nonnegative scalar. Regularization parameter for beta. |
epsilon_gamma |
nonnegative scalar. Regularization parameter for gamma. |
epsilon_W |
nonnegative scalar. Regularization parameter for W. |
epsilon_alpha |
nonnegative scalar. Regularization parameter for alpha |
epsilon_zeta |
nonnegative scalar. Regularization parameter for zeta. |
n |
integer. Number of samples. |
J |
integer. Number of genes. |
K |
integer. Number of latent factors. |
This is a wrapper around the new() function to create an
instance of class newmodel
. Rarely, the user will need to create a
newmodel
object from scratch, as tipically this is the result of
newFit
.
If any of X
, V
, W
matrices are passed,
n
, J
, and K
are inferred. Alternatively, the user can
specify one or more of n
, J
, and K
.
The regularization parameters can be set by a unique parameter
epsilon
or specific values for the different regularization
parameters can also be provided.
If only epsilon
is specified, the other parameters take the
following values:
epsilon_beta = epsilon/J
epsilon_gamma = epsilon/n
epsilon_W = epsilon/n
epsilon_alpha = epsilon/J
epsilon_zeta = epsilon
We empirically found that large values of epsilon
provide a more
stable estimation of W
.
A call with no argument has the following default values: n =
50
, J = 100
, K = 0
, epsilon=J
.
Although it is possible to create new instances of the class by
calling this function, this is not the most common way of creating
newmodel
objects. The main use of the class is within the
newFit
function.
an object of class newmodel
.
a <- newmodel() numberSamples(a) numberFeatures(a) numberFactors(a)
a <- newmodel() numberSamples(a) numberFeatures(a) numberFactors(a)
Objects of this class store all the values needed to work with a negative binomial model, as described in the vignette. They contain all information to fit a model by penalized maximum likelihood or simulate data from a model.
## S4 method for signature 'newmodel' show(object) ## S4 method for signature 'newmodel' numberSamples(x) ## S4 method for signature 'newmodel' numberFeatures(x) ## S4 method for signature 'newmodel' numberFactors(x) ## S4 method for signature 'newmodel' newX(object) ## S4 method for signature 'newmodel' newV(object) ## S4 method for signature 'newmodel' newLogMu(object) ## S4 method for signature 'newmodel' newMu(object) ## S4 method for signature 'newmodel' newZeta(object) ## S4 method for signature 'newmodel' newPhi(object) ## S4 method for signature 'newmodel' newTheta(object) ## S4 method for signature 'newmodel' newEpsilon_beta(object) ## S4 method for signature 'newmodel' newEpsilon_gamma(object) ## S4 method for signature 'newmodel' newEpsilon_W(object) ## S4 method for signature 'newmodel' newEpsilon_alpha(object) ## S4 method for signature 'newmodel' newEpsilon_zeta(object) ## S4 method for signature 'newmodel' newW(object) ## S4 method for signature 'newmodel' newBeta(object) ## S4 method for signature 'newmodel' newGamma(object) ## S4 method for signature 'newmodel' newAlpha(object)
## S4 method for signature 'newmodel' show(object) ## S4 method for signature 'newmodel' numberSamples(x) ## S4 method for signature 'newmodel' numberFeatures(x) ## S4 method for signature 'newmodel' numberFactors(x) ## S4 method for signature 'newmodel' newX(object) ## S4 method for signature 'newmodel' newV(object) ## S4 method for signature 'newmodel' newLogMu(object) ## S4 method for signature 'newmodel' newMu(object) ## S4 method for signature 'newmodel' newZeta(object) ## S4 method for signature 'newmodel' newPhi(object) ## S4 method for signature 'newmodel' newTheta(object) ## S4 method for signature 'newmodel' newEpsilon_beta(object) ## S4 method for signature 'newmodel' newEpsilon_gamma(object) ## S4 method for signature 'newmodel' newEpsilon_W(object) ## S4 method for signature 'newmodel' newEpsilon_alpha(object) ## S4 method for signature 'newmodel' newEpsilon_zeta(object) ## S4 method for signature 'newmodel' newW(object) ## S4 method for signature 'newmodel' newBeta(object) ## S4 method for signature 'newmodel' newGamma(object) ## S4 method for signature 'newmodel' newAlpha(object)
object |
an object of class |
x |
an object of class |
For the full description of the model see the model vignette.
Internally, the slots are checked so that the matrices are of the
appropriate dimensions: in particular, X
, O
and W
need to have n
rows, V
needs to have J
rows, zeta
must be of length J
.
numberSamples
returns the number of samples;
numberFeatures
returns the number of features;
numberFactors
returns the number of latent factors.
show
: show useful info on the object.
numberSamples
: returns the number of samples.
numberFeatures
: returns the number of features.
numberFactors
: returns the number of latent factors.
newX
: returns the sample-level design matrix for mu.
newV
: returns the gene-level design matrix for mu.
newLogMu
: returns the logarithm of the mean of the non-zero
component.
newMu
: returns the mean of the non-zero component.
newZeta
: returns the log of the inverse of the dispersion
parameter.
newPhi
: returns the dispersion parameter.
newTheta
: returns the inverse of the dispersion parameter.
newEpsilon_beta
: returns the regularization parameters for
beta
.
newEpsilon_gamma
: returns the regularization parameters for
gamma
.
newEpsilon_W
: returns the regularization parameters for
W
.
newEpsilon_alpha
: returns the regularization parameters for
alpha
.
newEpsilon_zeta
: returns the regularization parameters for
zeta
.
newW
: returns the matrix W of inferred sample-level
covariates.
newBeta
: returns the matrix beta of inferred parameters.
newGamma
: returns the matrix gamma of inferred parameters.
newAlpha
: returns the matrix alpha of inferred parameters.
X
matrix. The design matrix containing sample-level covariates, one sample per row.
V
matrix. The design matrix containing gene-level covariates, one gene per row.
X_intercept
logical. TRUE if X contains an intercept.
V_intercept
logical. TRUE if V contains an intercept.
W
matrix. The factors of sample-level latent factors.
beta
matrix or NULL. The coefficients of X in the regression.
gamma
matrix or NULL. The coefficients of V in the regression.
alpha
matrix. The weight of sample-level latent factors.
zeta
numeric. A vector of log of inverse dispersion parameters.
epsilon_beta
nonnegative scalar. Regularization parameter for beta
epsilon_gamma
nonnegative scalar. Regularization parameter for gamma
epsilon_W
nonnegative scalar. Regularization parameter for W
epsilon_alpha
nonnegative scalar. Regularization parameter for alpha
epsilon_zeta
nonnegative scalar. Regularization parameter for zeta
Given an object that describes a matrix of negative binomial distributions, returns the matrix of mean parameters.
newMu(object)
newMu(object)
object |
an object that describes a matrix of negative binomial distributions. |
Note that although the user interface of newFit
requires a J x n matrix, internally this is stored as a n x J matrix (i.e.,
samples in row and genes in column). Hence the parameter matrix returned by
this function is of n x J dimensions.
the matrix of mean parameters
a <- newmodel(n=5, J=10) newMu(a)
a <- newmodel(n=5, J=10) newMu(a)
Given a statistical model with regularization parameters, compute the penalty.
newpenalty(model) ## S4 method for signature 'newmodel' newpenalty(model)
newpenalty(model) ## S4 method for signature 'newmodel' newpenalty(model)
model |
an object that describes a statistical model with regularization parameters. |
The penalty of the model.
newmodel
: return the penalization.
m <- newmodel(K=2) newpenalty(m)
m <- newmodel(K=2) newpenalty(m)
Given an object that describes a matrix of negative binomial negative binomial
distributions, returns the vector of dispersion parameters phi
.
newPhi(object)
newPhi(object)
object |
an object that describes a matrix of negative binomial. distributions. |
the vector of dispersion parameters
a <- newmodel(n=5, J=10) newPhi(a)
a <- newmodel(n=5, J=10) newPhi(a)
Given an object that describes negative binomial distribution, simulate counts from the distribution.
newSim(object, seed, ...) ## S4 method for signature 'newmodel' newSim(object, seed)
newSim(object, seed, ...) ## S4 method for signature 'newmodel' newSim(object, seed)
object |
an object that describes a matrix of negative binomial. |
seed |
an optional integer to specify how the random number generator
should be initialized with a call to |
... |
additional arguments. |
A list with the following elements.
countsthe matrix with the simulated counts.
dataNBthe data simulated from the negative binomial.
dataDropoutsthe data simulated from the binomial process.
zeroFractionthe fraction of zeros.
newmodel
: simulate from a nb distribution.
a <- newmodel(n=5, J=10) newSim(a)
a <- newmodel(n=5, J=10) newSim(a)
Given an object that describes a matrix of negative binomial negative binomial
distributions, returns the vector of inverse dispersion parameters
theta
.
newTheta(object)
newTheta(object)
object |
an object that describes a matrix of negative binomial distributions. |
the vector of inverse dispersion parameters theta
a <- newmodel(n=5, J=10) newTheta(a)
a <- newmodel(n=5, J=10) newTheta(a)
Given an object that describes a matrix of negative binomial distributions, returns the gene-level design matrix for mu
newV(object, ...)
newV(object, ...)
object |
an object that describes a matrix of negative binomial distributions. |
... |
Additional parameters. |
the gene-level design matrix for mu
a <- newmodel(n=5, J=10) newV(a)
a <- newmodel(n=5, J=10) newV(a)
Given an object that contains the fit of a nb-WaVE model, returns the
matrix W
of low-dimensional matrix of inferred sample-level
covariates.
newW(object)
newW(object)
object |
the matrix W
of inferred sample-level covariates.
a <- newmodel(n=5, J=10) newW(a)
a <- newmodel(n=5, J=10) newW(a)
Given an object with the data, it performs dimensionality reduction using a nb regression model with gene and cell-level covariates.
newWave(Y, ...) ## S4 method for signature 'SummarizedExperiment' newWave( Y, X, V, K = 2, which_assay, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... )
newWave(Y, ...) ## S4 method for signature 'SummarizedExperiment' newWave( Y, X, V, K = 2, which_assay, commondispersion = TRUE, verbose = FALSE, maxiter_optimize = 100, stop_epsilon = 1e-04, children = 1, random_init = FALSE, random_start = FALSE, n_gene_disp = NULL, n_cell_par = NULL, n_gene_par = NULL, ... )
Y |
The SummarizedExperiment with the data |
... |
Additional parameters to describe the model, see
|
X |
The design matrix containing sample-level covariates, one sample per row. If missing, X will contain only an intercept. If Y is a SummarizedExperiment object, X can be a formula using the variables in the colData slot of Y. |
V |
The design matrix containing gene-level covariates, one gene per row. If missing, V will contain only an intercept. If Y is a SummarizedExperiment object, V can be a formula using the variables in the rowData slot of Y. |
K |
integer. Number of latent factors(default 2). |
which_assay |
numeric or character. Which assay of Y to use. If missing, if 'assayNames(Y)' contains "counts" then that is used. Otherwise, the first assay is used. |
commondispersion |
Whether or not a single dispersion for all features is estimated (default TRUE). |
verbose |
Print helpful messages(default FALSE). |
maxiter_optimize |
maximum number of iterations for the optimization step (default 100). |
stop_epsilon |
stopping criterion in the optimization step, when the relative gain in likelihood is below epsilon (default 0.0001). |
children |
number of cores of the used cluster(default 1) |
random_init |
if TRUE no initializations is done(default FALSE) |
random_start |
if TRUE the setup of parameters is a random samplig (default FALSE) |
n_gene_disp |
number of genes used in mini-batch dispersion estimation approach(default NULL > all genes are used) |
n_cell_par |
number of cells used in mini-batch cells related parameters estimation approach(default NULL > all cells are used) |
n_gene_par |
number of genes used in mini-batch genes related parameters estimation approach(default NULL > all genes are used) |
For visualization (heatmaps, ...), please use the normalized values.
It corresponds to the deviance residuals when the W
is not included
in the model but the gene and cell-level covariates are. As a results, when
W
is not included in the model, the deviance residuals should capture
the biology. Note that we do not recommend to use the normalized values for
any downstream analysis (such as clustering, or differential expression),
but only for visualization.
If one has already fitted a model using newmodel
,
the object containing such model can be used as input of newWave
to
save the resulting W into a SummarizedExperiment
and optionally
compute residuals and normalized values, without the need for re-fitting the
model.
By default newWave
uses all genes to estimate W
.
However, we recommend to use the top 1,000 most variable genes for this
step. In general, a user can specify any custom set of genes to be used to
estimate W
, by specifying either a vector of gene names, or a
single character string corresponding to a column of the rowData
.
Note that if both which_genes
is specified and at least one
among observationalWeights
, imputedValues
, residuals
,
and normalizedValues
is TRUE
, the model needs to be fit
twice.
An object of class SingleCellExperiment
; the dimensionality
reduced matrix is stored in the reducedDims
slot and optionally
normalized values and residuals are added in the list of assays.
SummarizedExperiment
: Y is a
SummarizedExperiment
.
se <- SummarizedExperiment(matrix(rpois(60, lambda=5), nrow=10, ncol=6), colData = data.frame(bio = gl(2, 3))) m <- newWave(se, X="~bio")
se <- SummarizedExperiment(matrix(rpois(60, lambda=5), nrow=10, ncol=6), colData = data.frame(bio = gl(2, 3))) m <- newWave(se, X="~bio")
Given an object that describes a matrix of negative binomial distributions, returns the sample-level design matrix for mu
newX(object, ...)
newX(object, ...)
object |
an object that describes a matrix of negative binomial distributions. |
... |
Additional parameters. |
the sample-level design matrix for mu
a <- newmodel(n=5, J=10) newX(a)
a <- newmodel(n=5, J=10) newX(a)
Given an object that describes a matrix of negative binomial negative binomial
distributions, returns the vector zeta
of log of inverse dispersion
parameters
newZeta(object)
newZeta(object)
object |
an object that describes a matrix of negative binomial distributions. |
the vector zeta
of log of inverse dispersion parameters
a <- newmodel(n=5, J=10) newZeta(a)
a <- newmodel(n=5, J=10) newZeta(a)
Given an object that describes a dataset or a model involving latent factors, this function returns the number of latent factors.
numberFactors(x)
numberFactors(x)
x |
an object that describes a dataset or a model involving latent factors |
the number of latent factors
a <- newmodel(n=5, J=10) numberFactors(a)
a <- newmodel(n=5, J=10) numberFactors(a)
Given an object that describes a dataset or a model involving features, this function returns the number of features
Given an object that describes a dataset or a model, it returns the number of features.
numberFeatures(x) numberFeatures(x)
numberFeatures(x) numberFeatures(x)
x |
an object that describes a dataset or a model. |
the number of features
the number of features.
a <- newmodel(n=5, J=10) numberFeatures(a) a <- newmodel(n=5, J=10) numberFeatures(a)
a <- newmodel(n=5, J=10) numberFeatures(a) a <- newmodel(n=5, J=10) numberFeatures(a)
Given an object that describes a model or a dataset, it returns total number of parameters of the model.
numberParams(model) ## S4 method for signature 'newmodel' numberParams(model)
numberParams(model) ## S4 method for signature 'newmodel' numberParams(model)
model |
an object that describes a dataset or a model. |
the total number of parameters of the model.
numberParams,newmodel-method
: returns the total number of parameters in the model.
a <- newmodel(n=5, J=10) numberParams(a)
a <- newmodel(n=5, J=10) numberParams(a)
Given an object that describes a dataset or a model involving samples, this function returns the number of samples.
Given an object that describes a model or a dataset, it returns the number of samples.
numberSamples(x) numberSamples(x)
numberSamples(x) numberSamples(x)
x |
an object that describes a dataset or a model. |
the number of samples
the number of samples.
a <- newmodel(n=5, J=10) numberSamples(a) a <- newmodel(n=5, J=10) numberSamples(a)
a <- newmodel(n=5, J=10) numberSamples(a) a <- newmodel(n=5, J=10) numberSamples(a)