# Error scanpy pbmc data

**URL:** <https://discourse.scverse.org/t/error-scanpy-pbmc-data/542>\
**Category:** scanpy\
**Created:** [June 14, 2022, 3:31pm UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542 "2022-06-14T15:31:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rexneal](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@rexneal](https://discourse.scverse.org/u/rexneal)\
**Post date:** [June 14, 2022, 3:31pm UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542/1 "2022-06-14T15:31:29Z")

</div>

I am a newbie to scanpy. It seems to be a wonderful program.  
I am working through the tutuoial:[Preprocessing and clustering 3k PBMCs — Scanpy documentation](https://scanpy-tutorials.readthedocs.io/en/latest/pbmc3k.html)

I get the following error message:  
tl.paga(adata)  
pl.paga(adata, plot=False) # remove `plot=False` if you want to see the coarse-grained graph  
tl.umap(adata, init\_pos=‘paga’)

* * *

NameError Traceback (most recent call last)  
 in   
----\> 1 tl.paga(adata)  
2 pl.paga(adata, plot=False) # remove `plot=False` if you want to see the coarse-grained graph  
3 tl.umap(adata, init\_pos=‘paga’)

NameError: name ‘tl’ is not defined

The remaining code is OK.  
Is this error important\>

Thanks. Neal

---

<div class="post-metadata">

**Author:** ![jeskowagner](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jeskowagner/32/218_2.png) [@jeskowagner](https://discourse.scverse.org/u/jeskowagner)\
**Post date:** [June 21, 2022, 12:51pm UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542/2 "2022-06-21T12:51:45Z")

</div>

Hi Neal,

I think this might be a typo in the tutorial. Python is telling you that it cannot find anything associated with “tl”. The reason for that is that “tl” is a submodule of scanpy. To overcome this, prefix all function calls to the “tl” submodule by “sc.” For example:

tl.paga(adata)  
Becomes  
sc.tl.paga(adata)

The same applies to the lines starting with “pp”, as this too is a submodule of scanpy.

Hope this helps!

Best,  
Jesko

---

<div class="post-metadata">

**Author:** ![rexneal](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@rexneal](https://discourse.scverse.org/u/rexneal)\
**Post date:** [June 21, 2022, 6:45pm UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542/3 "2022-06-21T18:45:17Z")

</div>

Jesko,

Thanks. This worked. Nice pick up.  
The continuing code works unti:  
result = adata.uns[‘rank\_genes\_groups’]  
groups = result[‘names’].dtype.names  
pd.DataFrame(  
{group + ‘\_’ + key[:1]: result[key][group]  
for group in groups for key in [‘names’, ‘pvals’]}).head(5)

KeyError: ‘pvals’

How do I get the ‘pvals’ in?

Thanks so much. Neal

---

<div class="post-metadata">

**Author:** ![jeskowagner](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jeskowagner/32/218_2.png) [@jeskowagner](https://discourse.scverse.org/u/jeskowagner)\
**Post date:** [June 29, 2022, 9:17am UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542/4 "2022-06-29T09:17:52Z")

</div>

Hi Neal,

Sorry for the late response. I am not one of the developers of Scanpy and therefore unsure what is going on. However, to troubleshoot, you could try `result.keys()` to inspect which keys there are in the dictionary `result`. Perhaps that could give us a pointer of your current output.

Cheers,  
Jesko

---

<div class="post-metadata">

**Author:** ![janatanmoy5](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@janatanmoy5](https://discourse.scverse.org/u/janatanmoy5)\
**Post date:** [July 25, 2023, 10:40pm UTC](https://discourse.scverse.org/t/error-scanpy-pbmc-data/542/5 "2023-07-25T22:40:58Z")

</div>

Hi Neal,

You could try this. The pvals may be replaced by scores.

result = pbmc\_concat.uns[‘rank\_genes\_groups’]  
pd.DataFrame(  
{group + ‘\_’ + key[:1]: result[key][group]  
for group in groups for key in [‘names’,‘scores’]}).head(5)
