ShobiStassen / VIA

trajectory inference
https://pyvia.readthedocs.io/en/latest/
MIT License
78 stars 20 forks source link

Fixing bug of None true_label #12

Closed GreenGilad closed 2 years ago

GreenGilad commented 2 years ago

In the current version if true_label is not passed in VIA's ctor one get the following exception:

TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_26896/2431515619.py in 1 v0 = via.VIA(X, knn=k, root_user=root, is_coarse=True, preserve_disconnected=True) ----> 2 v0.run_VIA() ~\anaconda3\envs\ViaEnv\lib\site-packages\pyVIA\core.py in run_VIA(self) 3494 self.ncomp = self.data.shape[1] 3495 pop_list = [] -> 3496 for item in set(list(self.true_label)): 3497 pop_list.append([item, list(self.true_label).count(item)]) 3498 # print("population composition", pop_list) TypeError: 'NoneType' object is not iterable

This happens because in the run_VIA function self.true_label is used in line 3615 but is only initialized in line 3618. In the suggested fix I simply moved the initialization of self.true_label to the ctor

GreenGilad commented 2 years ago

The second commit contains multiple changes of the following types:

GreenGilad commented 2 years ago

I also split the examples of all the different datasets to a separate file - this way it is easier to understand which part is the VIA algorithm and which is the examples.

There are still many lines in run_subPARC that have code specific for all of these examples (2610-2648, 2716-2802 and the functions that are called there fore finding the root). Maybe it is worth having classes that derive from the VIA class for these cases?

ShobiStassen commented 2 years ago

Thank you so very much for all your really neat contributions and modifications. I really appreciate your efforts to polish the code and make it neater. A big thank you :)

GreenGilad commented 2 years ago

@ShobiStassen if course :) I think this is a nice algorithm and it seems to be working nicely for my problem

ShobiStassen commented 2 years ago

@GreenGilad glad to hear it is working for your problem. what kind of data set are you using Via on, if i might ask? I find the parameter for graph pruning, cluster_graph_pruning_std, and the number of visualized outgoing edges, max_visual_outgoing_edges, to be quite useful to play around with to observe different levels of complexity of the trajectories. there are actually lots of things I want to improve/add for Via, just been busy/distracted with other projects cropping up!

GreenGilad commented 2 years ago

@ShobiStassen I have sent you an email to explain a bit more about the data