1

I have the following function, which plots UMAP, based on the number of clusters I've chosen, and returns series 'labels'.

def UMAPplot_building(file_name, num_clusters):
   logr_file = pd.read_csv(file_name, sep='\t')

   projector = umap.UMAP(metric='euclidean', random_state=42, verbose=True)
   logr_projection = projector.fit_transform(logr_file.T)
   logr_projection = pd.DataFrame(logr_projection,
                                 index=logr_file.columns,
                                 columns=['v1', 'v2'])

   clustermap_result = clustermap_wp(logr_projection.T, xl=[], yl=[])

   labels = cut_clustermap_tree(clustermap_result, num_clusters)
   umap_plot(logr_projection, labels)
   labels.index = [index.replace('.', '-') for index in labels.index]
   return labels

To choose the amount of clusters I use interact_manual:

interact_manual(UMAPplot_building, num_clusters = widgets.IntSlider(min=1, max=20), 
file_name=fixed(my_file, sep='\t'))

The problem is that I need to return 'labels' to use it further in my script. I know that for interactive we can use .result and it returns the value, but I cannot find how to do it using interact_manual. Thank you in advance.

Sam
  • 11
  • 1
  • Hi, if you can you simplify your question so I can copy and paste the code that would be much easier. Could you 1) Create a dummy dataframe from a dictionary, and 2) rewrite to remove unnecessary imports like `umap`, when your question is about widgets, could you use something more common like matplotlib to replace the plotting part? Thanks – ac24 Dec 07 '20 at 09:34

0 Answers0