From efb89bdcd1ee2858274a5e72124183a10444170e Mon Sep 17 00:00:00 2001 From: Erick Armingol Date: Thu, 1 Feb 2024 13:08:35 +0000 Subject: [PATCH] Fixed bug when adata.raw is None --- sccellfie/preprocessing/prepare_inputs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sccellfie/preprocessing/prepare_inputs.py b/sccellfie/preprocessing/prepare_inputs.py index f47bd89..23cf43d 100644 --- a/sccellfie/preprocessing/prepare_inputs.py +++ b/sccellfie/preprocessing/prepare_inputs.py @@ -73,7 +73,9 @@ def preprocess_inputs(adata, gpr_info, task_by_gene, rxn_by_gene, task_by_rxn, v task_by_rxn = task_by_rxn.loc[(task_by_rxn != 0).any(axis=1)] adata2 = adata[:, [True if g in genes else False for g in adata.var_names]] - adata2.raw = adata.raw.to_adata()[:, [True if g in genes else False for g in adata.var_names]] + if hasattr(adata, 'raw'): + if adata.raw is not None: + adata2.raw = adata.raw.to_adata()[:, [True if g in genes else False for g in adata.var_names]] if verbose: print(f'Shape of new adata object: {adata2.shape}\n'