Open BenjaminDEMAILLE opened 1 year ago
The same mistake,why?
The same mistake here too
This function only works after you exported results.
You need to check which slots exist here adata_vis.uns['mod'].keys()
.
Its possible that you don't have the slot for means only for quantiles so you need to change mod.plot_QC()
argument summary_name: str = "means"
.
In general, please provide more details as suggested in the template including which steps have already been performed, whether you are loading results after training or continuing a single notebook session, etc.
I am also experiencing the same error even tough adata_ref.uns['mod'].keys() returns 'post_sample_means'
How can I solve it?
Thank you!
adata_ref = mod.export_posterior( adata_ref, use_quantiles=True,
add_to_varm=['means', "q05","q50", "q95", "q0001"],
sample_kwargs={'batch_size': 2500}
) mod.plot_QC()
KeyError Traceback (most recent call last) Cell In[52], line 1 ----> 1 mod.plot_QC()
File C:\Users\Public\Anaconda3\envs\cell2loc_env\lib\site-packages\cell2location\models\reference_reference_model.py:294, in RegressionModel.plot_QC(self, summary_name, use_n_obs, scale_average_detection) 265 def plot_QC( 266 self, 267 summary_name: str = "means", 268 use_n_obs: int = 1000, 269 scale_average_detection: bool = True, 270 ): 271 """ 272 Show quality control plots: 273 1. Reconstruction accuracy to assess if there are any issues with model training. (...) 291 292 """ --> 294 super().plot_QC(summary_name=summary_name, use_n_obs=use_n_obs) 295 plt.show() 297 inf_aver = self.samples[f"postsample{summary_name}"]["per_cluster_mu_fg"].T
File C:\Users\Public\Anaconda3\envs\cell2loc_env\lib\site-packages\cell2location\models\base_pyro_mixin.py:575, in PltExportMixin.plot_QC(self, summary_name, use_n_obs) 571 else: 572 ind_x = None 574 self.expected_nb_param = self.module.model.compute_expected( --> 575 self.samples[f"postsample{summary_name}"], self.adata_manager, ind_x=ind_x 576 ) 577 x_data = self.adata_manager.get_from_registry(REGISTRY_KEYS.X_KEY)[ind_x, :] 578 if issparse(x_data):
KeyError: 'post_sample_means'
mod RegressionBackgroundDetectionTech model with the following params: n_factors: 25 n_batch: 1 Training status: Trained Model's adata is minified?: False
adata_ref.uns['mod'].keys() dict_keys(['model_name', 'date', 'factor_filter', 'factor_names', 'var_names', 'obs_names', 'post_sample_means', 'post_sample_stds', 'post_sample_q05', 'post_sample_q50', 'post_sample_q95', 'post_sample_q0001'])
Using the use_quantiles=True
option mod.export_posterior
only computes quantiles ["q05", "q50", "q95", "q0001"]
. You need to tell mod.plot_QC(summary_name="q50")
to use the median (summary_name="q50"
) or other quantiles.
Hi ! I got this error while running
mod.plot_QC()
The error is :
How can I correct it ?