Closed cbravo93 closed 2 years ago
The issue arises when bc_transform_func = None
. Replacing:
if bc_transform_func is not None:
#transform GEX barcodes to ACC barcodes
GEX_cell_names = [bc_transform_func(bc) for bc in GEX_anndata.obs_names]
GEX_cell_metadata.index = GEX_cell_names
by
if bc_transform_func is not None:
bc_transform_func = lambda x: x
GEX_cell_names = [bc_transform_func(bc) for bc in GEX_anndata.obs_names]
GEX_cell_metadata.index = GEX_cell_names
will work (but takes its time in that operation, would be better to skip it)
Thanks for the issue.
The problem arrises because GEX_cell_names
is expected to be a python list (.index
function returns the index of the barcode).
If bc_transform_func is set GEX_cell_names
will be transformed in a list (from a pandas.Index object).
Solution is to set GEX_cell_names
to a python list when bc_transform_func
is None.
i.e.
if bc_transform_func is not None:
#transform GEX barcodes to ACC barcodes
GEX_cell_names = [bc_transform_func(bc) for bc in GEX_anndata.obs_names]
GEX_cell_metadata.index = GEX_cell_names
else:
GEX_cell_names = list(GEX_cell_names)
When creating the scenicplus_obj:
Indeed, if I check GEX_cell_names (GEX_anndata.obs_names) it looks like:
Could this be because of the scanpy version? I'm using 1.8.2