Skip to content

Commit

Permalink
Modified batch_correct_mofa.py to add lowmem parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wlason committed Aug 20, 2024
1 parent 0bc49a4 commit 21a486e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions panpipes/panpipes/pipeline_integration/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ multimodal:
mofa:
modalities: rna,prot,atac
filter_by_hvg: True
lowmem: True
n_factors: 10
n_iterations: 1000
convergence_mode: fast
Expand Down
19 changes: 19 additions & 0 deletions panpipes/python_scripts/batch_correct_mofa.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@
L.info("Intersecting modality obs before running mofa")
mu.pp.intersect_obs(tmp)


if check_for_bool(params["multimodal"]["MultiVI"]["lowmem"]):
L.info("Running in low memory mode. Calculating and subsetting ATAC to top 25k HVF")
atac = tmp.mod['atac']

sc.pp.highly_variable_genes(atac, n_top_genes=25000)
atac = atac[:, atac.var.highly_variable].copy()

tmp.mod['atac'] = atac.copy()
del atac

tmp.update()

gc.collect()

mofa_kwargs={}
#expected args:
# n_factors: 10
Expand All @@ -106,6 +121,7 @@

mofa_kwargs = params['multimodal']['mofa']
del mofa_kwargs['modalities']
del mofa_kwargs['lowmem']

if mofa_kwargs['filter_by_hvg']:
mofa_kwargs['use_var'] = "highly_variable"
Expand All @@ -115,6 +131,9 @@
tmp[mod].var["highly_variable"] = True

tmp.update()
else:
del mofa_kwargs['filter_by_hvg']
mofa_kwargs['use_var'] = None



Expand Down

0 comments on commit 21a486e

Please sign in to comment.