@@ -1555,13 +1555,13 @@ def __init__(
1555
1555
mean_x0 = np .asarray (np .mean (x0 , axis = 0 )).flatten ().astype (dtype = np .float )
1556
1556
mean_x1 = np .asarray (np .mean (x1 , axis = 0 )).flatten ().astype (dtype = np .float )
1557
1557
# Avoid unnecessary mean computation:
1558
- self ._mean = np .average (
1558
+ self ._mean = np .asarray ( np . average (
1559
1559
a = np .vstack ([mean_x0 , mean_x1 ]),
1560
1560
weights = np .array ([x0 .shape [0 ] / (x0 .shape [0 ] + x1 .shape [0 ]),
1561
1561
x1 .shape [0 ] / (x0 .shape [0 ] + x1 .shape [0 ])]),
1562
1562
axis = 0 ,
1563
1563
returned = False
1564
- )
1564
+ )). flatten ()
1565
1565
self ._ave_nonzero = self ._mean != 0 # omit all-zero features
1566
1566
if isinstance (x0 , scipy .sparse .csr_matrix ):
1567
1567
# Efficient analytic expression of variance without densification.
@@ -1603,6 +1603,8 @@ def __init__(
1603
1603
if is_logged :
1604
1604
self ._logfc = mean_x1 - mean_x0
1605
1605
else :
1606
+ mean_x0 = np .nextafter (0 , np .inf , out = mean_x0 , where = mean_x0 < np .nextafter (0 , np .inf ))
1607
+ mean_x1 = np .nextafter (0 , np .inf , out = mean_x1 , where = mean_x1 < np .nextafter (0 , np .inf ))
1606
1608
self ._logfc = np .log (mean_x1 ) - np .log (mean_x0 )
1607
1609
1608
1610
@property
@@ -1679,13 +1681,13 @@ def __init__(
1679
1681
mean_x0 = np .asarray (np .mean (x0 , axis = 0 )).flatten ().astype (dtype = np .float )
1680
1682
mean_x1 = np .asarray (np .mean (x1 , axis = 0 )).flatten ().astype (dtype = np .float )
1681
1683
# Avoid unnecessary mean computation:
1682
- self ._mean = np .average (
1684
+ self ._mean = np .asarray ( np . average (
1683
1685
a = np .vstack ([mean_x0 , mean_x1 ]),
1684
1686
weights = np .array ([x0 .shape [0 ] / (x0 .shape [0 ] + x1 .shape [0 ]),
1685
1687
x1 .shape [0 ] / (x0 .shape [0 ] + x1 .shape [0 ])]),
1686
1688
axis = 0 ,
1687
1689
returned = False
1688
- )
1690
+ )). flatten ()
1689
1691
if isinstance (x0 , scipy .sparse .csr_matrix ):
1690
1692
# Efficient analytic expression of variance without densification.
1691
1693
var_x0 = np .asarray (np .mean (x0 .power (2 ), axis = 0 )).flatten ().astype (dtype = np .float ) - np .square (mean_x0 )
@@ -1724,6 +1726,8 @@ def __init__(
1724
1726
if is_logged :
1725
1727
self ._logfc = mean_x1 - mean_x0
1726
1728
else :
1729
+ mean_x0 = np .nextafter (0 , np .inf , out = mean_x0 , where = mean_x0 < np .nextafter (0 , np .inf ))
1730
+ mean_x1 = np .nextafter (0 , np .inf , out = mean_x1 , where = mean_x1 < np .nextafter (0 , np .inf ))
1727
1731
self ._logfc = np .log (mean_x1 ) - np .log (mean_x0 )
1728
1732
1729
1733
@property
@@ -1881,7 +1885,7 @@ def __init__(self, gene_ids, pval, logfc, ave, groups, tests, correction_type: s
1881
1885
self ._gene_ids = np .asarray (gene_ids )
1882
1886
self ._logfc = logfc
1883
1887
self ._pval = pval
1884
- self ._mean = ave
1888
+ self ._mean = np . asarray ( ave ). flatten ()
1885
1889
self .groups = list (np .asarray (groups ))
1886
1890
self ._tests = tests
1887
1891
@@ -2673,7 +2677,7 @@ def __init__(
2673
2677
self ._gene_ids = np .asarray (gene_ids )
2674
2678
self ._pval = pval
2675
2679
self ._logfc = logfc
2676
- self ._mean = ave
2680
+ self ._mean = np . asarray ( ave ). flatten ()
2677
2681
self .groups = list (np .asarray (groups ))
2678
2682
self ._tests = tests
2679
2683
@@ -2794,7 +2798,7 @@ def __init__(self, partitions, tests, ave, correction_type: str = "by_test"):
2794
2798
self ._gene_ids = tests [0 ].gene_ids
2795
2799
self ._pval = np .expand_dims (np .vstack ([x .pval for x in tests ]), axis = 0 )
2796
2800
self ._logfc = np .expand_dims (np .vstack ([x .log_fold_change () for x in tests ]), axis = 0 )
2797
- self ._mean = ave
2801
+ self ._mean = np . asarray ( ave ). flatten ()
2798
2802
2799
2803
_ = self .qval
2800
2804
0 commit comments