ben-j-barlow/clustree

Explain Images Better in Documentation

Opened this issue · 2 comments

The purpose of the required image argument is unclear. Overall, more explanation of function arguments would be great, such as of format of data. Additionally, a vignette would be great to show users a potential use case they could use.

I agree wholeheartedly. It is not enough to describe the image format. What is the required content? Images of clustering results? Node shapes? For the example in the one closed issue here, is it true that would require 23X22 images? Also, running that code, I get the following:

K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 ... K14 K15 K16 K17 K18 K19
0 0 0 2 2 0 5 2 0 3 6 ... 10 0 0 4 1 18
1 0 0 2 0 4 2 0 6 8 1 ... 9 12 2 2 7 8
2 0 0 2 0 4 2 0 6 8 1 ... 9 4 2 1 2 11
3 0 0 2 0 4 2 0 6 8 1 ... 9 4 8 1 2 11
4 0 0 2 2 0 5 2 0 3 6 ... 10 0 0 4 1 18

K20 K21 K22 K23
0 9 3 2 10
1 13 13 19 0
2 2 13 12 3
3 2 13 12 3
4 9 3 2 10

[5 rows x 23 columns]


error Traceback (most recent call last)
Cell In[11], line 24
20 data_final[col]=y_km
22 print(data_final.head())
---> 24 ct = clustree(data=data_final,
25 prefix="K",
26 draw=True,
27 output_path="C:\Users\smith6jt",
28 images="C:\Users\smith6jt")

File ~\AppData\Local\miniconda3\envs\clustree\Lib\site-packages\clustree_graph.py:171, in clustree(data, prefix, images, output_path, draw, node_color, node_color_aggr, node_cmap, edge_color, edge_cmap, orientation, layout_reingold_tilford, min_cluster_number, border_size, figsize, arrows, node_size, node_size_edge, dpi, kk)
169 dg = construct_clustree(cf=config)
170 if draw or output_path:
--> 171 draw_clustree(
172 dg=dg,
173 path=output_path,
174 orientation=orientation,
175 rt_layout=layout_reingold_tilford,
176 images=images,
177 figsize=figsize,
178 node_size=node_size,
179 node_size_edge=node_size_edge,
180 dpi=dpi,
181 border_size=border_size,
182 arrows=arrows,
183 node_color_sm=config.node_color_sm,
184 edge_color_sm=config.edge_color_sm,
185 node_color_title=config.node_color_legend_title,
186 edge_color_title=config.edge_color_legend_title,
187 )
188 return dg

File ~\AppData\Local\miniconda3\envs\clustree\Lib\site-packages\clustree_draw.py:251, in draw_clustree(dg, path, images, orientation, rt_layout, figsize, node_size, node_size_edge, arrows, border_size, node_color_sm, edge_color_sm, node_color_title, edge_color_title, dpi)
240 alpha = list(get_edge_attributes(dg, "in_prop").values())
241 draw_networkx_edges(
242 G=dg,
243 pos=pos,
(...)
249 alpha=alpha,
250 )
--> 251 draw_custom_nodes(
252 dg=dg,
253 extent=extent,
254 path=images,
255 ax=ax,
256 border_size_prop=border_size,
257 )
258 add_legend(
259 fig=fig,
260 ax=ax,
(...)
264 edge_color_title=edge_color_title,
265 )
266 if path:

File ~\AppData\Local\miniconda3\envs\clustree\Lib\site-packages\clustree_draw.py:161, in draw_custom_nodes(dg, extent, path, ax, border_size_prop)
159 img_path = path + file_name
160 img = cv2.imread(img_path)
--> 161 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
162 if border_size_prop == float(0):
163 ax.imshow(img, extent=extent[node_id], aspect=1, origin="upper", zorder=2)

error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:196: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

image

Hey, thanks for your input.

This project was completed as part of a paid contract at the University of Edinburgh which ended in April 2023. I open-sourced the package in an unpolished form intending to learn if there was demand for it in the Python community.

Given there have been a few issues raised, it seems there is motivation to improve the package after all. I think a vignette would be the best approach for providing instructions/examples. There wasn't much need to create one before, since the stakeholders involved in the project knew how everything worked. I am happy to revisit the project and create such a tutorial (after the busy period of my MSc dissertation ends in a few weeks!).