SydneyBioX / scMerge

Statistical approach for removing unwanted variation from multiple single-cell datasets
https://sydneybiox.github.io/scMerge/
66 stars 13 forks source link

SEG random initialisation error #23

Closed kevinwang09 closed 4 years ago

kevinwang09 commented 4 years ago

SEG computation will occasionally throw up an error because of the random initialisation of the z variable: https://github.com/SydneyBioX/scMerge/blob/98a362c7c94b0f45c0173292c56fcf9c0e30dd87/R/scSEGIndex.R#L221

Due to random chances, z could be a sequence of zeroes. This creates a problem of division by zero here: https://github.com/SydneyBioX/scMerge/blob/98a362c7c94b0f45c0173292c56fcf9c0e30dd87/R/scSEGIndex.R#L252

As such, this breaks the while condition in line 235.

kevinwang09 commented 4 years ago

This issue seems to be fixed by forcing a 1 in the first position of a sequence of all zeroes.

https://github.com/SydneyBioX/scMerge/blob/9f572c7c792383bb17bd9ce79ccca8d1dd097932/R/scSEGIndex.R#L222

More tests might be necessary in the future.