@@ -669,6 +669,7 @@ def t_test(
669
669
gene_names : Union [np .ndarray , list ] = None ,
670
670
sample_description : pd .DataFrame = None ,
671
671
is_logged : bool = False ,
672
+ is_sig_zerovar : bool = True ,
672
673
dtype = "float64"
673
674
):
674
675
"""
@@ -686,6 +687,9 @@ def t_test(
686
687
:param is_logged:
687
688
Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
688
689
If False, log-fold changes are computed as log-fold changes on this data.
690
+ :param is_sig_zerovar:
691
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
692
+ the p-value is set to np.nan.
689
693
"""
690
694
gene_names = parse_gene_names (data , gene_names )
691
695
X = parse_data (data , gene_names )
@@ -698,7 +702,8 @@ def t_test(
698
702
sample_description = sample_description ,
699
703
grouping = grouping ,
700
704
gene_names = gene_names ,
701
- is_logged = is_logged
705
+ is_logged = is_logged ,
706
+ is_sig_zerovar = is_sig_zerovar
702
707
)
703
708
704
709
return de_test
@@ -709,7 +714,8 @@ def rank_test(
709
714
grouping : Union [str , np .ndarray , list ],
710
715
gene_names : Union [np .ndarray , list ] = None ,
711
716
sample_description : pd .DataFrame = None ,
712
- is_logged = False ,
717
+ is_logged : bool = False ,
718
+ is_sig_zerovar : bool = True ,
713
719
dtype = "float64"
714
720
):
715
721
"""
@@ -727,6 +733,9 @@ def rank_test(
727
733
:param is_logged:
728
734
Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
729
735
If False, log-fold changes are computed as log-fold changes on this data.
736
+ :param is_sig_zerovar:
737
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
738
+ the p-value is set to np.nan.
730
739
"""
731
740
gene_names = parse_gene_names (data , gene_names )
732
741
X = parse_data (data , gene_names )
@@ -739,7 +748,8 @@ def rank_test(
739
748
sample_description = sample_description ,
740
749
grouping = grouping ,
741
750
gene_names = gene_names ,
742
- is_logged = is_logged
751
+ is_logged = is_logged ,
752
+ is_sig_zerovar = is_sig_zerovar
743
753
)
744
754
745
755
return de_test
@@ -756,6 +766,7 @@ def two_sample(
756
766
size_factors : np .ndarray = None ,
757
767
batch_size : int = None ,
758
768
training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
769
+ is_sig_zerovar : bool = True ,
759
770
quick_scale : bool = None ,
760
771
dtype = "float64" ,
761
772
** kwargs
@@ -824,6 +835,9 @@ def two_sample(
824
835
`training_strategy(estimator)`.
825
836
- list of keyword dicts containing method arguments: Will call Estimator.train() once with each dict of
826
837
method arguments.
838
+ :param is_sig_zerovar:
839
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
840
+ the p-value is set to np.nan.
827
841
:param quick_scale: Depending on the optimizer, `scale` will be fitted faster and maybe less accurate.
828
842
829
843
Useful in scenarios where fitting the exact `scale` is not absolutely necessary.
@@ -898,13 +912,15 @@ def two_sample(
898
912
data = X ,
899
913
gene_names = gene_names ,
900
914
grouping = grouping ,
915
+ is_sig_zerovar = is_sig_zerovar ,
901
916
dtype = dtype
902
917
)
903
918
elif test .lower () == 'rank' :
904
919
de_test = rank_test (
905
920
data = X ,
906
921
gene_names = gene_names ,
907
922
grouping = grouping ,
923
+ is_sig_zerovar = is_sig_zerovar ,
908
924
dtype = dtype
909
925
)
910
926
else :
@@ -925,6 +941,7 @@ def pairwise(
925
941
size_factors : np .ndarray = None ,
926
942
batch_size : int = None ,
927
943
training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
944
+ is_sig_zerovar : bool = True ,
928
945
quick_scale : bool = None ,
929
946
dtype = "float64" ,
930
947
pval_correction : str = "global" ,
@@ -1016,7 +1033,10 @@ def pairwise(
1016
1033
1017
1034
- "global": correct all p-values in one operation
1018
1035
- "by_test": correct the p-values of each test individually
1019
- :param keep_full_test_objs: [Debugging] keep the individual test objects; currently valid for test != "z-test"
1036
+ :param keep_full_test_objs: [Debugging] keep the individual test objects; currently valid for test != "z-test".
1037
+ :param is_sig_zerovar:
1038
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
1039
+ the p-value is set to np.nan.
1020
1040
:param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
1021
1041
"""
1022
1042
if len (kwargs ) != 0 :
@@ -1096,6 +1116,7 @@ def pairwise(
1096
1116
batch_size = batch_size ,
1097
1117
training_strategy = training_strategy ,
1098
1118
quick_scale = quick_scale ,
1119
+ is_sig_zerovar = is_sig_zerovar ,
1099
1120
dtype = dtype ,
1100
1121
** kwargs
1101
1122
)
@@ -1131,6 +1152,7 @@ def versus_rest(
1131
1152
size_factors : np .ndarray = None ,
1132
1153
batch_size : int = None ,
1133
1154
training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
1155
+ is_sig_zerovar : bool = True ,
1134
1156
quick_scale : bool = None ,
1135
1157
dtype = "float64" ,
1136
1158
pval_correction : str = "global" ,
@@ -1221,6 +1243,9 @@ def versus_rest(
1221
1243
1222
1244
- "global": correct all p-values in one operation
1223
1245
- "by_test": correct the p-values of each test individually
1246
+ :param is_sig_zerovar:
1247
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
1248
+ the p-value is set to np.nan.
1224
1249
:param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
1225
1250
"""
1226
1251
if len (kwargs ) != 0 :
@@ -1257,6 +1282,7 @@ def versus_rest(
1257
1282
training_strategy = training_strategy ,
1258
1283
quick_scale = quick_scale ,
1259
1284
size_factors = size_factors ,
1285
+ is_sig_zerovar = is_sig_zerovar ,
1260
1286
dtype = dtype ,
1261
1287
** kwargs
1262
1288
)
@@ -1353,6 +1379,7 @@ def two_sample(
1353
1379
noise_model : str = None ,
1354
1380
batch_size : int = None ,
1355
1381
training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
1382
+ is_sig_zerovar : bool = True ,
1356
1383
** kwargs
1357
1384
) -> _DifferentialExpressionTestMulti :
1358
1385
"""
@@ -1388,6 +1415,9 @@ def two_sample(
1388
1415
`training_strategy(estimator)`.
1389
1416
- list of keyword dicts containing method arguments: Will call Estimator.train() once with each dict of
1390
1417
method arguments.
1418
+ :param is_sig_zerovar:
1419
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
1420
+ the p-value is set to np.nan.
1391
1421
:param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
1392
1422
"""
1393
1423
DETestsSingle = []
@@ -1403,6 +1433,7 @@ def two_sample(
1403
1433
size_factors = size_factors [idx ] if size_factors is not None else None ,
1404
1434
batch_size = batch_size ,
1405
1435
training_strategy = training_strategy ,
1436
+ is_sig_zerovar = is_sig_zerovar ,
1406
1437
** kwargs
1407
1438
))
1408
1439
return DifferentialExpressionTestByPartition (
@@ -1415,6 +1446,7 @@ def t_test(
1415
1446
self ,
1416
1447
grouping : Union [str ],
1417
1448
is_logged : bool ,
1449
+ is_sig_zerovar : bool = True ,
1418
1450
dtype = "float64"
1419
1451
):
1420
1452
"""
@@ -1428,6 +1460,9 @@ def t_test(
1428
1460
:param is_logged:
1429
1461
Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
1430
1462
If False, log-fold changes are computed as log-fold changes on this data.
1463
+ :param is_sig_zerovar:
1464
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
1465
+ the p-value is set to np.nan.
1431
1466
:param dtype:
1432
1467
"""
1433
1468
DETestsSingle = []
@@ -1438,6 +1473,7 @@ def t_test(
1438
1473
is_logged = is_logged ,
1439
1474
gene_names = self .gene_names ,
1440
1475
sample_description = self .sample_description .iloc [idx , :],
1476
+ is_sig_zerovar = is_sig_zerovar ,
1441
1477
dtype = dtype
1442
1478
))
1443
1479
return DifferentialExpressionTestByPartition (
@@ -1449,6 +1485,7 @@ def t_test(
1449
1485
def rank_test (
1450
1486
self ,
1451
1487
grouping : Union [str ],
1488
+ is_sig_zerovar : bool = True ,
1452
1489
dtype = "float64"
1453
1490
):
1454
1491
"""
@@ -1460,6 +1497,9 @@ def rank_test(
1460
1497
1461
1498
- column in data.obs/sample_description which contains the split of observations into the two groups.
1462
1499
- array of length `num_observations` containing group labels
1500
+ :param is_sig_zerovar:
1501
+ Whether to assign p-value of 0 to a gene which has zero variance in both groups but not the same mean. If False,
1502
+ the p-value is set to np.nan.
1463
1503
:param dtype:
1464
1504
"""
1465
1505
DETestsSingle = []
@@ -1469,6 +1509,7 @@ def rank_test(
1469
1509
grouping = grouping ,
1470
1510
gene_names = self .gene_names ,
1471
1511
sample_description = self .sample_description .iloc [idx , :],
1512
+ is_sig_zerovar = is_sig_zerovar ,
1472
1513
dtype = dtype
1473
1514
))
1474
1515
return DifferentialExpressionTestByPartition (
0 commit comments