diff --git a/panpipes/panpipes/pipeline_integration/pipeline.yml b/panpipes/panpipes/pipeline_integration/pipeline.yml index a8693636..0445dcfe 100644 --- a/panpipes/panpipes/pipeline_integration/pipeline.yml +++ b/panpipes/panpipes/pipeline_integration/pipeline.yml @@ -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 diff --git a/panpipes/python_scripts/batch_correct_mofa.py b/panpipes/python_scripts/batch_correct_mofa.py index b9300df0..afc4655c 100644 --- a/panpipes/python_scripts/batch_correct_mofa.py +++ b/panpipes/python_scripts/batch_correct_mofa.py @@ -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 @@ -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" @@ -115,6 +131,9 @@ tmp[mod].var["highly_variable"] = True tmp.update() +else: + del mofa_kwargs['filter_by_hvg'] + mofa_kwargs['use_var'] = None