pachterlab / voyager

From geospatial to spatial -omics
https://pachterlab.github.io/voyager/
Artistic License 2.0
79 stars 9 forks source link

Errors in calculateBivariate:check_Ops_vector_arg_length(e, x_nrow, e_what = e_what, x_what = x_what): when the right operand is not a DelayedArray object (or derivative), its length cannot be greater than the first dimension of the left operand #37

Closed huiyijiangling closed 3 months ago

huiyijiangling commented 4 months ago

image

lambdamoses commented 4 months ago

Sorry for the late reply since I was traveling. This is a known issue when the gene count matrix is a DelayedArray, buried deep inside DelayedArray's binary arithmetic operators. I'm not sure what to do about it for now. Quick and dirty fix: something like logcounts(sfe) <- as(logcounts(sfe), "CsparseMatrix"). I may try adding something before this line for a more permanent fix: https://github.com/pachterlab/voyager/blob/27944de52b5fc4ecca06b03eb56f887ef28ba498/R/SFEMethod-bivariate.R#L22

lambdamoses commented 3 months ago

I finally got a chance to look into it. Turns out the problem is much simpler. The base version of the sweep function is called here, which can't handle DelayedArray. Now in the updated code, DelayedArray's sweep method is called (simply imported it so it can be found), and it works. Nothing to do with weird ways DelayedArray handles binary arithmetic operations; that arose because of the way the base version of sweep preprocesses the data.