Chapter 4 Helpful Tips

4.1 Handle nulls in categorical annotation

Such nulls in categorical annotation would cause trouble in VIP because it cannot be converted to string. Here is how to handle it, let’s call the annotation X_annotation:

# Cast to str from categorical
adata.obs = adata.obs.astype({'X_annotation':'str'})

# replace all of nan by ‘nan’
adata.obs["X_annotation "][adata.obs["X_annotation "].isnull()] = 'nan'

4.2 Display full traceback stack for debugging in VIP

It follows the global setting. Please set “—verbose” to launch cellxgene server.

4.3 Pitfall of using special characters

In the mode which allows user to create manual annotation in cellxgene, user should try to avoid using hyphen (“-”) in name label. It would cause client-side issue. Please try to use underscores.

4.4 Potential use for bulk or pseudo bulk sample dataset

Once the data matrix is replaced by sample x gene matrix, cellxgene VIP framework can handle regular bulk / pseudobulk RNAseq datasets. Simply replace “cells” by “samples”. All plotting functions sould still work.

4.5 Common mistakes in naming

  • “B internediate” with extra space in the end of a cell type
  • “CD4 naive” where “n” should be “N” to match the cell type used in the h5ad file

4.6 Loading h5ad file generated by SeuratDisk from R

SeuratDisk provides a convenient way to convert a Seurat object into the h5ad format. However, there are cases cellxgene VIP window would be blank when loading such h5ad file. To fix the issue, simply run the following python code to re-generate the h5ad file, which should solve the blank VIP window issue.

import scanpy as sc
adata = sc.read_h5ad(<input h5ad>)
adata.__dict__['_raw'].__dict__['_var'] = adata.__dict__['_raw'].__dict__['_var'].rename(columns={'_index': 'features'})