How to rename genes in an anndata object?

What would be the most straightforward way to change gene names in the AnnData object?

Hi @bsierieb1,

You can just do the following:

adata.var_names = new_gene_names_in_correct_order

The second list can be created by, e.g.:
new_gene_names_in_correct_order = ['newName' if id=='gene A' else id for id in adata.var_names]

1 Like

Great, thanks a lot!