theislab / diffxpy

Differential expression analysis for single-cell RNA-seq data.
https://diffxpy.rtfd.io
BSD 3-Clause "New" or "Revised" License
191 stars 23 forks source link

specifying size_factor argument breaks wald test when dmat_loc is supplied directly #173

Open le-ander opened 4 years ago

le-ander commented 4 years ago

I have just tried running a wald test with a directly provided patsy design matrix. When I specified the size_factors argument, I got the following error (because sample_information is no longer provided when dmat is provided directly)

de.test.wald(
        data = adata_sub[adata_sub.obs['louvain_separate_fine'] == i],
        dmat_loc = dmat, 
        formula_scale="~1",
        coef_totest = ["C(treatment_chronic, levels=l_chr)[T.Chr]"],
        batch_size=(1e9,512),
        train_args={"nproc": 40},
        size_factors="size_factors"
    )
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-a1ad529c1918> in <module>
      6         batch_size=(1e9,512),
      7         train_args={"nproc": 40},
----> 8         size_factors="size_factors"
      9     )

~/.local/lib/python3.7/site-packages/diffxpy/testing/tests.py in wald(data, factor_loc_totest, coef_to_test, formula_loc, formula_scale, as_numeric, init_a, init_b, gene_names, sample_description, dmat_loc, dmat_scale, constraints_loc, constraints_scale, noise_model, size_factors, batch_size, backend, train_args, training_strategy, quick_scale, dtype, **kwargs)
    641         size_factors=size_factors,
    642         data=data,
--> 643         sample_description=sample_description
    644     )
    645 

~/.local/lib/python3.7/site-packages/diffxpy/testing/utils.py in parse_size_factors(size_factors, data, sample_description)
     89             size_factors = size_factors.values
     90         elif isinstance(size_factors, str):
---> 91             assert size_factors in sample_description.columns, ""
     92             size_factors = sample_description[size_factors].values
     93 

AttributeError: 'NoneType' object has no attribute 'columns'