RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
77 stars 29 forks source link

Errors in compensate() function #153

Closed aarzalluz closed 6 years ago

aarzalluz commented 7 years ago

I am manually calculating a spillover matrix using single staining fcs files, and then using this matrix as input for the compensate() function, together the flowSet containing my data (as indicated in the openCyto vignettes). I'm doing the following calls, where ss_flowSet and samp_flowSet are the flowSets containing single stainings and samples.

comp_matrix <- spillover(ss_flowSet, unstained = 1, stain_match = "ordered") comp_samples <- compensate(samp_flowSet, comp_matrix)

And I get the following error:

Error in solve.default(t(spillover)) : system is computationally singular: reciprocal condition number = 4.7006e-42

If I perform the spillover computations using the mean instead of the median, I get another error from the solve.default() function:

Error in solve.default(t(spillover)) : Lapack routine dgesv: system is exactly singular: U[8,8] = 0

Apparently both result from providing it with a singular (i.e. not invertible) spillover matrix. Is there any way around this? Could it be fixed by tweeking the tolerance in the Rbase solve() function?

Thanks in advance.

gfinak commented 7 years ago

I suggest you look carefully at the gating of the positive populations in your single stain controls. These types of problems are usually indicative of problems with the data more than problems with the methods.

aarzalluz commented 7 years ago

Thank you very much for your input. However, since the single-staining .fcs files have already been generated, I see no way around it that can allow me to use the compensate() function directly for compensation. Do you know of any workflow in R to do compensation in a semi-unsupervised or manual manner?

gfinak commented 7 years ago

Plot the compensation controls, verify that the subsets selected by compensate() are accurate. Maybe consider pregating, or not. I don't really have specific advice. Just try to get to the bottom of why your compensation matrix is singular.