Skip to content

Commit 4589ee4

Browse files
committed
fix abca script
1 parent d6ca3be commit 4589ee4

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

scripts/create_resources/process_allen_brain_cell_atlas_brain.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ param_list:
1818
- CTXsp
1919
- HPF
2020
- HY
21-
- Isocortex-1
22-
- Isocortex-2
23-
- Isocortex-3
24-
- Isocortex-4
21+
- Isocortex
2522
- MB
2623
- OLF
2724
- TH

src/datasets/loaders/allen_brain_cell_atlas/script.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
from collections import defaultdict
55
import anndata as ad
66
from abc_atlas_access.abc_atlas_cache.abc_project_cache import AbcProjectCache
7+
import re
78

89
## VIASH START
910
par = {
1011
"abca_version": "20230630",
11-
"regions": ["MB", "TF"],
12+
"regions": ["MB", "TH"],
1213
"sample_n_obs": 5000,
1314
"sample_obs_weight": "subclass",
1415
"sample_transform": "sqrt",
@@ -76,13 +77,24 @@
7677
# TODO: potentially also load other chemistries (currently only 10Xv2)
7778

7879
print("Downloading and reading expression matrices", flush=True)
80+
abca_data_subdir="WMB-10Xv2"
81+
abca_region_files = [
82+
[file, region]
83+
for file in abc_cache.list_data_files(abca_data_subdir)
84+
for region in REGIONS
85+
if re.match(f"WMB-10Xv2-{region}[\\-0-9]*/raw", file)
86+
]
87+
7988
adatas = []
80-
for region in REGIONS:
89+
for region, abca_data_file in abca_region_files:
8190
try:
82-
print(f"Downloading h5ad file for region {region}", flush=True)
83-
adata_path = abc_cache.get_data_path(directory="WMB-10Xv2", file_name=f"WMB-10Xv2-{region}/raw")
91+
print(f"Downloading file {abca_data_file} for region {region}", flush=True)
92+
adata_path = abc_cache.get_data_path(
93+
directory=abca_data_subdir,
94+
file_name=abca_data_file
95+
)
8496

85-
print(f"Reading h5ad for region {region}", flush=True)
97+
print(f"Reading file {adata_path}", flush=True)
8698
adata = ad.read_h5ad(str(adata_path))
8799

88100
if not par["keep_files"]:
@@ -91,9 +103,6 @@
91103
# filter cells
92104
adata = adata[adata.obs_names.isin(obs.index)].copy()
93105

94-
# add region to obs
95-
adata.obs["region"] = region
96-
97106
# move counts to layer
98107
adata.layers["counts"] = adata.X
99108
del adata.X

0 commit comments

Comments
 (0)