imsb-uke/scGAN

Assistance Needed with cscGAN Training Error

Xinle-Deng opened this issue · 3 comments

Firstly, I want to commend you on the wonderful work you have done. I am very interested in scGAN and its applications. I have my own anndata with predefined clusters, so there is no need for additional clustering. The cluster information is stored in adata.obs['cluster'], where each element's data type is a pandas category, consistent with the outputs of sc.tl.louvain.

However, when I attempt to train cscGAN, I encounter the following error messages:
image

Could you please provide guidance on how to resolve this issue?

Hello @Xinle-Deng,

The issue is that your clusters (named cluster_int in our code) are not saved in the TFRecord files. If you want to use the code with your clusters, you must pass cluster=<your clusters as integers per cell>, categories=<cell type names matching your cluster numbers> into the make_example function.

I assume you already modified the main.py and did something like this, right? Could you let me know what modifications you did already if your problem persists after the modification to the make_example call mentioned above?

Hello @Xinle-Deng,

The issue is that your clusters (named cluster_int in our code) are not saved in the TFRecord files. If you want to use the code with your clusters, you must pass cluster=<your clusters as integers per cell>, categories=<cell type names matching your cluster numbers> into the make_example function.

I assume you already modified the main.py and did something like this, right? Could you let me know what modifications you did already if your problem persists after the modification to the make_example call mentioned above?

Thank you for your prompt response. It's my fault. I reviewed the code and data once again today and found that although adata.obs['cluster'] is of pandas category type, its category label data type is an integer rather than a string object. This causes the condition "if cluster" in the make_example function to not trigger when the cluster number is 0, leading to the aforementioned error message. I believe it would be better to change this to "if cluster is not None". After making this change, the model can be trained normally.

Thank you for your prompt response. It's my fault. I reviewed the code and data once again today and found that although adata.obs['cluster'] is of pandas category type, its category label data type is an integer rather than a string object. This causes the condition "if cluster" in the make_example function to not trigger when the cluster number is 0, leading to the aforementioned error message. I believe it would be better to change this to "if cluster is not None". After making this change, the model can be trained normally.

Thank you, you're right. I changed that.