Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when conducting CCI analysis using human DB #315

Open
CenFWNW opened this issue Feb 21, 2025 · 0 comments
Open

Issue when conducting CCI analysis using human DB #315

CenFWNW opened this issue Feb 21, 2025 · 0 comments

Comments

@CenFWNW
Copy link

CenFWNW commented Feb 21, 2025

Hi,

Thank you for creating this great tool! I have been working on serial CosMx data 3D reconstruction and it worked really well. There is an issue encountered when I was trying to conduct CCI analysis on the re-constructed data set, here is my issue:

First, I saved my aligned cell coordinates to the adata.obsm['aligned_spatial_3D'], they look like:

Image

I then followed the tutorial to find neighbor by using the following codes:

_, aligned_adata = st.tl.neighbors(
aligned_adata,
basis='spatial',
spatial_key='aligned_spatial_3D',
n_neighbors=20
)

The first issue happened here is 'distances' and 'connectivities' slot was not created by the function, what I did was:
aligned_adata.obsp['distances'] = aligned_adata.obsp['spatial_distances']
aligned_adata.obsp['connectivities'] = aligned_adata.obsp['spatial_connectivities']

Then the plot_connections function worked fine:
st.pl.plot_connections(
aligned_adata,
cat_key='cell_type',
save_show_or_return='show'
)

next by following the tutorial, I ran:
sender_ct = 'Epithelial_1'
receptor_ct = 'Epithelial_2'

st.tl.prepare_cci_cellpair_adata(aligned_adata, sender_group=sender_ct,
receiver_group=receptor_ct, group='cell_type', all_cell_pair=True)

res = st.tl.find_cci_two_group(aligned_adata,
path="~/",
species='human',
group='cell_type',
sender_group=sender_ct,
receiver_group=receptor_ct,
#lr_pair=None,
filter_lr='inner',
min_pairs=0,
min_pairs_ratio=0,
top=20,)

Here returns an wired error:


KeyError Traceback (most recent call last)
Cell In[79], line 1
----> 1 res = st.tl.find_cci_two_group(aligned_adata,
2 path="~/",
3 species='human',
4 group='cell_type',
5 sender_group=sender_ct,
6 receiver_group=receptor_ct,
7 #lr_pair=None,
8 filter_lr='inner',
9 min_pairs=0,
10 min_pairs_ratio=0,
11 top=20,)

File ~/.local/lib/python3.11/site-packages/spateo/configuration.py:204, in SpateoAdataKeyManager.check_adata_is_type..decorator..wrapper(*args, **kwargs)
202 else:
203 raise ConfigurationError(f"AnnData is not AnnData object, but {type(adata)}.")
--> 204 return func(*args, **kwargs)

File ~/.local/lib/python3.11/site-packages/spateo/tools/cci_two_cluster.py:241, in find_cci_two_group(adata, path, species, layer, group, lr_pair, sender_group, receiver_group, mode, filter_lr, top, spatial_neighbors, spatial_distances, min_cells_by_counts, min_pairs, min_pairs_ratio, num, pvalue, fdr)
180 ligands = [
181 l
182 for l in ligands_test
(...)
237 ]
238 ]
240 # ligand_sender_spec
--> 241 adata_l = adata[:, ligands]
242 for g in adata.obs[group_sp].unique():
243 # Of all cells expressing particular ligand, what proportion are group g:
244 frac = (adata_l[adata_l.obs[group_sp] == g].X > 0).sum(axis=0) / (adata_l.X > 0).sum(axis=0)

File ~/.local/lib/python3.11/site-packages/anndata/_core/anndata.py:1085, in AnnData.getitem(self, index)
1083 def getitem(self, index: Index) -> AnnData:
1084 """Returns a sliced view of the object."""
-> 1085 oidx, vidx = self._normalize_indices(index)
1086 return AnnData(self, oidx=oidx, vidx=vidx, asview=True)

File ~/.local/lib/python3.11/site-packages/anndata/_core/anndata.py:1066, in AnnData._normalize_indices(self, index)
1065 def _normalize_indices(self, index: Index | None) -> tuple[slice, slice]:
-> 1066 return _normalize_indices(index, self.obs_names, self.var_names)

File ~/.local/lib/python3.11/site-packages/anndata/_core/index.py:36, in _normalize_indices(index, names0, names1)
34 ax0, ax1 = unpack_index(index)
35 ax0 = _normalize_index(ax0, names0)
---> 36 ax1 = _normalize_index(ax1, names1)
37 return ax0, ax1

File ~/.local/lib/python3.11/site-packages/anndata/_core/index.py:100, in _normalize_index(indexer, index)
98 if np.any(positions < 0):
99 not_found = indexer[positions < 0]
--> 100 raise KeyError(
101 f"Values {list(not_found)}, from {list(indexer)}, "
102 "are not valid obs/ var names or indices."
103 )
104 return positions # np.ndarray[int]
105 else:

KeyError: "Values ['Efna4', 'Tgfb2', 'Egf', 'Il20', 'Ccl5', 'Csf2', 'Tnfsf9', 'Il17b', 'Pdgfb', 'Vegfa', 'Wnt5b', 'Ccl2', 'Ccl28', 'Csf3', 'Angptl1', 'Igf2', 'Wnt7b', 'Il15', 'Il1a', 'Il17a', 'Klk3', 'Ccl13', 'Areg', 'Cxcl16', 'Vegfc', 'Ccl21', 'Efnb2', 'Col1a1', 'Il12a', 'Selplg', 'Tnfsf13b', 'Tnfsf12', 'Wnt7a', 'Col9a3', 'Inha', 'Fgf9', 'Gdf15', 'Pgf', 'Thbs1', 'Pecam1', 'Col4a1', 'Il33', 'Ccl19', 'Col9a2', 'Cxcl12', 'Thbs2', 'Cd274', 'Bmp4', 'Mif', 'Inhba', 'Csf1', 'Spp1', 'Il23a', 'Dll1', 'Tnfsf10', 'Vtn', 'Il18', 'Cd70', 'Ifng', 'Cd209', 'Ccl8', 'Tnf', 'Pdgfa', 'Wnt3', 'Il1b', 'Jag1', 'Ltb', 'Cxcl8', 'Il7', 'Lif', 'Col6a3', 'Cdh1', 'Itgb2', 'Itgb1', 'Efna1', 'Efnb1', 'Bmp7', 'Cdh5', 'Fgf2', 'Angpt2', 'Hla-dqa1', 'Il10', 'Ptprc', 'Tgfb3', 'Il6', 'Wnt9a', 'Ccl18', 'Cxcl9', 'Anxa1', 'Il12b', 'Vegfd', 'Cd86', 'Rarres2', 'Ins', 'Fgf1', 'Clcf1', 'Osm', 'Cxcl10', 'Nppc', 'Cxcl5', 'Clec2b', 'Sell', 'App', 'Il2', 'Fgf7', 'Inhbb', 'Clec2d', 'Tgfb1', 'Adgre5', 'Esam', 'Angpt1', 'Il16', 'Hla-dpa1', 'Cx3cl1', 'Col1a2', 'Hla-dpb1', 'Ccl15', 'Fgf18', 'Nrg1', 'Ccl11', 'Efna5', 'Bmp2', 'Cd80', 'Il24', 'Kitlg', 'Faslg', 'Gas6', 'Vegfb', 'Col4a5', 'Icam2', 'Hgf', 'Itga9', 'Bmp5', 'Igf1', 'Lgals9', 'Il36g', 'Hla-dra', 'Il34', 'Pdgfc', 'Vwf', 'Tnfsf4', 'Wnt5a', 'Tnfsf14', 'Pdgfd', 'Icoslg', 'Wnt10b', 'Col6a2', 'Icam1', 'Col6a1', 'Dll4', 'Cd69', 'Pdcd1lg2', 'Col4a2', 'Wnt11', 'Fn1', 'Cd40lg', 'Il11'], from ['Efna4', 'Tgfb2', 'Egf', 'Il20', 'Ccl5', 'Csf2', 'Tnfsf9', 'Il17b', 'Pdgfb', 'Vegfa', 'Wnt5b', 'Ccl2', 'Ccl28', 'Csf3', 'Angptl1', 'Igf2', 'Wnt7b', 'Il15', 'Il1a', 'Il17a', 'Klk3', 'Ccl13', 'Areg', 'Cxcl16', 'Vegfc', 'Ccl21', 'Efnb2', 'Col1a1', 'Il12a', 'Selplg', 'Tnfsf13b', 'Tnfsf12', 'Wnt7a', 'Col9a3', 'Inha', 'Fgf9', 'Gdf15', 'Pgf', 'Thbs1', 'Pecam1', 'Col4a1', 'Il33', 'Ccl19', 'Col9a2', 'Cxcl12', 'Thbs2', 'Cd274', 'Bmp4', 'Mif', 'Inhba', 'Csf1', 'Spp1', 'Il23a', 'Dll1', 'Tnfsf10', 'Vtn', 'Il18', 'Cd70', 'Ifng', 'Cd209', 'Ccl8', 'Tnf', 'Pdgfa', 'Wnt3', 'Il1b', 'Jag1', 'Ltb', 'Cxcl8', 'Il7', 'Lif', 'Col6a3', 'Cdh1', 'Itgb2', 'Itgb1', 'Efna1', 'Efnb1', 'Bmp7', 'Cdh5', 'Fgf2', 'Angpt2', 'Hla-dqa1', 'Il10', 'Ptprc', 'Tgfb3', 'Il6', 'Wnt9a', 'Ccl18', 'Cxcl9', 'Anxa1', 'Il12b', 'Vegfd', 'Cd86', 'Rarres2', 'Ins', 'Fgf1', 'Clcf1', 'Osm', 'Cxcl10', 'Nppc', 'Cxcl5', 'Clec2b', 'Sell', 'App', 'Il2', 'Fgf7', 'Inhbb', 'Clec2d', 'Tgfb1', 'Adgre5', 'Esam', 'Angpt1', 'Il16', 'Hla-dpa1', 'Cx3cl1', 'Col1a2', 'Hla-dpb1', 'Ccl15', 'Fgf18', 'Nrg1', 'Ccl11', 'Efna5', 'Bmp2', 'Cd80', 'Il24', 'Kitlg', 'Faslg', 'Gas6', 'Vegfb', 'Col4a5', 'Icam2', 'Hgf', 'Itga9', 'Bmp5', 'Igf1', 'Lgals9', 'Il36g', 'Hla-dra', 'Il34', 'Pdgfc', 'Vwf', 'Tnfsf4', 'Wnt5a', 'Tnfsf14', 'Pdgfd', 'Icoslg', 'Wnt10b', 'Col6a2', 'Icam1', 'Col6a1', 'Dll4', 'Cd69', 'Pdcd1lg2', 'Col4a2', 'Wnt11', 'Fn1', 'Cd40lg', 'Il11'], are not valid obs/ var names or indices."

I tried to convert my human gene symbols to the upcase+lowercase format but returned error:

Image

Please suggest what is the best solution, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant