@@ -2102,11 +2102,13 @@ def __init__(
21022102 self .grouping = grouping
21032103 self .groups = list (np .asarray (groups ))
21042104
2105- # values of parameter estimates: coefficients x genes array with one coefficient per group
2105+ # Values of parameter estimates: coefficients x genes array with one coefficient per group
21062106 self ._theta_mle = model_estim .a_var
2107- # standard deviation of estimates: coefficients x genes array with one coefficient per group
2108- # theta_sd = sqrt(diagonal(fisher_inv))
2109- self ._theta_sd = np .sqrt (np .diagonal (model_estim .fisher_inv , axis1 = - 2 , axis2 = - 1 )).T
2107+ # Standard deviation of estimates: coefficients x genes array with one coefficient per group
2108+ # Need .copy() here as nextafter needs mutabls copy.
2109+ theta_sd = np .diagonal (model_estim .fisher_inv , axis1 = - 2 , axis2 = - 1 ).T .copy ()
2110+ theta_sd = np .nextafter (0 , np .inf , out = theta_sd , where = theta_sd < np .nextafter (0 , np .inf ))
2111+ self ._theta_sd = np .sqrt (theta_sd )
21102112 self ._logfc = None
21112113
21122114 # Call tests in constructor.
@@ -2307,11 +2309,13 @@ def __init__(
23072309 else :
23082310 self .groups = groups .tolist ()
23092311
2310- # values of parameter estimates: coefficients x genes array with one coefficient per group
2312+ # Values of parameter estimates: coefficients x genes array with one coefficient per group
23112313 self ._theta_mle = model_estim .a_var
2312- # standard deviation of estimates: coefficients x genes array with one coefficient per group
2313- # theta_sd = sqrt(diagonal(fisher_inv))
2314- self ._theta_sd = np .sqrt (np .diagonal (model_estim .fisher_inv , axis1 = - 2 , axis2 = - 1 )).T
2314+ # Standard deviation of estimates: coefficients x genes array with one coefficient per group
2315+ # Need .copy() here as nextafter needs mutabls copy.
2316+ theta_sd = np .diagonal (model_estim .fisher_inv , axis1 = - 2 , axis2 = - 1 ).T .copy ()
2317+ theta_sd = np .nextafter (0 , np .inf , out = theta_sd , where = theta_sd < np .nextafter (0 , np .inf ))
2318+ self ._theta_sd = np .sqrt (theta_sd )
23152319
23162320 def _correction (self , pvals , method = "fdr_bh" ) -> np .ndarray :
23172321 """
0 commit comments