Skip to content

Commit

Permalink
apply more stringent filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 25, 2024
1 parent 8bd0a33 commit f9cb326
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/datasets/loaders/allen_brain_cell_atlas/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
adata = ad.read_h5ad(
TMP_DIR / f"expression_matrices/WMB-10Xv2/{VERSION}/WMB-10Xv2-{region}-raw.h5ad"
)
sc.pp.filter_cells(adata, min_genes=5)
sc.pp.filter_cells(adata, min_counts=50)

adata = adata[adata.obs_names.isin(obs.index)]
adata.obs["region"] = region
counts = adata.X
Expand All @@ -82,14 +85,6 @@
adata = ad.concat(adatas, merge="first")
del adatas

print("Filtering data", flush=True)
num_cells_per_gene = adata.layers["counts"].getnnz(axis=0)
num_genes_per_cell = adata.layers["counts"].getnnz(axis=1)
adata = adata[
num_genes_per_cell >= 1,
num_cells_per_gene >= 1
].copy()

print("Processing .obs")
adata.obs = obs.loc[adata.obs.index]

Expand Down

0 comments on commit f9cb326

Please sign in to comment.