Skip to content

Commit 8a44f27

Browse files
Do not inner join var by default
1 parent c7af345 commit 8a44f27

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

benj/aggregate.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from pathlib import Path
44
_PathLike=Union[str, Path]
55

6-
def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True):
6+
def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True, join_vars=None):
7+
import gc
78
from tqdm.auto import tqdm
89
import numpy as np
910
import pandas as pd
@@ -16,12 +17,15 @@ def aggregate_collection(adata, which:Union[str, List[str]]="X", view:bool=True)
1617
good_samples = pd.unique(adata.obs[adata.uns["H5AD"]["sample_key"]])
1718
for k, v in tqdm(adata.uns["H5AD"]["files"].items()):
1819
if k not in good_samples:
19-
continue
20+
continue
2021
tbl[k] = anndata.read_h5ad(v, backed="r")
2122
del tbl[k].raw
23+
if join_vars is None:
24+
del tbl[k].var
2225
if "layers" not in which and "all" not in which:
23-
del tbl[k].layers
24-
ac = AnnCollection(tbl, join_vars="inner")
26+
del tbl[k].layers
27+
gc.collect()
28+
ac = AnnCollection(tbl, join_vars=join_vars)
2529
if view:
2630
return ac[adata.obs_names, adata.var_names]
2731
else:

0 commit comments

Comments
 (0)