netZoo / netZooPy

netZooPy is a network biology package implemented in Python.
https://netzoo.github.io/
GNU General Public License v3.0
76 stars 34 forks source link

Singular shrunken covariance matrix in DRAGON #302

Open katehoffshutta opened 1 year ago

katehoffshutta commented 1 year ago

The DRAGON precision matrix is the inverse of the shrunken covariance (1-lambda)S + lambdaT where T is the target matrix of covariances on the diagonal and should be full rank. However, we do not currently have a check to see if T is full rank. If any of the variables have zero variance, (1-lambda)S + lambdaT can be singular. DRAGON will not recognize this problem; it will try to invert the matrix and the numpy.linalg matrix inversion function will throw an exception that is unclear.

I plan to handle this by adding default behavior that any variables with zero variance are excluded from the analysis and a note warning of the excluded variables is printed to the console.

I also will add a try-catch on the rank of (1-lambda)S + lambdaT so that DRAGON provides an informative exception before it can percolate down to numpy.linalg.

katehoffshutta commented 1 year ago

Note that this can also occur in LIONESS-DRAGON. I will implement similar fixes here.

violafanfani commented 12 months ago

Ehi Kate, is this still something you will work on in the future? I assigned it both a bug and an enhancement label for now

katehoffshutta commented 12 months ago

Thanks, Viola - this is accurate. We will try to get this in for the next release.