Skip to content

Commit

Permalink
fixes to make MultiVI run
Browse files Browse the repository at this point in the history
  • Loading branch information
bio-la committed Feb 29, 2024
1 parent f230085 commit 1802a7f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/integration01-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ jobs:
channel-priority: strict
activate-environment: pipeline_env
environment-file: pipeline_env.yaml

# important: this patch is only to test if multivi integration works
# issues are not related to panpipes https://discourse.scverse.org/t/error-when-training-model-on-m3-max-mps/1896/2
# https://discourse.scverse.org/t/macbook-m1-m2-mps-acceleration-with-scvi/2075/4
- name: Install Panpipes
shell: bash -el {0}
run: |
pip install -e .
pip install '.[multivipatch]'
conda list
- name: Conda info
Expand Down
20 changes: 16 additions & 4 deletions panpipes/python_scripts/batch_correct_multivi.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@
del mdata

if check_for_bool(params["multimodal"]["MultiVI"]["lowmem"]):
L.info("subsetting atac to top 25k HVF")
if 'hvg' in atac.uns.keys():
L.info("subsetting atac to top HVF")
atac = atac[:, atac.var.highly_variable].copy()
L.info("calculating and subsetting atac to top 25k HVF")
sc.pp.highly_variable_genes(atac, n_top_genes=25000)
atac = atac[:, atac.var.highly_variable]
atac = atac[:, atac.var.highly_variable].copy()



Expand Down Expand Up @@ -125,6 +128,15 @@
L.info("concatenating modalities to comply with multiVI")
# adata_paired = ad.concat([rna, atac], join="outer")
# adata_paired.var = pd.concat([rna.var,atac.var])
if rna.is_view:
L.info("RNA is view")
atac = rna.copy()
if atac.is_view:
L.info("ATAC is view")
atac = atac.copy()

L.info(atac.is_view)


adata_paired = ad.concat([rna.T, atac.T]).T

Expand Down Expand Up @@ -222,14 +234,14 @@
multivi_training_args={}
else:
multivi_training_args = {k: v for k, v in params["multimodal"]['MultiVI']['training_args'].items() if v is not None}

L.info("multivi training args")
print(multivi_training_args)

if params["multimodal"]['MultiVI']['training_plan'] is None:
multivi_training_plan = {}
else:
multivi_training_plan = {k: v for k, v in params["multimodal"]['MultiVI']['training_plan'].items() if v is not None}

L.info("multivi training plan")
print(multivi_training_plan)

mvi.view_anndata_setup()
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
"scikit-misc",
"scirpy",
"scrublet",
"scvi-tools>=1.1.1",
"scvi-tools", #>=1.1.1
"sqlalchemy",
]

Expand All @@ -61,6 +61,11 @@ spatial = [
"cell2location",
"tangram-sc"
]

multivipatch = [
"scvi-tools<=0.20.3",
"requests"
]
[project.scripts]
panpipes = "panpipes:entry.main"

Expand Down
6 changes: 3 additions & 3 deletions tests/integration_1/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ multimodal:
# specify one at a time and run the pipeline in different folders i.e. integration_by_sample,
# integration_by_tissue ...
column_continuous:
column_categorical: sample_id
column_categorical: dataset
# extra params:
totalvi:
# this is a minimal set of parameters that will be expected
Expand Down Expand Up @@ -269,8 +269,8 @@ multimodal:
batch_size : 128
#float (default: 0.001)
weight_decay : 0.001
#float (default: 1e-08)
eps : 1e-08
#float (default: 1.0e-08)
eps : 1.0e-08
#bool (default: True)
early_stopping : True
#bool (default: True)
Expand Down

0 comments on commit 1802a7f

Please sign in to comment.