Skip to content

Commit

Permalink
Merge pull request #201 from DendrouLab/fc_cipy
Browse files Browse the repository at this point in the history
Fc_ added integration01
  • Loading branch information
bio-la authored Mar 19, 2024
2 parents 372aaba + aa031b5 commit 224b8ea
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 10 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/integration01-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Run integration01

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
debug: 'true'

jobs:
integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # , "macos-latest", "windows-latest"
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4

- name: File tree
if: env.debug == 'true'
run: tree

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-activate-base: true
auto-update-conda: true
channels: conda-forge
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 '.[multivipatch]'
conda list
- name: Conda info
if: env.debug == 'true'
shell: bash -el {0}
run: conda info

- name: Conda list
if: env.debug == 'true'
shell: pwsh
run: conda list

# Note: all three files are renamed during the download to trim the "subsample_" prefix
- name: Preparing the data
run: |
mkdir -p teaseq/integration && cd teaseq/integration
curl -L -o teaseq.h5mu https://figshare.com/ndownloader/files/44796985
# Note: we run the following to test that the commands works
# However, the following task will replacing the file anyway
- name: Preparing the configuration file
shell: bash -el {0}
run: |
cd teaseq/integration
panpipes integration config
- name: Edit the submission file
run: |
cd teaseq/integration
curl -o pipeline.yml https://raw.githubusercontent.com/DendrouLab/panpipes/main/tests/integration_1/pipeline.yml
- name: Replace template contents in configuration file
run: |
cd teaseq/integration
sed -i 's+/Users/fabiola.curion/Documents/devel/miniconda3/envs/pipeline_env+pipeline_env+g' pipeline.yml
- name: File tree
if: env.debug == 'true'
run: tree teaseq

- name: Review pipeline tasks
shell: bash -el {0}
run: |
cd teaseq/integration
panpipes integration show full --local
- name: Run pipeline tasks
shell: bash -el {0}
run: |
cd teaseq/integration
panpipes integration make full --local
- name: File tree
if: env.debug == 'true'
run: tree teaseq
31 changes: 21 additions & 10 deletions panpipes/python_scripts/batch_correct_multivi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
sc.settings.autoshow = False
sc.settings.figdir = args.figdir


scvi.settings.seed = 1492
# load parameters

threads_available = multiprocessing.cpu_count()
Expand All @@ -71,17 +71,19 @@
# ------------------------------------------------------------------
L.info("Running multivi")

# mdata = mu.read(args.scaled_anndata)
# rna = mdata['rna'].copy()
# atac = mdata['atac'].copy()
rna= mu.read(args.scaled_anndata +"/" + "rna")
atac= mu.read(args.scaled_anndata +"/" + "atac")
mdata = mu.read(args.scaled_anndata)
rna = mdata['rna'].copy()
atac = mdata['atac'].copy()

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 @@ -126,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 @@ -223,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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ spatial = [
"cell2location",
"tangram-sc"
]

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

Expand Down

0 comments on commit 224b8ea

Please sign in to comment.