mossjacob / pyslingshot

Python implementation of the Slingshot pseudotime algorithm
51 stars 7 forks source link

If clusters are more than 20, the algorithm crashes #8

Closed YazdanZ closed 2 years ago

YazdanZ commented 2 years ago

Hello, This issue is related to #2. It seems like the number of clusters allowed has been increased to 20 as as result of #2. However, now I get the following error with more than 20 clusters.

IndexError                                Traceback (most recent call last)
[<ipython-input-47-f6b45923880d>](https://localhost:8080/#) in <module>()
      6 slingshot = Slingshot(adata.X.astype("float32"), pd.get_dummies(adata.obs["louvain"]).to_numpy(dtype="float64"), start_node=12, debug_level='verbose')
      7 
----> 8 slingshot.fit(num_epochs=1, debug_axes=axes)

2 frames
[/usr/local/lib/python3.7/dist-packages/slingshot/slingshot.py](https://localhost:8080/#) in fit(self, num_epochs, debug_axes)
     72         self._set_debug_axes(debug_axes)
     73         if self.curves is None:  # Initial curves and pseudotimes:
---> 74             self.get_lineages()
     75             self.construct_initial_curves()
     76             self.cell_weights = [self.cluster_labels_onehot[:, self.lineages[l].clusters].sum(axis=1)

[/usr/local/lib/python3.7/dist-packages/slingshot/slingshot.py](https://localhost:8080/#) in get_lineages(self)
    153         # from matplotlib import pyplot as plt
    154         # plt.imshow(dists)
--> 155         self.plotter.clusters(self.debug_axes[0, 0])
    156         for root, children in tree.items():
    157             for child in children:

[/usr/local/lib/python3.7/dist-packages/slingshot/plotter.py](https://localhost:8080/#) in clusters(self, ax, labels, s, alpha, color_mode)
     23 
     24         if color_mode == 'clusters':
---> 25             colors = np.array(sns.color_palette())[sling.cluster_labels]
     26             handles = [
     27                 Patch(color=colors[k], label=labels[k]) for k in range(sling.num_clusters)

IndexError: index 22 is out of bounds for axis 0 with size 20

Edit: Sorry, the problem was solved in #2. The package on pypi isn't updated.

YazdanZ commented 2 years ago

Would be nice to update pypi but closing the issue.

mossjacob commented 2 years ago

Thanks for finding this. I'll update pypi now!