@@ -669,6 +669,7 @@ def t_test(
669669 gene_names : Union [np .ndarray , list ] = None ,
670670 sample_description : pd .DataFrame = None ,
671671 is_logged : bool = False ,
672+ is_sig_zerovar : bool = True ,
672673 dtype = "float64"
673674):
674675 """
@@ -686,6 +687,9 @@ def t_test(
686687 :param is_logged:
687688 Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
688689 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.
689693 """
690694 gene_names = parse_gene_names (data , gene_names )
691695 X = parse_data (data , gene_names )
@@ -698,7 +702,8 @@ def t_test(
698702 sample_description = sample_description ,
699703 grouping = grouping ,
700704 gene_names = gene_names ,
701- is_logged = is_logged
705+ is_logged = is_logged ,
706+ is_sig_zerovar = is_sig_zerovar
702707 )
703708
704709 return de_test
@@ -709,7 +714,8 @@ def rank_test(
709714 grouping : Union [str , np .ndarray , list ],
710715 gene_names : Union [np .ndarray , list ] = None ,
711716 sample_description : pd .DataFrame = None ,
712- is_logged = False ,
717+ is_logged : bool = False ,
718+ is_sig_zerovar : bool = True ,
713719 dtype = "float64"
714720):
715721 """
@@ -727,6 +733,9 @@ def rank_test(
727733 :param is_logged:
728734 Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
729735 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.
730739 """
731740 gene_names = parse_gene_names (data , gene_names )
732741 X = parse_data (data , gene_names )
@@ -739,7 +748,8 @@ def rank_test(
739748 sample_description = sample_description ,
740749 grouping = grouping ,
741750 gene_names = gene_names ,
742- is_logged = is_logged
751+ is_logged = is_logged ,
752+ is_sig_zerovar = is_sig_zerovar
743753 )
744754
745755 return de_test
@@ -756,6 +766,7 @@ def two_sample(
756766 size_factors : np .ndarray = None ,
757767 batch_size : int = None ,
758768 training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
769+ is_sig_zerovar : bool = True ,
759770 quick_scale : bool = None ,
760771 dtype = "float64" ,
761772 ** kwargs
@@ -824,6 +835,9 @@ def two_sample(
824835 `training_strategy(estimator)`.
825836 - list of keyword dicts containing method arguments: Will call Estimator.train() once with each dict of
826837 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.
827841 :param quick_scale: Depending on the optimizer, `scale` will be fitted faster and maybe less accurate.
828842
829843 Useful in scenarios where fitting the exact `scale` is not absolutely necessary.
@@ -898,13 +912,15 @@ def two_sample(
898912 data = X ,
899913 gene_names = gene_names ,
900914 grouping = grouping ,
915+ is_sig_zerovar = is_sig_zerovar ,
901916 dtype = dtype
902917 )
903918 elif test .lower () == 'rank' :
904919 de_test = rank_test (
905920 data = X ,
906921 gene_names = gene_names ,
907922 grouping = grouping ,
923+ is_sig_zerovar = is_sig_zerovar ,
908924 dtype = dtype
909925 )
910926 else :
@@ -925,6 +941,7 @@ def pairwise(
925941 size_factors : np .ndarray = None ,
926942 batch_size : int = None ,
927943 training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
944+ is_sig_zerovar : bool = True ,
928945 quick_scale : bool = None ,
929946 dtype = "float64" ,
930947 pval_correction : str = "global" ,
@@ -1016,7 +1033,10 @@ def pairwise(
10161033
10171034 - "global": correct all p-values in one operation
10181035 - "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.
10201040 :param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
10211041 """
10221042 if len (kwargs ) != 0 :
@@ -1096,6 +1116,7 @@ def pairwise(
10961116 batch_size = batch_size ,
10971117 training_strategy = training_strategy ,
10981118 quick_scale = quick_scale ,
1119+ is_sig_zerovar = is_sig_zerovar ,
10991120 dtype = dtype ,
11001121 ** kwargs
11011122 )
@@ -1131,6 +1152,7 @@ def versus_rest(
11311152 size_factors : np .ndarray = None ,
11321153 batch_size : int = None ,
11331154 training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
1155+ is_sig_zerovar : bool = True ,
11341156 quick_scale : bool = None ,
11351157 dtype = "float64" ,
11361158 pval_correction : str = "global" ,
@@ -1221,6 +1243,9 @@ def versus_rest(
12211243
12221244 - "global": correct all p-values in one operation
12231245 - "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.
12241249 :param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
12251250 """
12261251 if len (kwargs ) != 0 :
@@ -1257,6 +1282,7 @@ def versus_rest(
12571282 training_strategy = training_strategy ,
12581283 quick_scale = quick_scale ,
12591284 size_factors = size_factors ,
1285+ is_sig_zerovar = is_sig_zerovar ,
12601286 dtype = dtype ,
12611287 ** kwargs
12621288 )
@@ -1353,6 +1379,7 @@ def two_sample(
13531379 noise_model : str = None ,
13541380 batch_size : int = None ,
13551381 training_strategy : Union [str , List [Dict [str , object ]], Callable ] = "AUTO" ,
1382+ is_sig_zerovar : bool = True ,
13561383 ** kwargs
13571384 ) -> _DifferentialExpressionTestMulti :
13581385 """
@@ -1388,6 +1415,9 @@ def two_sample(
13881415 `training_strategy(estimator)`.
13891416 - list of keyword dicts containing method arguments: Will call Estimator.train() once with each dict of
13901417 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.
13911421 :param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
13921422 """
13931423 DETestsSingle = []
@@ -1403,6 +1433,7 @@ def two_sample(
14031433 size_factors = size_factors [idx ] if size_factors is not None else None ,
14041434 batch_size = batch_size ,
14051435 training_strategy = training_strategy ,
1436+ is_sig_zerovar = is_sig_zerovar ,
14061437 ** kwargs
14071438 ))
14081439 return DifferentialExpressionTestByPartition (
@@ -1415,6 +1446,7 @@ def t_test(
14151446 self ,
14161447 grouping : Union [str ],
14171448 is_logged : bool ,
1449+ is_sig_zerovar : bool = True ,
14181450 dtype = "float64"
14191451 ):
14201452 """
@@ -1428,6 +1460,9 @@ def t_test(
14281460 :param is_logged:
14291461 Whether data is already logged. If True, log-fold changes are computed as fold changes on this data.
14301462 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.
14311466 :param dtype:
14321467 """
14331468 DETestsSingle = []
@@ -1438,6 +1473,7 @@ def t_test(
14381473 is_logged = is_logged ,
14391474 gene_names = self .gene_names ,
14401475 sample_description = self .sample_description .iloc [idx , :],
1476+ is_sig_zerovar = is_sig_zerovar ,
14411477 dtype = dtype
14421478 ))
14431479 return DifferentialExpressionTestByPartition (
@@ -1449,6 +1485,7 @@ def t_test(
14491485 def rank_test (
14501486 self ,
14511487 grouping : Union [str ],
1488+ is_sig_zerovar : bool = True ,
14521489 dtype = "float64"
14531490 ):
14541491 """
@@ -1460,6 +1497,9 @@ def rank_test(
14601497
14611498 - column in data.obs/sample_description which contains the split of observations into the two groups.
14621499 - 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.
14631503 :param dtype:
14641504 """
14651505 DETestsSingle = []
@@ -1469,6 +1509,7 @@ def rank_test(
14691509 grouping = grouping ,
14701510 gene_names = self .gene_names ,
14711511 sample_description = self .sample_description .iloc [idx , :],
1512+ is_sig_zerovar = is_sig_zerovar ,
14721513 dtype = dtype
14731514 ))
14741515 return DifferentialExpressionTestByPartition (
0 commit comments