SydneyBioX/scMerge

SEG random initialisation error

kevinwang09 opened this issue · 1 comments

SEG computation will occasionally throw up an error because of the random initialisation of the z variable:

z = stats::rbinom(n, 1, 0.5)

Due to random chances, z could be a sequence of zeroes. This creates a problem of division by zero here:

mu_iter = sum(z_iter * x)/sum(z_iter)

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

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

if(sum(z) == 0){z[1] = 1} ## Break out of a sequence of zeroes error

More tests might be necessary in the future.