Closed lhock17 closed 1 year ago
Hi @lhock17
Thanks alot for pointing this out.
It appears there was some kind of merge operation error when we were bringing in the new Xenium tutorial that reverted some of the CCI code back to older versions (not sure how...).
Will fix it and get back to you. Currently away.
Thanks for that Brad!
Hi @lhock17
ccinet_plot is working fine for me with current stLearn version, and @duypham2108 have checked and this code hasn't changed between versions.
Wondering if you could provide more code on the preprocessing steps, and also what these data look like if you print them:
print( data.uns[f"lr_cci_cell_type"] ) print( data.uns[f"lr_cci_cell_type"].index.values ) print( data.uns['cell_type'] ) print( data.obs['cell_type'].cat.categories )
May be able to figure it out from that
Hi @BradBalderson
Thanks for your help. Here is the code from the CCI: `data = sc.read_h5ad(Path+"A1_brain_bin_80.h5ad") rctd = pd.read_csv(Path+"A1_brain_RCTD.csv",index_col=0) rctd = rctd.iloc[:2500,:] data.obs.rename(columns={"x": "imagerow", "y": "imagecol"},inplace=True)
data.obs.index = "A1_"+data.obs.index data = data[data.obs.index.isin(rctd.index)]
labels = list(rctd.idxmax(axis=1)) data.obs['cell_type'] = labels data.obs['cell_type'] = data.obs['cell_type'].astype('category') data.uns['cell_type'] = rctd
lrs = st.tl.cci.load_lrs(['connectomeDB2020_lit'], species='mouse') print(len(lrs))
st.tl.cci.run(data, lrs, min_spots = 50, distance=80, n_pairs=100, n_cpus=32)
lr_info = data.uns['lr_summary']
st.tl.cci.adj_pvals(data, correct_axis='spot', pval_adj_cutoff=0.05, adj_method='fdr_bh')
st.tl.cci.run_cci(data, 'cell_type', min_spots=50, spot_mixtures=True, sig_spots=True, n_perms=100 )`
Here are the outputs of those data, which is slightly different in each version:
Version 0.4.8:
Version 0.4.11
I also encountered this error.
st.pl.lr_chord_plot(subset, 'cell_type')
st.pl.ccinet_plot(subset, 'cell_type')
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In [101], line 1
----> 1 st.pl.lr_chord_plot(subset, 'cell_type')
2 st.pl.ccinet_plot(subset, 'cell_type')
File ~/miniconda3/envs/stlearn/lib/python3.8/site-packages/stlearn/plotting/cci_plot.py:1483, in lr_chord_plot(adata, use_label, lr, min_ints, n_top_ccis, cmap, sig_interactions, label_size, label_rotation, title, figsize, show)
1480 nodes = cell_names
1482 # Retrieving colors of cell types #
-> 1483 colors = get_colors(adata, use_label, cmap=cmap, label_set=cell_names)
1485 ax = plt.axes([0, 0, 1, 1])
1486 nodePos = chordDiagram(flux, ax, lim=1.25, colors=colors)
File ~/miniconda3/envs/stlearn/lib/python3.8/site-packages/stlearn/plotting/utils.py:141, in get_colors(adata, obs_key, cmap, label_set)
139 # Returning the colors of the desired labels in indicated order #
140 if type(label_set) != type(None):
--> 141 colors_ordered = [
142 colors_ordered[np.where(labels_ordered == label)[0][0]]
143 for label in label_set
144 ]
146 return colors_ordered
File ~/miniconda3/envs/stlearn/lib/python3.8/site-packages/stlearn/plotting/utils.py:142, in <listcomp>(.0)
139 # Returning the colors of the desired labels in indicated order #
140 if type(label_set) != type(None):
141 colors_ordered = [
--> 142 colors_ordered[np.where(labels_ordered == label)[0][0]]
143 for label in label_set
144 ]
146 return colors_ordered
IndexError: index 0 is out of bounds for axis 0 with size 0
<Figure size 800x800 with 0 Axes>
It seems something wrong in parameter _uselabel.
I fixed with the new version 0.4.12. Sorry for the delay.
Hi,
I have been consistently getting an error with st.pl.ccinet_plot since going from 0.4.8 to 0.4.11. The code I have been using is from the readthedocs CCI tutorial which worked fine in 0.4.8. Here is the traceback. Thanks