kuwisdelu / Cardinal

Mass spectrometry imaging toolbox
http://www.cardinalmsi.org
Artistic License 2.0
42 stars 14 forks source link

spatialDGMM fails to converge (loops indefinitely?) if mass intensity is constant within group #16

Closed bentyeh closed 6 months ago

bentyeh commented 4 years ago
library(Cardinal)
set.seed(20)
mse <- Cardinal::simulateImage(preset = 1, npeaks = 3, dim = c(5, 5), nruns = 2)

# this works
result <- Cardinal::spatialDGMM(mse)

# if we fix the intensity of a mass to a constant value within a run, ...
Cardinal::spectra(mse)[1, Cardinal::run(mse) == "run0"] <- 10

# then this will stall (fail to converge)
Cardinal::spatialDGMM(mse)

Consider a dataset where 3 sections belong to a control condition and 3 sections belong to an experimental condition with a gene knocked out, such that metabolite X is no longer detected in those sections (i.e., the intensity across those sections is 0).

We could filter out m/z values that are constant within any section before running Cardinal::spatialDGMM(), but ideally the statistical model should capture the differential abundance signal of metabolite X between the control and experimental condition.