Error scanpy pbmc data

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

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

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

1 Like

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

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

1 Like

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)