Skip to content

Commit

Permalink
Do not inner join var by default
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-james committed Jan 26, 2025
1 parent c7af345 commit 8a44f27
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions benj/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from pathlib import Path
_PathLike=Union[str, Path]

def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True):
def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True, join_vars=None):
import gc
from tqdm.auto import tqdm
import numpy as np
import pandas as pd
Expand All @@ -16,12 +17,15 @@ def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True)
good_samples = pd.unique(adata.obs[adata.uns["H5AD"]["sample_key"]])
for k, v in tqdm(adata.uns["H5AD"]["files"].items()):
if k not in good_samples:
continue
continue
tbl[k] = anndata.read_h5ad(v, backed="r")
del tbl[k].raw
if join_vars is None:
del tbl[k].var
if "layers" not in which and "all" not in which:
del tbl[k].layers
ac = AnnCollection(tbl, join_vars="inner")
del tbl[k].layers
gc.collect()
ac = AnnCollection(tbl, join_vars=join_vars)
if view:
return ac[adata.obs_names, adata.var_names]
else:
Expand Down

0 comments on commit 8a44f27

Please sign in to comment.