theislab / scCODA

A Bayesian model for compositional single-cell data analysis
BSD 3-Clause "New" or "Revised" License
142 stars 23 forks source link

WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature #40

Closed Elhl93 closed 2 years ago

Elhl93 commented 2 years ago

Hi,

many thanks for the package! After running ".sample_hmc()" I receive a warning:

WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass.

After investigating the results with arviz, I observed that sample-stats -> chain only contains level 0 (I have multiple conditions, but I tried with 2 and 3, one being the reference), I furthermore could not find a 'mu' and 'tau' in the results with az.summary(all_results, var_names=['mu', 'tau'], filter_vars="regex"). Previously I ran:

mod.CompositionalAnalysis(CCM_GMEAN_SUB, formula="C(TREATMENT_COLNAME, Treatment('ELEMENT1_IN_TREATMENT_COLNAME'))", reference_cell_type="CELL_TYPE_REFERENCE").

Thanks for your thoughts.

johannesostner commented 2 years ago

Hi, thanks for using scCODA! This is an issue we have not encountered previously, but is definitely not intended. Unfortunately I can't tell the cause of it from the information you provide.

Could you please share:

Please also make sure that your reference cell type is actually in the data.

Thanks!

Elhl93 commented 2 years ago
johannesostner commented 2 years ago

Thanks for sharing this information! The tensorflow and tensorflow-probability versions that you have installed were not tested with scCODA yet, and might have introduced breaking changes. Reverting to tensorflow 2.4.x and tensorflow-probability 0.12.x could possibly fix the problem

Elhl93 commented 2 years ago

Excellent, the warnings disappeared. I assume it is expected that mu and tau are not in the final arviz object - ?

johannesostner commented 2 years ago

Exactly, there are no parameters named "mu" and "tau" used in scCODA. You can see the list of printable parameters in the result object by looking at result.posterior