You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use the code "r = cell2location.models.Cell2location", it gave me an error: TypeError: LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.init() got an unexpected keyword argument 'summ_sc_data_args‘
Here are the code and outputs
sc.settings.set_figure_params(dpi = 100, color_map = 'viridis', dpi_save = 100,
vector_friendly = True, format = 'pdf',
facecolor='white')
r = cell2location.models.Cell2location(
# Single cell reference signatures as pd.DataFrame
# (could also be data as anndata object for estimating signatures
# as cluster average expression - `sc_data=adata_snrna_raw`)
adata_vis,inf_aver,
# Spatial data as anndata object
# the column in sc_data.obs that gives cluster idenitity of each cell
summ_sc_data_args={'cluster_col': "cell_type",
},
train_args={'use_raw': True, # By default uses raw slots in both of the input datasets.
'n_iter': 40000, # Increase the number of iterations if needed (see QC below)
# Whe analysing the data that contains multiple experiments,
# cell2location automatically enters the mode which pools information across experiments
'sample_name_col': 'sample'}, # Column in sp_data.obs with experiment ID (see above)
export_args={'path': results_folder, # path where to save results
'run_name_suffix': '' # optinal suffix to modify the name the run
},
model_kwargs={ # Prior on the number of cells, cell types and co-located groups
'cell_number_prior': {
# - N - the expected number of cells per location:
'cells_per_spot': 8, # < - change this
# - A - the expected number of cell types per location (use default):
'factors_per_spot': 7,
# - Y - the expected number of co-located cell type groups per location (use default):
'combs_per_spot': 7
},
# Prior beliefs on the sensitivity of spatial technology:
'gene_level_prior':{
# Prior on the mean
'mean': 1/2,
# Prior on standard deviation,
# a good choice of this value should be at least 2 times lower that the mean
'sd': 1/4
}
}
)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[35], line 5
1 sc.settings.set_figure_params(dpi = 100, color_map = 'viridis', dpi_save = 100,
2 vector_friendly = True, format = 'pdf',
3 facecolor='white')
----> 5 r = cell2location.models.Cell2location(
6
7 # Single cell reference signatures as pd.DataFrame
8 # (could also be data as anndata object for estimating signatures
9 # as cluster average expression - `sc_data=adata_snrna_raw`)
10 adata_vis,inf_aver,
11 # Spatial data as anndata object
12
13 # the column in sc_data.obs that gives cluster idenitity of each cell
14 summ_sc_data_args={'cluster_col': "cell_type",
15 },
16
17 train_args={'use_raw': True, # By default uses raw slots in both of the input datasets.
18 'n_iter': 40000, # Increase the number of iterations if needed (see QC below)
19
20 # Whe analysing the data that contains multiple experiments,
21 # cell2location automatically enters the mode which pools information across experiments
22 'sample_name_col': 'sample'}, # Column in sp_data.obs with experiment ID (see above)
23
24
25 export_args={'path': results_folder, # path where to save results
26 'run_name_suffix': '' # optinal suffix to modify the name the run
27 },
28
29 model_kwargs={ # Prior on the number of cells, cell types and co-located groups
30
31 'cell_number_prior': {
32 # - N - the expected number of cells per location:
33 'cells_per_spot': 8, # < - change this
34 # - A - the expected number of cell types per location (use default):
35 'factors_per_spot': 7,
36 # - Y - the expected number of co-located cell type groups per location (use default):
37 'combs_per_spot': 7
38 },
39
40 # Prior beliefs on the sensitivity of spatial technology:
41 'gene_level_prior':{
42 # Prior on the mean
43 'mean': 1/2,
44 # Prior on standard deviation,
45 # a good choice of this value should be at least 2 times lower that the mean
46 'sd': 1/4
47 }
48 }
49 )
File ~/anaconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:115, in Cell2location.__init__(self, adata, cell_state_df, model_class, detection_mean_per_sample, detection_mean_correction, **model_kwargs)
110 self.detection_alpha_ = pd.Series(detection_alpha)[batch_mapping]
111 model_kwargs["detection_alpha"] = self.detection_alpha_.values.reshape(
112 (self.summary_stats["n_batch"], 1)
113 ).astype("float32")
--> 115 self.module = Cell2locationBaseModule(
116 model=model_class,
117 n_obs=self.summary_stats["n_cells"],
118 n_vars=self.summary_stats["n_vars"],
119 n_factors=self.n_factors_,
120 n_batch=self.summary_stats["n_batch"],
121 cell_state_mat=self.cell_state_df_.values.astype("float32"),
122 **model_kwargs,
123 )
124 self._model_summary_string = f'cell2location model with the following params: \nn_factors: {self.n_factors_} \nn_batch: {self.summary_stats["n_batch"]} '
125 self.init_params_ = self._get_init_params(locals())
File ~/anaconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/base/_pyro_base_loc_module.py:39, in Cell2locationBaseModule.__init__(self, model, amortised, encoder_mode, encoder_kwargs, data_transform, create_autoguide_kwargs, **kwargs)
36 super().__init__()
37 self.hist = []
---> 39 self._model = model(**kwargs)
40 self._amortised = amortised
41 if create_autoguide_kwargs is None:
TypeError: LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.__init__() got an unexpected keyword argument 'summ_sc_data_args'
The text was updated successfully, but these errors were encountered:
Please use latest tutorial for reference - it is mentioned in readme and is the only tutorial on the documentation website. The tutorial via the link you provided is from a very old 2020/2021 cell2location version.
The latest tutorial ''https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_tutorial.html'' was just where I found the link to the previous notebook. In the "Loading Visium and scRNA-seq reference data" section, the tutorial tells us "See this tutorial for a more extensive and practical example of data loading (multiple visium samples)." The link will directly lead you to the cell2location_short_demo tutorial.
I still have no clue on how to introduce the multi-sample mode, the "COMMON ERRORS" section says that "if you have multiple expreriments try analysing them jointly in the multi-sample mode (detected automatically based on 'sample_name_col': 'sample')." Could you tell me or give me an example on how to input the argument “'sample_name_col': 'sample'”?
I was trying to mapping multiple slides multiple slides using my own snRNA and Visium data, flowing the tutorials (https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_short_demo.html).
When I use the code "r = cell2location.models.Cell2location", it gave me an error: TypeError: LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.init() got an unexpected keyword argument 'summ_sc_data_args‘
Here are the code and outputs
The text was updated successfully, but these errors were encountered: