theislab / diffxpy

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

ValueError: assignment destination is read-only #186

Open gokceneraslan opened 3 years ago

gokceneraslan commented 3 years ago

Hey,

In some rare cases, I am getting the following error in de.test.wald():

Traceback (most recent call last):
  File "de.py", line 46, in <module>
    test = de.test.wald(
  File "/home/gokcen/.miniconda3/lib/python3.8/site-packages/diffxpy/testing/tests.py", line 717, in wald
    model = _fit(
  File "/home/gokcen/.miniconda3/lib/python3.8/site-packages/diffxpy/testing/tests.py", line 242, in _fit
    estim.train_sequence(
  File "/home/gokcen/.miniconda3/lib/python3.8/site-packages/batchglm/models/base/estimator.py", line 124, in train_sequence
    self.train(**d, **kwargs)
  File "/home/gokcen/.miniconda3/lib/python3.8/site-packages/batchglm/train/numpy/base_glm/estimator.py", line 139, in train
    a_step = self.iwls_step(idx_update=idx_update)
  File "/home/gokcen/.miniconda3/lib/python3.8/site-packages/batchglm/train/numpy/base_glm/estimator.py", line 290, in iwls_step
    delta_theta[:, idx_update[invertible]] = dask.array.map_blocks(
ValueError: assignment destination is read-only

I don't have a test case, but I think it happens if the number of cells and/or genes being tested are low.

Any ideas or workarounds?

Versions of the packages I am using:

diffxpy: 'v0.7.4+16.g3689ea8' batchglm: 'v0.7.4' tensorflow: '2.3.0' numpy: '1.19.4'

scSeqLiubice commented 3 years ago

Hey,

getting the same error traceback. Happened with a processed anndata single cell object:

>>> adata.proc
AnnData object with n_obs × n_vars = 4827 × 3000
    obs: 'n_genes', 'n_genes_by_counts', 'total_counts', 'total_counts_mt', 'pct_counts_mt', 'initial_size_spliced', 'initial_size_unspliced', 'initial_size', 'n_counts', 'leiden', 'velocity_self_transition', 'clusters'
    var: 'gene_name', 'gene_ens', 'n_cells', 'mt', 'n_cells_by_counts', 'mean_counts', 'pct_dropout_by_counts', 'total_counts', 'gene_count_corr', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std', 'fit_r2', 'fit_alpha', 'fit_beta', 'fit_gamma', 'fit_t_', 'fit_scaling', 'fit_std_u', 'fit_std_s', 'fit_likelihood', 'fit_u0', 'fit_s0', 'fit_pval_steady', 'fit_steady_u', 'fit_steady_s', 'fit_variance', 'fit_alignment_scaling', 'velocity_genes'
    uns: 'clusters_colors', "dendrogram_['clusters']", "dendrogram_['leiden']", 'dendrogram_clusters', 'hvg', 'leiden', 'leiden_colors', 'leiden_sizes', 'neighbors', 'paga', 'pca', 'rank_genes_groups', 'recover_dynamics', 'umap', 'velocity_graph', 'velocity_graph_neg', 'velocity_params'
    obsm: 'X_pca', 'X_umap', 'velocity_umap'
    varm: 'PCs', 'loss'
    layers: 'Ms', 'Mu', 'fit_t', 'fit_tau', 'fit_tau_', 'matrix', 'spliced', 'unspliced', 'velocity', 'velocity_u'
    obsp: 'connectivities', 'distances'

Should diffxpy rather be used on the raw anndata object before highly_variable filtering? I'm using the tensorflow-nightly packages. Hope this can be attributed to something user related so i can fix it asap. If there is some more info needed i would gladly provide it.

ivandatasci commented 3 years ago

Just to report that I get the same error. "ValueError: assignment destination is read-only".

I am simply following this tutorial to the letter: https://nbviewer.jupyter.org/github/theislab/diffxpy_tutorials/blob/master/diffxpy_tutorials/test/introduction_differential_testing.ipynb

My software versions Python 3.8.7 diffxpy v0.7.4 batchglm 0.7.4 anndata 0.7.5 numpy 1.18.4 scikit-learn 0.22.1 pandas 1.2.1 tensorflow 2.3.1