@@ -223,7 +223,7 @@ def lrt(
223
223
use wald() for constraints.
224
224
225
225
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
226
- Input data
226
+ Input data matrix (observations x features) or (cells x genes).
227
227
:param reduced_formula_loc: formula
228
228
Reduced model formula for location and scale parameter models.
229
229
If not specified, `reduced_formula` will be used instead.
@@ -403,7 +403,7 @@ def wald(
403
403
Perform Wald test for differential expression for each gene.
404
404
405
405
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
406
- Input data
406
+ Input data matrix (observations x features) or (cells x genes).
407
407
:param factor_loc_totest: str, list of strings
408
408
List of factors of formula to test with Wald test.
409
409
E.g. "condition" or ["batch", "condition"] if formula_loc would be "~ 1 + batch + condition"
@@ -530,6 +530,17 @@ def wald(
530
530
formula = formula_loc ,
531
531
as_categorical = [False if x in as_numeric else True for x in sample_description .columns .values ]
532
532
)
533
+ # Check that closed-form is not used if numeric predictors are used and model is not "norm".
534
+ if isinstance (init_a , str ):
535
+ if np .any ([True if x in as_numeric else False for x in sample_description .columns .values ]):
536
+ if noise_model .lower () not in ["normal" , "norm" ]:
537
+ if init_a == "closed_form" :
538
+ init_a = "standard"
539
+ logger .warning ("Setting init_a to standard as numeric predictors were supplied." )
540
+ logger .warning ("Closed-form initialisation is not possible" +
541
+ " for noise model %s with numeric predictors." % noise_model )
542
+ elif init_a == "AUTO" :
543
+ init_a = "standard"
533
544
else :
534
545
design_loc = dmat_loc
535
546
@@ -539,6 +550,16 @@ def wald(
539
550
formula = formula_scale ,
540
551
as_categorical = [False if x in as_numeric else True for x in sample_description .columns .values ]
541
552
)
553
+ # Check that closed-form is not used if numeric predictors are used and model is not "norm".
554
+ if isinstance (init_b , str ):
555
+ if np .any ([True if x in as_numeric else False for x in sample_description .columns .values ]):
556
+ if init_b == "closed_form" :
557
+ init_b = "standard"
558
+ logger .warning ("Setting init_b to standard as numeric predictors were supplied." )
559
+ logger .warning ("Closed-form initialisation is not possible" +
560
+ " for noise model %s with numeric predictors." % noise_model )
561
+ elif init_b == "AUTO" :
562
+ init_b = "standard"
542
563
else :
543
564
design_scale = dmat_scale
544
565
@@ -622,7 +643,7 @@ def t_test(
622
643
between two groups on adata object for each gene.
623
644
624
645
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
625
- Input data
646
+ Input data matrix (observations x features) or (cells x genes).
626
647
:param grouping: str, array
627
648
628
649
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -662,7 +683,7 @@ def rank_test(
662
683
between two groups on adata object for each gene.
663
684
664
685
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
665
- Input data
686
+ Input data matrix (observations x features) or (cells x genes).
666
687
:param grouping: str, array
667
688
668
689
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -736,7 +757,7 @@ def two_sample(
736
757
Wilcoxon rank sum (Mann-Whitney U) test between both observation groups.
737
758
738
759
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
739
- Input data
760
+ Input data matrix (observations x features) or (cells x genes).
740
761
:param grouping: str, array
741
762
742
763
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -925,7 +946,7 @@ def pairwise(
925
946
Wilcoxon rank sum (Mann-Whitney U) test between both observation groups.
926
947
927
948
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
928
- Input data
949
+ Input data matrix (observations x features) or (cells x genes).
929
950
:param grouping: str, array
930
951
931
952
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -1143,7 +1164,7 @@ def versus_rest(
1143
1164
Wilcoxon rank sum (Mann-Whitney U) test between both observation groups.
1144
1165
1145
1166
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
1146
- Input data
1167
+ Input data matrix (observations x features) or (cells x genes).
1147
1168
:param grouping: str, array
1148
1169
1149
1170
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -1271,7 +1292,7 @@ def partition(
1271
1292
Wraps _Partition so that doc strings are nice.
1272
1293
1273
1294
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
1274
- Input data
1295
+ Input data matrix (observations x features) or (cells x genes).
1275
1296
:param gene_names: optional list/array of gene names which will be used if `data` does not implicitly store these
1276
1297
:param sample_description: optional pandas.DataFrame containing sample annotations
1277
1298
"""
@@ -1300,7 +1321,7 @@ def __init__(
1300
1321
sample_description : pd .DataFrame = None ):
1301
1322
"""
1302
1323
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
1303
- Input data
1324
+ Input data matrix (observations x features) or (cells x genes).
1304
1325
:param partition: str, array
1305
1326
1306
1327
- column in data.obs/sample_description which contains the split of observations into the two groups.
@@ -1615,9 +1636,8 @@ def continuous_1d(
1615
1636
continuous : str ,
1616
1637
df : int = 5 ,
1617
1638
factor_loc_totest : Union [str , List [str ]] = None ,
1618
- formula : str = None ,
1619
1639
formula_loc : str = None ,
1620
- formula_scale : str = None ,
1640
+ formula_scale : str = "~1" ,
1621
1641
as_numeric : Union [List [str ], Tuple [str ], str ] = (),
1622
1642
test : str = 'wald' ,
1623
1643
init_a : Union [np .ndarray , str ] = "standard" ,
@@ -1647,7 +1667,7 @@ def continuous_1d(
1647
1667
dmat directly to one of the test routines wald() or lrt().
1648
1668
1649
1669
:param data: Array-like, xr.DataArray, xr.Dataset or anndata.Anndata object containing observations.
1650
- Input data
1670
+ Input data matrix (observations x features) or (cells x genes).
1651
1671
:param continuous: str
1652
1672
1653
1673
- column in data.obs/sample_description which contains the continuous covariate.
@@ -1690,15 +1710,13 @@ def continuous_1d(
1690
1710
1691
1711
- str:
1692
1712
* "auto": automatically choose best initialization
1693
- * "random": initialize with random values
1694
1713
* "standard": initialize intercept with observed mean
1695
1714
- np.ndarray: direct initialization of 'a'
1696
1715
:param init_b: (Optional) Low-level initial values for b
1697
1716
Can be:
1698
1717
1699
1718
- str:
1700
1719
* "auto": automatically choose best initialization
1701
- * "random": initialize with random values
1702
1720
* "standard": initialize with zeros
1703
1721
- np.ndarray: direct initialization of 'b'
1704
1722
:param gene_names: optional list/array of gene names which will be used if `data` does not implicitly store these
@@ -1735,13 +1753,8 @@ def continuous_1d(
1735
1753
Should be "float32" for single precision or "float64" for double precision.
1736
1754
:param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
1737
1755
"""
1738
- if formula is None and (formula_loc is None or formula_scale is None ):
1739
- raise ValueError ("supply either formula or fomula_loc and formula_scale" )
1740
- if formula is not None and (formula_loc is not None or formula_scale is not None ):
1741
- raise ValueError ("supply either formula or fomula_loc and formula_scale" )
1742
- # Check that continuous factor is contained in model formulas:
1743
- if formula is not None :
1744
- pass
1756
+ if formula_loc is None :
1757
+ raise ValueError ("supply fomula_loc" )
1745
1758
# Set testing default to continuous covariate if not supplied:
1746
1759
if factor_loc_totest is None :
1747
1760
factor_loc_totest = [continuous ]
0 commit comments