Skip to content

Commit

Permalink
simplify index iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
fmalmeida committed Oct 30, 2024
1 parent efd6299 commit f357fd7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions modules/local/templates/mtx_to_h5ad_kallisto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions modules/local/templates/mtx_to_h5ad_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit f357fd7

Please sign in to comment.