Skip to content

Commit

Permalink
fix component
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 25, 2024
1 parent 6c85040 commit 751facc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/datasets/loaders/allen_brain_cell_atlas/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
## VIASH START
par = {
"abca_version": "20230630",
"regions": ["CTXsp", "HPF", "HY", "Isocortex-1", "Isocortex-2", "Isocortex-3", "Isocortex-4", "MB", "OLF", "TF"],
"sample_n_obs": 500000,
"regions": ["MB", "TF"],
"sample_n_obs": 5000,
"sample_obs_weight": "subclass",
"sample_transform": "sqrt",
"sample_seed": None,
Expand Down Expand Up @@ -54,7 +54,7 @@
print("Filtering obs based on regions", flush=True)
obs = obs[obs["anatomical_division_label"].isin(REGIONS)]

if par["sample_n_obs"]:
if par["sample_n_obs"] and par["sample_n_obs"] < obs.shape[0]:
print("Filtering obs based on n_obs", flush=True)
col = par["sample_obs_weight"]

Expand Down Expand Up @@ -85,14 +85,11 @@

adata = ad.read_h5ad(str(adata_path))

adata_ = adata[adata.obs_names.isin(obs.index)]
adata = adata[adata.obs_names.isin(obs.index)]
adata.obs["region"] = region
counts = adata.X
del adata.X

# make sure counts is sparse
if not isinstance(counts, sp.sparse.csr_matrix):
counts = sp.sparse.csr_matrix(counts)
adata.layers["counts"] = counts

# add anndata to list
Expand Down

0 comments on commit 751facc

Please sign in to comment.