API
Bayesian models
scBayesDeconv.finiteGaussianMixture — FunctionfiniteGaussianMixture(X::Matrix;
k::Int,
initialization::Union{String,Matrix} = "kmeans",
α = 1,
ν0 = 1,
κ0 = 0.001,
μ0 = nothing,
Σ0 = nothing,
ignoreSteps::Int = 1000,
saveSteps::Int = 1000,
saveEach::Int = 10,
verbose = false
)Function to fit a finite mixture model to data.
Arguments:
- X::Matrix: Matrix with data to be fitted as (realizations, dimensions).
Keyword Arguments:
- k::Int: Number of components of the mixture.
- initialization::Union{String,Matrix} = "kmeans": Method to initializate the mixture parameters.
- α = 1: Hyperparameter of the Dirichlet distribution. The higher, the more probable that a cell will be assigned to another distribution.
- ν0 = 1: Hyperparameter of the InverseWishart distribution. The highler, the more wight has the pior InverseWishart.
- κ0 = 0.001: Hyperparameter of the Normal prior distribution. The higher, the more focussed will be the prior Normal around the mean.
- μ0 = nothing: Hyperparameter of indicating the mean of the Normal. If nothing it will be estimated.
- Σ0 = nothing: Hyperparameter indicating the prior Covariance distribution of the model. If nothing it will be estimated.
- ignoreSteps::Int = 1000: Number of steps to perform before saving realizations.
- saveSteps::Int = 1000: Number of steps to perform from which we will save samples.
- saveEach::Int = 10: Number of steps to take before saving a sample.
- verbose = false: Is to show progress of the fitting.
- seed = 0: Seed of the random generator.
Return
A GaussianFiniteMixtureModel with the sampling of the bayesian model.
scBayesDeconv.infiniteGaussianMixture — FunctioninfiniteGaussianMixture(X::Matrix;
k::Int,
initialization::Union{String,Matrix} = "kmeans",
α = 1,
ν0 = 1,
κ0 = 0.001,
μ0 = nothing,
Σ0 = nothing,
ignoreSteps::Int = 1000,
saveSteps::Int = 1000,
saveEach::Int = 10,
verbose = false,
seed = 0
)Function to fit a infinite mixture model to data.
Arguments:
- X::Matrix: Matrix with data to be fitted as (realizations, dimensions).
Keyword Arguments:
- k::Int: Number of components of the mixture to start with.
- initialization::Union{String,Matrix} = "kmeans": Method to initializate the mixture parameters.
- α = 1: Hyperparameter of the Dirichlet distribution. The higher, the more probable that a cell will be assigned to another distribution.
- ν0 = 1: Hyperparameter of the InverseWishart distribution. The highler, the more wight has the pior InverseWishart.
- κ0 = 0.001: Hyperparameter of the Normal prior distribution. The higher, the more focussed will be the prior Normal around the mean.
- μ0 = nothing: Hyperparameter of indicating the mean of the Normal. If nothing it will be estimated.
- Σ0 = nothing: Hyperparameter indicating the prior Covariance distribution of the model. If nothing it will be estimated.
- ignoreSteps::Int = 1000: Number of steps to perform before saving realizations.
- saveSteps::Int = 1000: Number of steps to perform from which we will save samples.
- saveEach::Int = 10: Number of steps to take before saving a sample.
- verbose = false: Is to show progress of the fitting.
- seed = 0: Seed of the random generator.
Return
A GaussianInfiniteMixtureModel with the sampling of the bayesian model.
scBayesDeconv.finiteGaussianMixtureDeconvolution — FunctionfiniteGaussianMixtureDeconvolution(X::Matrix, Y::GaussianFiniteMixtureModel;
k::Int,
initialization::Union{String,Matrix} = "kmeans",
α = 1,
ν0 = 1,
κ0 = 0.001,
μ0 = nothing,
Σ0 = nothing,
ignoreSteps::Int = 1000,
saveSteps::Int = 1000,
saveEach::Int = 10,
verbose = false,
seed = 0
)Function to fit a convolved finite mixture model to data.
Arguments:
- X::Matrix: Matrix with data to be fitted as (realizations, dimensions).
- Y::GaussianFiniteMixtureModel: Mixture model used to fit the noise of the convolution.
Keyword Arguments:
- k::Int: Number of components of the mixture of the target.
- initialization::Union{String,Matrix} = "kmeans": Method to initializate the mixture parameters.
- α = 1: Hyperparameter of the Dirichlet distribution. The higher, the more probable that a cell will be assigned to another distribution.
- ν0 = 1: Hyperparameter of the InverseWishart distribution. The highler, the more wight has the pior InverseWishart.
- κ0 = 0.001: Hyperparameter of the Normal prior distribution. The higher, the more focussed will be the prior Normal around the mean.
- μ0 = nothing: Hyperparameter of indicating the mean of the Normal. If nothing it will be estimated.
- Σ0 = nothing: Hyperparameter indicating the prior Covariance distribution of the model. If nothing it will be estimated.
- ignoreSteps::Int = 1000: Number of steps to perform before saving realizations.
- saveSteps::Int = 1000: Number of steps to perform from which we will save samples.
- saveEach::Int = 10: Number of steps to take before saving a sample.
- verbose = false: Is to show progress of the fitting.
- seed = 0: Seed of the random generator.
Return
A GaussianFiniteMixtureModelDeconvolved with the sampling of the bayesian model.
scBayesDeconv.infiniteGaussianMixtureDeconvolution — FunctioninfiniteGaussianMixtureDeconvolution(X::Matrix, Y::GaussianMixtureModel;
k::Int,
initialization::Union{String,Matrix} = "kmeans",
α = 1,
ν0 = 1,
κ0 = 0.001,
μ0 = nothing,
Σ0 = nothing,
ignoreSteps::Int = 1000,
saveSteps::Int = 1000,
saveEach::Int = 10,
verbose = false,
seed = 0,
prune = 0.1
)Function to fit a convolved finite mixture model to data.
Arguments:
- X::Matrix: Matrix with data to be fitted as (realizations, dimensions).
- Y::GaussianMixtureModel: Mixture model used to fit the noise of the convolution.
Keyword Arguments:
- k::Int: Number of components of the mixture to start with.
- initialization::Union{String,Matrix} = "kmeans": Method to initializate the mixture parameters.
- α = 1: Hyperparameter of the Dirichlet distribution. The higher, the more probable that a cell will be assigned to another distribution.
- ν0 = 1: Hyperparameter of the InverseWishart distribution. The highler, the more wight has the pior InverseWishart.
- κ0 = 0.001: Hyperparameter of the Normal prior distribution. The higher, the more focussed will be the prior Normal around the mean.
- μ0 = nothing: Hyperparameter of indicating the mean of the Normal. If nothing it will be estimated.
- Σ0 = nothing: Hyperparameter indicating the prior Covariance distribution of the model. If nothing it will be estimated.
- ignoreSteps::Int = 1000: Number of steps to perform before saving realizations.
- saveSteps::Int = 1000: Number of steps to perform from which we will save samples.
- saveEach::Int = 10: Number of steps to take before saving a sample.
- verbose = false: Is to show progress of the fitting.
- seed = 0: Seed of the random generator.
- prune = 0.1: Cutoff to remove any basis from the noise distribution that is below this weight.
As infinite mixtures may have many basis that are only allocated to ver few cells (starting clusters) during the creation of new clusters, they do not realy contribute to the effective distribution but increase substantially the number of call to the likelihood function that is one of the most costly steps. Pruning unimportant basis can highly reduce the computation of the convolved model.
Return
A GaussianInfiniteMixtureModelDeconvolved with the sampling of the bayesian model.
Other deconvolution models
scBayesDeconv.neumannDeconvolution — Functionfunction neumannDeconvolution(noise::Matrix,conv::Matrix,d1=1,d2=1,dw=0.01,w_lims=[-100,100],dx=0.01,x_lims=[-100,100],cut_off=true)Fast-Fourier method for the deconvolution of two distributions as proposed by Neumann & Hössjer. This method as implemented only works for 1D distributions.
Arguments:
- noise::Matrix: Autofluorescence data of size (NSamples,1).
- conv::Matrix: Convolution data of size (NSamples,1).
- d1=1: Weight of the estimation of the frequencies to be removed based on the size of the data.
- d2=1: Weight of the estimation of the frequencies to be removed based on the size of the data.
- dw=0.01: Width of the frequency sampling.
- w_lims=[-100,100]: Limits of the frequency domain.
- dx=0.01: Width of the spatial sampling.
- x_lims=[-100,100]: Limits of the spatial domain.
- cut_off=true: If to use the cutoff of the frequencies (in the original method this is true).
Returns:
Deconvolved signal, Points of the deconvolved signal determined by x_lims and dx.
Metrics
MISE
Is the Mean Integrated Squared Error metric defined as
$MISE = \int (f_2(\bm{x})-f_1(\bm{x}))^2 d\bm{x}$
scBayesDeconv.metrics.mise — Functionfunction mise(model::GaussianMixtureModel,f2;box=[-100. 100.],d=.1,samples=1:length(model.samples))Function to compute the Mean Integrated Squared error of between two distributions.
Arguments:
- model::BayesianMixtureModel: Bayesian Mixture Model from which to draw samples.
- f: Distribution against which to compare the model samples.
Keyword Args:
- box=[-100. 100.]: Matrix with box of integration with (min max) in columns and dimensions in rows.
- d=.1: Width of integration steps.
- samples=1:length(model.samples): Samples from which to draw from the Bayesian model to compare agains the function.
Return
The MISE values for each iteration.
function mise(f1,f2;box,d)Function to compute the Mean Integrated Squared error of between two distributions.
Arguments:
- f1: Distribution 1.
- f2: Distribution 2.
Keyword Args:
- box: Matrix with box of integration with (min max) in columns and dimensions in rows.
- d: Width of integration steps.
Return
The MISE value.
MISE
Is the Mean Integrated Overlap metric defined as
$MIO = 1 - \frac{1}{2}\int |f_2(\bm{x})-f_1(\bm{x})| d\bm{x}$
which makes de metric bounded as $MIO \in(0,1)$, being 1 is the distributions overlap perfectly and zero is there is no overlap in the domain at all.
scBayesDeconv.metrics.mio — Functionfunction mio(model1::GaussianMixtureModel,model2::GaussianMixtureModel;
box=[-100. 100.],d=.1,samples1=1:length(model1.samples),samples2=1:length(model2.samples),nSamples=100)Function to compute the Mean Integrated Overlap error of between two bayesian mixture deconvolutions.
Arguments:
- model1::BayesianMixtureModel: Bayesian Mixture Model from which to draw samples.
- model2::BayesianMixtureModel: Bayesian Mixture Model from which to draw samples.
Keyword Args:
- box=[-100. 100.]: Matrix with box of integration with (min max) in columns and dimensions in rows.
- d=.1: Width of integration steps.
- samples1=1:length(model.samples): Samples from which to draw from the Bayesian model to compare agains the function.
- samples2=1:length(model.samples): Number of samples to draw from the Bayesian model to compare agains the function.
- nSamples=100: number of samples to draw from the distributions.
Return
The MIO values for each random sample.
function mio(model::GaussianMixtureModel,f2;box=[-100. 100.],d=.1,samples=1:length(model.samples))Function to compute the Mean Integrated Overlap error of between a Bayesian Mixture Model and a distribution.
Arguments:
- model::BayesianMixtureModel: Bayesian Mixture Model from which to draw samples.
- f2: Bayesian Mixture Model from which to draw samples.
Keyword Args:
- box=[-100. 100.]: Matrix with box of integration with (min max) in columns and dimensions in rows.
- d=.1: Width of integration steps.
- samples=1:length(model.samples): Samples from which to draw from the Bayesian model to compare agains the function.
Return
The MIO value for each sample.
function mio(f1,f2;box,d)Function to compute the Mean Integrated Squared error of between two distributions.
Arguments:
- f1: Distribution 1.
- f2: Distribution 2.
Keyword Args:
- box=[-100. 100.]: Matrix with box of integration with (min max) in columns and dimensions in rows.
- d=.1: Width of integration steps.
Return:
The mio value.