KeyError: 'gene_symbol' in ppi_deg.plot_network
Please make sure these conditions are met
- [x] I have checked that this issue has not already been reported.
- [x] I have confirmed this bug exists on the latest version of omicverse.
- [ ] (optional) I have confirmed this bug exists on the main branch of omicverse.
What happened?
input gene list blow: ['JUN', 'IER2', 'FOS', 'JUNB', 'TEX14', 'DUSP1', 'ZFP36L2', 'RBM38', 'RPS4X', 'FOSB', 'DUSP2', 'DNAJB1', 'TUBA1A', 'CROCC', 'HIST1H4C', 'ZNF331', 'LINC01578', 'LINC00910', 'MGAT4A', 'BTG2', 'C12orf57', 'AL499604.1', 'H3F3B', 'CITED2', 'OSER1', 'BTG1', 'PER1', 'ARRDC2', 'ODC1', 'RPS13', 'CXCR4', 'EIF5A', 'RPL36AL', 'NFKBIA', 'RPL5', 'HNRNPA0', 'EIF1', 'YPEL5', 'RPL3', 'RPL6', 'SNHG5', 'RPL32', 'PNRC1', 'JUND', 'HOOK2', 'TSC22D3', 'SARAF', 'NACA', 'RPS5', 'RPS3', 'LEPROTL1', 'SNHG8', 'KLF2', 'RPS23', 'RPL11', 'SLC2A3', 'SBDS', 'RPL30', 'RPS27A', 'EEF1B2', 'PIK3IP1', 'IER5', 'NPM1', 'ABLIM1', 'SNHG1', 'ATP6V1G1', 'LAPTM5', 'RPL8', 'CIRBP', 'RGCC', 'VAMP2', 'RPS15A', 'ITM2A', 'EEF1A1', 'RPL29', 'RPL9', 'RPL7', 'AIF1', 'COX4I1', 'RPL24', 'TBCC', 'EIF2S3', 'PHB2', 'RPL14', 'TNFAIP3', 'TOMM7', 'PFDN5', 'APOO', 'RPL18A', 'EEF1D', 'RPL35A', 'RBM3', 'GADD45B', 'H1FX', 'RPL19', 'KDM6B', 'RPS14', 'RPL22', 'ZBTB10', 'AC022217.3']
Minimal code sample
def run_ppi(df,group, topn=50):
gene = df['gene'].head(topn)
ppi_deg = ov.bulk.pyPPI(gene= gene,
gene_type_dict= dict(zip(gene, ['up']*topn)),
gene_color_dict= dict(zip(gene, ['#4DBBD5FF']*topn)),
species=9606)
ppi_deg.interaction_analysis()
fig2, axes2 = ppi_deg.plot_network(
figsize = (12,12),
plot_node_num = topn,
pos_type = 'kamada_kawai', #'kamada_kawai',
node_size= 20
)
fig2.savefig("{}_gene_ppi.pdf".format(group), bbox_inches='tight', dpi=300)
Error output
KeyError Traceback (most recent call last)
Cell In[45], line 1
----> 1 run_ppi(df7,"CD4_T_naive_Ab_vs_Ag_PBMC")
Cell In[42], line 9, in run_ppi(df, group, topn)
3 ppi_deg = ov.bulk.pyPPI(gene= gene,
4 gene_type_dict= dict(zip(gene, ['up']*topn)),
5 gene_color_dict= dict(zip(gene, ['#4DBBD5FF']*topn)),
6 species=9606)
7 ppi_deg.interaction_analysis()
----> 9 fig2, axes2 = ppi_deg.plot_network(
10 figsize = (12,12),
11 plot_node_num = topn,
12 pos_type = 'kamada_kawai', #'kamada_kawai',
13 node_size= 20
14 )
15 fig2.savefig("{}_gene_ppi.pdf".format(group), bbox_inches='tight', dpi=300)
File /mnt/p0/biotools/python-3.10.12/lib/python3.10/site-packages/omicverse/bulk/_network.py:220, in pyPPI.plot_network(self, **kwargs)
210 def plot_network(self,**kwargs) -> Tuple[matplotlib.figure.Figure,matplotlib.axes._axes.Axes]:
211 r"""Plot protein-protein interaction network.
212
213 Arguments:
(...)
218 ax: Axes object containing PPI network plot
219 """
--> 220 return plot_network(self.G,self.gene_type_dict,self.gene_color_dict,**kwargs)
File /mnt/p0/biotools/python-3.10.12/lib/python3.10/site-packages/omicverse/utils/_plot.py:639, in plot_network(G, G_type_dict, G_color_dict, pos_type, pos_dim, figsize, pos_scale, pos_k, pos_alpha, node_size, node_alpha, node_linewidths, plot_node, plot_node_num, label_verticalalignment, label_fontsize, label_fontfamily, label_fontweight, label_bbox, legend_bbox, legend_ncol, legend_fontsize, legend_fontweight)
636 pos=nx.kamada_kawai_layout(G,dim=pos_dim,scale=pos_scale)
637 degree_dict = dict(G.degree(G.nodes()))
--> 639 G_color_dict=dict(zip(G.nodes,[G_color_dict[i] for i in G.nodes]))
640 G_type_dict=dict(zip(G.nodes,[G_type_dict[i] for i in G.nodes]))
642 nx.draw_networkx_edges(G, pos,nodelist=list(G_color_dict.keys()), alpha=pos_alpha)
File /mnt/p0/biotools/python-3.10.12/lib/python3.10/site-packages/omicverse/utils/_plot.py:639, in <listcomp>(.0)
636 pos=nx.kamada_kawai_layout(G,dim=pos_dim,scale=pos_scale)
637 degree_dict = dict(G.degree(G.nodes()))
--> 639 G_color_dict=dict(zip(G.nodes,[G_color_dict[i] for i in G.nodes]))
640 G_type_dict=dict(zip(G.nodes,[G_type_dict[i] for i in G.nodes]))
642 nx.draw_networkx_edges(G, pos,nodelist=list(G_color_dict.keys()), alpha=pos_alpha)
KeyError: 'H4C6'
Versions
🔬 Starting plot initialization...
🧬 Detecting GPU devices…
✅ NVIDIA CUDA GPUs detected: 1
• [CUDA 0] NVIDIA RTX A5500
Memory: 22.1 GB | Compute: 8.6
____ _ _ __
/ __ \____ ___ (_)___| | / /__ _____________
/ / / / __ `__ \/ / ___/ | / / _ \/ ___/ ___/ _ \
/ /_/ / / / / / / / /__ | |/ / __/ / (__ ) __/
\____/_/ /_/ /_/_/\___/ |___/\___/_/ /____/\___/
🔖 Version: 1.7.8 📚 Tutorials: https://omicverse.readthedocs.io/
✅ plot_set complete.