Open chengarthur opened 1 year ago
Hi! I'm having the same issue. I don't have "spot_factors". Were you able to resolve this?
You need to use the latest version and follow the instructions from the scvi-tools tutorial. This variable was called "spot_factors" in 2020-2021.
I run the standard tutorial and export my posterior to mdo https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_tutorial.html
however when I tried the furthur downstream analysis pipeline I found it incompatible : https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_short_demo_downstream.html
here is the notebook that I tried to run NMF separately
However .there is no key in ['post_sample_q05'] named as ['spot_factors']
Could you tell me how I can export this result to ['mod'] in standard pipeline ? btw, There is no cell2location.run_cell2location in main function in this version https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_short_demo_downstream.html
number of cell type combinations - educated guess assuming that most cell types don't co-locate
n_fact = int(30)
extract cell abundance from cell2location
X_data = adata_vis.uns['mod']['post_sample_q05']['spot_factors']
import cell2location.models as c2l
create model class
mod_sk = c2l.CoLocatedGroupsSklearnNMF(n_fact, X_data, n_iter = 10000, verbose = True, var_names=adata_vis.uns['mod']['fact_names'], obs_names=adata_vis.obs_names, factnames=['fact' + str(i) for i in range(n_fact)], sample_id=adata_vis.obs['sample'], init='random', random_state=0, nmf_kwd_args={'tol':0.0001})
train 5 times to evaluate stability
mod_sk.fit(n=5, n_type='restart')