Skip to content
SpaTrekPublic

About

ZOOM is a Python-based integrative framework for linking macroscopic and mesoscopic spatial brain phenotypes (SBPs) with microscopic molecular, cellular information.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZOOM (Zoom from Macro to Micro)

Decoding molecular and cellular underpinnings of macroscopic spatial brain phenotypes with ZOOM

ZOOM is a Python-based integrative framework for linking macroscopic and mesoscopic spatial brain phenotypes (SBPs) with microscopic molecular, cellular information.

python >=3.9 DOI

avatar

Code used to generate results of this study can be found here. The pseudocode for ZOOM's main framework is available here.

Tutorial

To get started with ZOOM, we recommend creating a dedicated conda environment to manage dependencies:

# Create and activate the environment
conda create -n zoom_env python=3.9
conda activate zoom_env

# Clone the repository and install dependencies
git clone https://github.com/SpaTrek/ZOOM.git
cd ZOOM
pip install -r requirements.txt
pip install .

This tutorial demonstrates how to use ZOOM to decode the single-cell underpinnings of adolescent myelination changes (ΔMT). you need to download the Demonstration Data and place it in your working directory (e.g., ./ZOOM_demodata).

import scanpy as sc
import pandas as pd
import numpy as np
import zoom
import os
os.chdir("./ZOOM_demodata")

# Prepare AHBA expression and SBP data
expression = pd.read_csv("expression_HCPMMP.csv",index_col=0)
SBP, SBP_perm = zoom.prepare.process_SBP(
    SBP="lh.deltaMT.fsLR.32k.func.gii",
    parcellation="lh.HCPMMP1.fsLR.32k.label.gii",
    atlas="fsLR", density="32k", hemi="L",
    n_perm=1000, seed=123
)

# Keep valid regions
SBP = SBP[SBP.index.isin(expression.index)]
SBP_perm = SBP_perm[SBP_perm.index.isin(expression.index)]
# Prepare ZOOM_SC object for analysis
adata = sc.read_h5ad("adata_ctx.h5ad")
zoom_obj = zoom.ZOOM_SC(
    adata=adata,
    expression=expression,
    SBP=SBP,
    SBP_perm=SBP_perm,
    best_comp=9, #This can be tested via zoom, but takes time
    processed = True
)
zoom_obj.cv_PLSR()
zoom_obj.get_gene_contrib(metric="VIP")

# Compute ZOOM single-cell score
zoom_obj.get_SBP_score(
    direction=True,
    gene_size=30,
    fdr_method="group_bh",
    alpha=0.1,
    group="Subcluster"
)

# For visualization
zoom_obj.adata.obs["norm_score"] = zoom_obj.SBP_scores["norm_score"]
zoom_obj.adata.obs["p_fdr0.1"] = zoom_obj.SBP_scores["p_fdr0.1"]
# Filter for significant scores
zoom_obj.adata.obs['sig_score'] = zoom_obj.adata.obs['norm_score'].where(
    (zoom_obj.adata.obs['p_fdr0.1'] == 'True') & (zoom_obj.adata.obs['norm_score'] > 3), 
    other=np.nan
)
# Plotting
sc.pl.embedding(zoom_obj.adata, basis='umap', color=['Cluster', 'norm_score', 'sig_score'], 
                size=5, color_map='magma', frameon=False)

CPU times: user 6min 48s, sys: 43min 58s, total: 50min 47s, Wall time: 2min 43s

avatar Detailed guidance of ZOOM can be found here.

Citation

Our article has not been published yet.

About

ZOOM is a Python-based integrative framework for linking macroscopic and mesoscopic spatial brain phenotypes (SBPs) with microscopic molecular, cellular information.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages