abuzarmahmood / blech_clust

GNU General Public License v3.0
7 stars 4 forks source link

Issue running blech_clust_run #162

Closed cmazzio closed 1 month ago

cmazzio commented 1 month ago

Something wrong with clustermap...full block below

https://app.warp.dev/block/dCgZKFhhjbhMucPFLNzCO6

Error snippet

local:16/19/100%/28.7s Using neuRecommend features
=== Performing manual clustering ===
local:16/19/100%/28.7s Electrode 20 complete.
local:16/19/100%/28.8s /home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/seaborn/matrix.py:654: UserWarning: Clustering large matrix with scipy. Installing `fastcluster` may give better performance.
  warnings.warn(msg)
local:16/19/100%/28.8s Using neuRecommend features
=== Performing manual clustering ===
local:16/19/100%/28.9s Traceback (most recent call last):
  File "/home/cmazzio/Desktop/blech_clust/utils/cluster_stability.py", line 135, in <module>
    fig.savefig(f'./Plots/{electrode_num:02}/clusters{clust_num:02}/' +\
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/figure.py", line 2311, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/backends/backend_qt5agg.py", line 81, in print_figure
    super().print_figure(*args, **kwargs)
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2210, in print_figure
    result = print_method(
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 1639, in wrapper
    return func(*args, **kwargs)
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 510, in print_png
    mpl.image.imsave(
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/matplotlib/image.py", line 1611, in imsave
    image.save(fname, **pil_kwargs)
  File "/home/cmazzio/miniconda3/envs/blech_clust/lib/python3.8/site-packages/PIL/Image.py", line 2456, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: '/media/cmazzio/large_data/CM40/CM40_CTATest_h2o_sac_nacl_qhcl_240322_113514/Plots/20/clusters02/clustermap.png'
abuzarmahmood commented 1 month ago

On this commit (431ceb9), cluster_stability.py is outputting to cluster folders with zero-padded numbers

https://github.com/abuzarmahmood/blech_clust/blob/431ceb95d1bc431c20cb4f1c5e6b49f00936ca35/utils/cluster_stability.py#L135C1-L138C13

        fig.savefig(f'./Plots/{electrode_num:02}/clusters{clust_num:02}/' +\
                        f'clustermap.png', dpi=300,
                         bbox_inches='tight')
        plt.close()

but blech_run_process.py creates the directories without zero-padding (see f'clusters{self.cluster_num}' below)

https://github.com/abuzarmahmood/blech_clust/blob/431ceb95d1bc431c20cb4f1c5e6b49f00936ca35/utils/blech_process_utils.py#L232C1-L237C10

        clust_results_dir = os.path.join(
            self.data_dir,
            'clustering_results',
            f'electrode{self.electrode_num:02}',
            f'clusters{self.cluster_num}'
        )

You can remove the zero padding for the cluster directory in cluster_stability.py and it should work.

cmazzio commented 1 month ago

That fixed the issue.