eiriniar / CellCnn

Representation Learning for detection of phenotype-associated cell subsets
http://www.imsb.ethz.ch/research/claassen/Software/cellcnn.html
GNU General Public License v3.0
64 stars 28 forks source link

Unable to plot figures using the NK example files #6

Open Troylimyj opened 3 years ago

Troylimyj commented 3 years ago

Thank you for developing this very interesting ML tool for cytof data analysis. I am new to Python and keen to utilise your algorithm for my dataset.

However when trying to run using the example NK cells data set, I keep getting this error code, I wonder if you could advise further.

run run_analysis.py -f NK_fcs_samples_with_labels.csv -m NK_markers.csv -i gated_NK/ -o outdir_NK --export_csv --group_a CMV- --group_b CMV+ --verbose 0

2021-02-23 13:44:11 - main:156 - INFO - Samples used for model training: ['a_001_NK.fcs', 'a_002_NK.fcs', 'a_003_NK.fcs', 'a_004_NK.fcs', 'a_006_NK.fcs', 'a_009_NK.fcs', 'a_010_NK.fcs', 'a_011_NK.fcs', 'a_012_NK.fcs', 'a_1a_NK.fcs', 'a_2a_NK.fcs', 'a_2b_NK.fcs', 'a_4a_NK.fcs', 'a_4b_NK.fcs', 'a_5a_NK.fcs'] 2021-02-23 13:44:11 - main:157 - INFO - Samples used for validation: ['a_005_NK.fcs', 'a_007_NK.fcs', 'a_3a_NK.fcs', 'a_3b_NK.fcs', 'a_5b_NK.fcs'] 2021-02-23 13:44:12 - cellCnn.model:320 - INFO - Generating multi-cell inputs... 2021-02-23 13:44:12 - cellCnn.model:390 - INFO - Done. 2021-02-23 13:44:12 - cellCnn.model:425 - INFO - Number of filters: 3 2021-02-23 13:44:12 - cellCnn.model:431 - INFO - Cells pooled: 1 63/63 [==============================] - 0s 1ms/step - loss: 0.6482 - accuracy: 0.6768 2021-02-23 13:44:16 - cellCnn.model:460 - INFO - Best validation accuracy: 0.68 2021-02-23 13:44:16 - cellCnn.model:425 - INFO - Number of filters: 6 2021-02-23 13:44:16 - cellCnn.model:431 - INFO - Cells pooled: 2 63/63 [==============================] - 0s 1ms/step - loss: 0.4967 - accuracy: 0.7944 2021-02-23 13:44:25 - cellCnn.model:460 - INFO - Best validation accuracy: 0.79 2021-02-23 13:44:25 - cellCnn.model:425 - INFO - Number of filters: 8 2021-02-23 13:44:25 - cellCnn.model:431 - INFO - Cells pooled: 10 63/63 [==============================] - 0s 1ms/step - loss: 0.3701 - accuracy: 0.8989 2021-02-23 13:44:34 - cellCnn.model:460 - INFO - Best validation accuracy: 0.90 2021-02-23 13:44:34 - cellCnn.model:425 - INFO - Number of filters: 4 2021-02-23 13:44:34 - cellCnn.model:431 - INFO - Cells pooled: 40 63/63 [==============================] - 0s 1ms/step - loss: 0.6090 - accuracy: 0.7579 2021-02-23 13:44:38 - cellCnn.model:460 - INFO - Best validation accuracy: 0.76 2021-02-23 13:44:38 - cellCnn.model:425 - INFO - Number of filters: 6 2021-02-23 13:44:38 - cellCnn.model:431 - INFO - Cells pooled: 1 63/63 [==============================] - 0s 1ms/step - loss: 0.5279 - accuracy: 0.7724 2021-02-23 13:44:45 - cellCnn.model:460 - INFO - Best validation accuracy: 0.77 2021-02-23 13:44:45 - cellCnn.model:425 - INFO - Number of filters: 7 2021-02-23 13:44:45 - cellCnn.model:431 - INFO - Cells pooled: 2 63/63 [==============================] - 0s 1ms/step - loss: 0.6276 - accuracy: 0.7114 2021-02-23 13:44:50 - cellCnn.model:460 - INFO - Best validation accuracy: 0.71 2021-02-23 13:44:50 - cellCnn.model:425 - INFO - Number of filters: 9 2021-02-23 13:44:50 - cellCnn.model:431 - INFO - Cells pooled: 10 63/63 [==============================] - 0s 1ms/step - loss: 0.4519 - accuracy: 0.8374 2021-02-23 13:44:58 - cellCnn.model:460 - INFO - Best validation accuracy: 0.84 2021-02-23 13:44:58 - cellCnn.model:425 - INFO - Number of filters: 4 2021-02-23 13:44:58 - cellCnn.model:431 - INFO - Cells pooled: 40 63/63 [==============================] - 0s 1ms/step - loss: 0.3997 - accuracy: 0.9390 2021-02-23 13:45:03 - cellCnn.model:460 - INFO - Best validation accuracy: 0.94 2021-02-23 13:45:03 - cellCnn.model:425 - INFO - Number of filters: 5 2021-02-23 13:45:03 - cellCnn.model:431 - INFO - Cells pooled: 1 63/63 [==============================] - 0s 2ms/step - loss: 0.6324 - accuracy: 0.8139 2021-02-23 13:45:07 - cellCnn.model:460 - INFO - Best validation accuracy: 0.81 2021-02-23 13:45:07 - cellCnn.model:425 - INFO - Number of filters: 8 2021-02-23 13:45:07 - cellCnn.model:431 - INFO - Cells pooled: 2 63/63 [==============================] - 0s 1ms/step - loss: 0.4493 - accuracy: 0.8229 2021-02-23 13:45:17 - cellCnn.model:460 - INFO - Best validation accuracy: 0.82 2021-02-23 13:45:17 - cellCnn.model:425 - INFO - Number of filters: 5 2021-02-23 13:45:17 - cellCnn.model:431 - INFO - Cells pooled: 10 63/63 [==============================] - 0s 1ms/step - loss: 0.6025 - accuracy: 0.7044 2021-02-23 13:45:22 - cellCnn.model:460 - INFO - Best validation accuracy: 0.70 2021-02-23 13:45:22 - cellCnn.model:425 - INFO - Number of filters: 7 2021-02-23 13:45:22 - cellCnn.model:431 - INFO - Cells pooled: 40 63/63 [==============================] - 0s 1ms/step - loss: 0.4441 - accuracy: 0.8574 2021-02-23 13:45:29 - cellCnn.model:460 - INFO - Best validation accuracy: 0.86 2021-02-23 13:45:29 - cellCnn.model:425 - INFO - Number of filters: 7 2021-02-23 13:45:29 - cellCnn.model:431 - INFO - Cells pooled: 1 63/63 [==============================] - 0s 1ms/step - loss: 0.4593 - accuracy: 0.8219 2021-02-23 13:45:37 - cellCnn.model:460 - INFO - Best validation accuracy: 0.82 2021-02-23 13:45:37 - cellCnn.model:425 - INFO - Number of filters: 4 2021-02-23 13:45:37 - cellCnn.model:431 - INFO - Cells pooled: 2 63/63 [==============================] - 0s 1ms/step - loss: 0.5350 - accuracy: 0.7729 2021-02-23 13:45:42 - cellCnn.model:460 - INFO - Best validation accuracy: 0.77 2021-02-23 13:45:42 - cellCnn.model:425 - INFO - Number of filters: 6 2021-02-23 13:45:42 - cellCnn.model:431 - INFO - Cells pooled: 10 63/63 [==============================] - 0s 1ms/step - loss: 0.2961 - accuracy: 0.9450 2021-02-23 13:45:51 - cellCnn.model:460 - INFO - Best validation accuracy: 0.94 2021-02-23 13:45:53 - cellCnn.plotting:144 - INFO - Loading the weights of consensus filters. 2021-02-23 13:45:53 - cellCnn.plotting:168 - INFO - Computing t-SNE projection... C:\Users\yeong\AppData\Local\Programs\Python\Python37\Scripts\CellCnn-python3\cellCnn\plotting.py:582: MatplotlibDeprecationWarning: The 'add_all' parameter of init() was deprecated in Matplotlib 3.3 and will be removed two minor releases later. If any parameter follows 'add_all', they should be passed as keyword, not positionally. cbar_pad="5%",

TypeError Traceback (most recent call last) ~\AppData\Local\Programs\Python\Python37\Scripts\CellCnn-python3\run_analysis.py in 240 if name == 'main': 241 try: --> 242 main() 243 except KeyboardInterrupt: 244 sys.stderr.write("User interrupt!\n")

~\AppData\Local\Programs\Python\Python37\Scripts\CellCnn-python3\run_analysis.py in main() 209 tsne_ncell=args.tsne_ncell, 210 regression=args.regression, --> 211 show_filters=False) 212 _v = plot_results(results, valid_samples, valid_phenotypes, 213 marker_names, os.path.join(plotdir, 'validation_plots'),

~\AppData\Local\Programs\Python\Python37\Scripts\CellCnn-python3\cellCnn\plotting.py in plot_results(results, samples, phenotypes, labels, outdir, filter_diff_thres, filter_response_thres, response_grad_cutoff, stat_test, log_yscale, group_a, group_b, group_names, tsne_ncell, regression, show_filters) 176 fig_path = os.path.join(outdir, 'tsne_all_cells') 177 plot_tsne_grid(x_tsne, x_for_tsne, fig_path, labels=labels, fig_size=(20, 20), --> 178 point_size=5) 179 180 return_filters = []

~\AppData\Local\Programs\Python\Python37\Scripts\CellCnn-python3\cellCnn\plotting.py in plot_tsne_grid(z, x, fig_path, labels, fig_size, g_j, suffix, point_size) 580 cbar_mode="each", 581 cbar_size="8%", --> 582 cbar_pad="5%", 583 ) 584 for seq_index in range(ncol):

c:\users\yeong\appdata\local\programs\python\python37\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(inner_args, inner_kwargs) 409 else deprecation_addendum, 410 kwargs) --> 411 return func(inner_args, **inner_kwargs) 412 413 return wrapper

c:\users\yeong\appdata\local\programs\python\python37\lib\site-packages\mpl_toolkits\axes_grid1\axes_grid.py in init(self, fig, rect, nrows_ncols, ngrids, direction, axes_pad, add_all, share_all, aspect, label_mode, cbar_mode, cbar_location, cbar_pad, cbar_size, cbar_set_cax, axes_class) 434 direction=direction, axes_pad=axes_pad, 435 share_all=share_all, share_x=True, share_y=True, aspect=aspect, --> 436 label_mode=label_mode, axes_class=axes_class) 437 else: # Only show deprecation in that case. 438 super().init(

c:\users\yeong\appdata\local\programs\python\python37\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(inner_args, inner_kwargs) 409 else deprecation_addendum, 410 kwargs) --> 411 return func(inner_args, **inner_kwargs) 412 413 return wrapper

c:\users\yeong\appdata\local\programs\python\python37\lib\site-packages\mpl_toolkits\axes_grid1\axes_grid.py in init(self, fig, rect, nrows_ncols, ngrids, direction, axes_pad, add_all, share_all, share_x, share_y, label_mode, axes_class, aspect) 210 if add_all: 211 for ax in self.axes_all: --> 212 fig.add_axes(ax) 213 214 self.set_label_mode(label_mode)

c:\users\yeong\appdata\local\programs\python\python37\lib\site-packages\matplotlib\figure.py in add_axes(self, *args, **kwargs) 1234 else: 1235 rect = args[0] -> 1236 if not np.isfinite(rect).all(): 1237 raise ValueError('all entries in rect must be finite ' 1238 'not {}'.format(rect))

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

eleniel-mocna commented 3 years ago

I've had the same issue and solved it by downgrading matplotlib to version 2.2. Rewriting pipfile with locked versions would probably solve this issue...

Z-Forest commented 2 years ago

@Troylimyj @eleniel-mocna Hello, I just learned Python and found that the data set website of this project is no longer accessible. Could you please share a relevant data set with me? Thank you very much!