jpx
jpx

Reputation: 111

scv.pl.proportions(): numpy.AxisError in `Cellrank` workflow

I am new to use python to anlyze scRNA-seq. I run the cellrank workflow and always found this error. Here is my code for Cellrank:


import scvelo as scv
import scanpy as sc
import cellrank
import numpy as np

scv.settings.verbosity = 3
scv.settings.set_figure_params("scvelo")
cellrank.settings.verbosity = 2

import warnings

warnings.simplefilter("ignore", category=UserWarning)
warnings.simplefilter("ignore", category=FutureWarning)
warnings.simplefilter("ignore", category=DeprecationWarning)

adata =  sc.read_h5ad('./my.h5ad') # my data
**scv.pl.proportions(adata)**

The errorcode:

Traceback (most recent call last):
  File "test_cellrank.py", line 25, in <module>
    **scv.pl.proportions(adata)**
  ...........
**numpy.AxisError: axis 1 is out of bounds for array of dimension 1**

I tried to use SeuratDisk or loom to get h5ad from a seurat object. I thought that must be some problem in this progress.

Here is the anndata object from tutorial:

>>> adata
AnnData object with n_obs × n_vars = 2531 × 27998
    obs: 'day', 'proliferation', 'G2M_score', 'S_score', 'phase', 'clusters_coarse', 'clusters', 'clusters_fine', 'louvain_Alpha', 'louvain_Beta', 'palantir_pseudotime'
    var: 'highly_variable_genes'
    uns: 'clusters_colors', 'clusters_fine_colors', 'day_colors', 'louvain_Alpha_colors', 'louvain_Beta_colors', 'neighbors', 'pca'
    obsm: 'X_pca', 'X_umap'
    layers: 'spliced', 'unspliced'
    obsp: 'connectivities', 'distances'

Here is mine:

>>> adata
AnnData object with n_obs × n_vars = 5443 × 18489
    obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'percent.mt', 'nCount_SCT', 'nFeature_SCT', 'SCT_snn_res.0.8', 'seurat_clusters', 'SCT_snn_res.0.5', 'SCT_snn_res.0.6',
 'SCT_snn_res.0.7', 'S.Score', 'G2M.Score', 'Phase', 'old.ident', 'new.ident', 'nCount_MAGIC_RNA', 'nFeature_MAGIC_RNA'
    var: 'SCT_features', '_index', 'features'
    obsm: 'X_tsne', 'X_umap'
    layers: 'SCT'

So, What packages or protocols should I follow to convert a seurat into a h5ad? Thank you for your help!

Upvotes: 0

Views: 214

Answers (1)

badwolf
badwolf

Reputation: 31

scv.pl.proportions gives the proportion of spliced and unspliced reads in your dataset. These count tables must be added to your adata layers before you can call this function.

Your adata object does not have these layers. I think that is why you are seeing this error.

Conversion from Seurat to h5ad can be accomplished using two step process given here

Upvotes: 3

Related Questions