theislab / cellrank

CellRank: dynamics from multi-view single-cell data
https://cellrank.org
BSD 3-Clause "New" or "Revised" License
347 stars 46 forks source link

Bug in `self._select_cells`. #181

Closed Marius1311 closed 4 years ago

Marius1311 commented 4 years ago

I compute metastable states as g_fwd.compute_metastable_states(cluster_key='clusters', n_states=2), which gives the following output:

Computing metastable states
INFO: Using pre-computed schur decomposition
WARNING: The following groups could not be mapped uniquely: `AT2 cells_1, AT2 cells_2`
Adding `.schur_vectors`
       `.metastable_states`
       `.coarse_T`
       `.coarse_stationary_distribution`
    Finish (0:00:00)

The resulting states look like this: image This makes no sense. So I check the membership vectors themselves: image

They look fine, just the names are off, see the cluster assignment below: image This tells me: the first state should be called "to ciliated cells", while the second one should be called "to AT2 cells"

Also, I check the metastable assignment like this: scv.pl.scatter(adata, color=g_fwd._gpcca.metastable_assignment, color_map='Paired'), which gives image

This also looks fine, so it must be a problem with selecting cells from each metastable state. It seems like the wrong cells are selected, which subsequently means that the state gets the wrong name and color assigned.

If needed, I can send you the anndata object to reproduce. Have we got tests yet for

Since these seem to be a bit tricky in practice, would be important to include some tests for them.

michalk8 commented 4 years ago

Seems pretty serious, will look into it. Don't have tests for this yet, will add.

Marius1311 commented 4 years ago

Thanks!