From f357fd7ccbed89b715d1f0e1fa7b7b9ca9efeda1 Mon Sep 17 00:00:00 2001 From: Felipe Marques de Almeida Date: Wed, 30 Oct 2024 08:23:53 +0000 Subject: [PATCH] simplify index iteration --- modules/local/templates/mtx_to_h5ad_kallisto.py | 4 +--- modules/local/templates/mtx_to_h5ad_star.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/local/templates/mtx_to_h5ad_kallisto.py b/modules/local/templates/mtx_to_h5ad_kallisto.py index fab07f59..ac71fc42 100755 --- a/modules/local/templates/mtx_to_h5ad_kallisto.py +++ b/modules/local/templates/mtx_to_h5ad_kallisto.py @@ -77,9 +77,7 @@ def input_to_adata( # standard format # index are gene IDs and symbols are a column adata.var['gene_versions'] = adata.var.index - adata.var['gene_ids'] = adata.var['gene_versions'].str.split('.').str[0] - adata.var.index = adata.var["gene_ids"].values - adata.var = adata.var.drop("gene_ids", axis=1) + adata.var.index = adata.var['gene_versions'].str.split('.').str[0] adata.var_names_make_unique() # write results diff --git a/modules/local/templates/mtx_to_h5ad_star.py b/modules/local/templates/mtx_to_h5ad_star.py index 5614e698..aa0cd02f 100755 --- a/modules/local/templates/mtx_to_h5ad_star.py +++ b/modules/local/templates/mtx_to_h5ad_star.py @@ -64,9 +64,7 @@ def input_to_adata( # index are gene IDs and symbols are a column adata.var["gene_symbol"] = adata.var.index adata.var['gene_versions'] = adata.var["gene_ids"] - adata.var['gene_ids'] = adata.var['gene_versions'].str.split('.').str[0] - adata.var.index = adata.var["gene_ids"].values - adata.var = adata.var.drop("gene_ids", axis=1) + adata.var.index = adata.var['gene_versions'].str.split('.').str[0] # write results adata.write_h5ad(f"{output}")