Deleted:How to use gseapy after scanpy?
Entering edit mode
8 weeks ago
bioinfo ▴ 50


I analyzed some data using scanpy and now I want to do some pathway analysis.

I have done DE analysis between each cluster and the rest and I want to do the pathway analysis for each cluster but I have a few questions. I initially followed the instructions from here ( and did the enrichment and then I also wanted to do GSEA so I used gseapy.prerank. However, then I was trying to find a way to visualize the network so I ended up going to the gseapy documentation.

The steps of the enrichment analysis seemed the same but then I got confused with the GSEA portion. The first tutorial I found used gseapy.prerank but the second one uses gp.gsea. I was trying to understand the difference and it seems that since I already have the DE analysis I should be using the gseapy.prerank right? I tried to plot the network using the results for gseapy.prerank but I am having issues.

My two questions are:

  1. How do I decide between using gs.prerank and gs.gsea?
  2. Is the reason why I am having issues plotting the network the fact that I used the gs.prerank output?

Please see the code below.

Thank you

fig, ax = plt.subplots(figsize=(8, 8))
# init node cooridnates
#node_size = nx.get_node_attributes()
# draw node
node_size=list(nodes.Hits_ratio *1000))
# draw node label
# draw edge
edge_weight = nx.get_edge_attributes(G, 'jaccard_coef').values()
width=list(map(lambda x: x*10, edge_weight)),

The error I am getting is :

KeyError                                  Traceback (most recent call last)
<ipython-input-162-f8b5069fd046> in <module>
     10 node_size=list(nodes.Hits_ratio *1000))
     11 # draw node label
---> 12 nx.draw_networkx_labels(G,
     13 pos=pos,
     14 labels=nodes.Term.to_dict())

/usr/local/lib/python3.8/dist-packages/networkx/drawing/ in draw_networkx_labels(G, pos, labels, font_size, font_color, font_family, font_weight, alpha, bbox, horizontalalignment, verticalalignment, ax, clip_on)
   1018     text_items = {}  # there is no text collection so we'll fake one
   1019     for n, label in labels.items():
-> 1020         (x, y) = pos[n]
   1021         if not isinstance(label, str):
   1022             label = str(label)  # this makes "1" and 1 labeled the same

KeyError: 0
gsea single cell enrichR gseapy • 312 views
This thread is not open. No new answers may be added
Traffic: 1357 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6