Skip to content

Commit 9114791

Browse files
committed
add new feature
1 parent ee4b00a commit 9114791

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Utilities for loading and analyzing 10x Genomics Xenium exports in Python.
77
Install:
88

99
```bash
10+
# 稳定用法(本地开发/CI)
11+
pip install -U "git+https://github.com/hutaobo/pyXenium@main"
12+
#
1013
pip install pyXenium
1114
```
1215

@@ -56,6 +59,38 @@ adata = load_anndata_from_partial(
5659
)
5760
```
5861

62+
### Protein + RNA correlation (Xenium)
63+
64+
Compute spatial correlation between **mean protein intensity** and **gene transcript density** on a user-defined grid.
65+
66+
```python
67+
from pyXenium.io.partial_xenium_loader import load_anndata_from_partial
68+
from pyXenium.analysis import protein_gene_correlation
69+
70+
# 1) Load data (RNA counts + optional cells/analysis attachments)
71+
BASE = "https://huggingface.co/datasets/<your-dataset>/resolve/main"
72+
adata = load_anndata_from_partial(
73+
base_url=BASE,
74+
# or base_dir="/path/to/Xenium_Export"
75+
# If you also have analysis/cells zarr, pass them here to attach clusters & spatial centroids
76+
)
77+
78+
# 2) Run protein–gene correlation
79+
# transcripts_zarr_path 可为 .zarr 或 .zarr.zip(本地或远程,fsspec 透明读)
80+
pairs = [("CD3E", "CD3E"), ("E-Cadherin", "CDH1")] # (protein, gene)
81+
summary = protein_gene_correlation(
82+
adata=adata,
83+
transcripts_zarr_path=BASE + "/transcripts.zarr.zip",
84+
pairs=pairs,
85+
output_dir="./protein_gene_corr",
86+
grid_size=(50, 50), # 可自定义网格
87+
pixel_size_um=0.2125, # Xenium 常见像素尺寸
88+
qv_threshold=20,
89+
overwrite=False
90+
)
91+
print(summary)
92+
```
93+
5994
### Troubleshooting
6095
- **FileNotFoundError: MEX missing files** → Ensure the three files exist in `cell_feature_matrix/`:
6196
`matrix.mtx.gz`, `features.tsv.gz`, `barcodes.tsv.gz`.

src/pyXenium/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from ._version import __version__
22
from .io.partial_xenium_loader import load_anndata_from_partial
33
from .io.xenium_gene_protein_loader import load_xenium_gene_protein
4+
from .analysis import protein_gene_correlation
45

56
# src/pyXenium/__init__.py
6-
__all__ = []
7+
__all__ = [
8+
"__version__",
9+
"load_xenium_gene_protein",
10+
"load_anndata_from_partial",
11+
"protein_gene_correlation",
12+
]

src/pyXenium/analysis/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 新增/补充
2+
from .protein_gene_correlation import protein_gene_correlation
3+
4+
__all__ = [
5+
"protein_gene_correlation",
6+
]

0 commit comments

Comments
 (0)