BloomAI
Project: CellAtlas chevron_right Workflow: Integration chevron_right Bio-Computation Workspace
terminal main_analysis.py
Python 3.9 Kernel Ready
1
2
3
4
5
6
7
8
9
10
11
12
13
import scanpy as sc
import pandas as pd
# Load dataset configuration
DATA_PATH = 's3://bloom-data/lung_atlas_v2.h5ad'
# Initialize analysis object
adata = sc.read_h5ad(DATA_PATH)
# Preprocessing: Normalize and log transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
# Attempt neighborhood graph construction
error sc.pp.neighbors(adata, n_neighbors=10, n_pcs=40)
sc.tl.umap(adata)
TERMINAL OUTPUT DEBUG CONSOLE
close
➜ workspace git:(main) python main_analysis.py
Loading dataset 'lung_atlas_v2.h5ad'... Done (2.4s)
Normalizing counts... Done (0.8s)
Computing neighbors...
RuntimeError: Matrix alignment failed.
File "main_analysis.py", line 12, in <module>
sc.pp.neighbors(adata, n_neighbors=10, n_pcs=40)
Principal components do not match reference integration. Batch effect detected across samples.
Atomic Insight Detected

Harmony Integration Required

psychology

It looks like your matrices are unaligned. Standard neighborhood calculation failed due to significant batch effects in the lung_atlas_v2 dataset.

school Learn about: Batch Effects, Harmony Method
Data Alignment Preview
Recommended Fix Python
# Use Harmony for batch correction
import scanpy.external as sce
sce.pp.harmony_integrate(adata, key='batch')
sc.pp.neighbors(adata, use_rep='X_pca_harmony')