Open livyring opened 2 years ago
For most of the downstream analysis, you don't need to load the scvi-tools model - only the anndata object. However, to run mod.plot_QC()
you need to do exactly what the error asks: please run self.export_posterior() first
meaning to run mod.export_posterior()
with the same arguments as before.
Ok thank you. My other issue I am running into is the ability to do NCEM. When I run:
''' expected_dict = mod.module.model.compute_expected_per_cell_type( mod.samples["post_sample_q05"], mod.adata_manager )
for i, n in enumerate(mod.factornames): adata_vis.layers[n] = expected_dict['mu'][i]
adata_file = f"{run_name}/sp.h5ad" adata_vis.write(adata_file) adata_file
I get the error: RegressionBackgroundDetectionTech model with the following params: n_factors: 23 n_batch: 1 Training status: Trained
AttributeError Traceback (most recent call last)
1 frames /usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in getattr(self, name) 1206 return modules[name] 1207 raise AttributeError("'{}' object has no attribute '{}'".format( -> 1208 type(self).name, name)) 1209 1210 def setattr(self, name: str, value: Union[Tensor, 'Module']) -> None:
AttributeError: 'RegressionBackgroundDetectionTechPyroModel' object has no attribute 'compute_expected_per_cell_type'
I was also getting a similar error last night saying cell2location has no attribute "samples"
To generate cell-type specific RNA count predictions as below:
expected_dict = mod.module.model.compute_expected_per_cell_type(
mod.samples["post_sample_q05"], mod.adata_manager
)
you indeed need to runmod.export_posterior()
after loading the model.
AttributeError: 'RegressionBackgroundDetectionTechPyroModel' object has no attribute 'compute_expected_per_cell_type'
Please make sure that you are loading the cell2location model using anndata object for Visium data - not the regression model with Visium anndata.
Thank you this worked well!
I try to import my model and h5ad that was already trained, it is able to import correctly but cannot be used for downstream analysis. For example, even when I attempt to plot QC, i return an error:
What could be happening?