Skip to content

Commit

Permalink
(#856) Refactor create_projection_adata function to not read from h5a…
Browse files Browse the repository at this point in the history
…d file in constructor
  • Loading branch information
adkinsrs committed Aug 9, 2024
1 parent 0661e12 commit 8ee080f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions www/api/resources/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

def create_projection_adata(dataset_adata, dataset_id, projection_id):
# Create AnnData object out of readable CSV file
# ? Does it make sense to put this in the geardb/Analysis class?
projection_id = secure_filename(projection_id)
dataset_id = secure_filename(dataset_id)

Expand All @@ -34,7 +33,7 @@ def create_projection_adata(dataset_adata, dataset_id, projection_id):
obs = dataset_adata.obs
# Create the anndata object and write to h5ad
# Associate with a filename to ensure AnnData is read in "backed" mode
projection_adata = anndata.AnnData(X=X, obs=obs, var=var, obsm=dataset_adata.obsm, filename=projection_adata_path, filemode='r')
projection_adata = anndata.AnnData(X=X, obs=obs, var=var, obsm=dataset_adata.obsm, filemode='r')
except Exception as e:
print(str(e), file=sys.stderr)
raise PlotError("Could not create projection AnnData object from CSV.")
Expand All @@ -45,6 +44,10 @@ def create_projection_adata(dataset_adata, dataset_id, projection_id):
# For some reason the gene_symbol is not taken in by the constructor
projection_adata.var["gene_symbol"] = projection_adata.var_names

# Associate with a filename to ensure AnnData is read in "backed" mode
# This creates the h5ad file if it does not exist
projection_adata.filename = projection_adata_path

return projection_adata

def order_by_time_point(obs_df):
Expand Down

0 comments on commit 8ee080f

Please sign in to comment.