zcang / COMMOT

MIT License
97 stars 13 forks source link

IndexError: single positional indexer is out-of-bounds #6

Closed beibeiru closed 1 year ago

beibeiru commented 1 year ago

Hi, Dr Cang,

COMMOT is an excellent tool for analyzing CCC in ST data.

I can run COMMOT on the sample data from your tutorial. However, I downloaded breast cancer visium data (i.e., filtered_feature_bc_matrix.h5) from https://www.10xgenomics.com/resources/datasets/human-breast-cancer-block-a-section-1-1-standard-1-1-0, and analyzed it and got the following error.

adata = sc.read_visium("./test/",count_file='filtered_feature_bc_matrix.h5') adata.var_names_make_unique()

sc.pp.normalize_total(adata, inplace=True) sc.pp.log1p(adata)

LR=np.array([['Tgfb1', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'], ['Tgfb2', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'], ['Tgfb3', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'], ['Fgf1', 'Fgfr1', 'FGF_pathway'], ['Fgf1', 'Fgfr2', 'FGF_pathway']],dtype=str) df_ligrec = pd.DataFrame(data=LR)

ct.tl.spatial_communication(adata, database_name='user_database', df_ligrec=df_ligrec, dis_thr=500, heteromeric=True, pathway_sum=True)

Traceback (most recent call last): File "", line 1, in File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/commot/tools/_spatial_communication.py", line 418, in spatial_communication model = CellCommunication(adata, File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/commot/tools/_spatial_communication.py", line 71, in init tmp_recs = list(set(df_ligrec.iloc[:,1])) File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/pandas/core/indexing.py", line 925, in getitem return self._getitem_tuple(key) File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/pandas/core/indexing.py", line 1506, in _getitem_tuple self._has_valid_tuple(tup) File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/pandas/core/indexing.py", line 754, in _has_valid_tuple self._validate_key(k, i) File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/pandas/core/indexing.py", line 1409, in _validate_key self._validate_integer(key, axis) File "/home/rub2/miniconda3/envs/commot_env/lib/python3.9/site-packages/pandas/core/indexing.py", line 1500, in _validate_integer raise IndexError("single positional indexer is out-of-bounds") IndexError: single positional indexer is out-of-bounds

Thanks.

Best, Beibei

zcang commented 1 year ago

Hi, these example LR pairs are for the example mouse dataset. You could use the database here: https://commot.readthedocs.io/en/latest/api/commot.pp.ligand_receptor_database.html with species set to human, or make your own database with the ligand and receptor names matching the gene names in data.