Custom Segmentation
In [1]:
Copied!
%load_ext autoreload
%autoreload 2
%env ANYWIDGET_HMR=1
%load_ext autoreload
%autoreload 2
%env ANYWIDGET_HMR=1
env: ANYWIDGET_HMR=1
In [2]:
Copied!
import celldega as dega
import os
dega.__version__
import celldega as dega
import os
dega.__version__
Out[2]:
'0.4.0'
Download data if needed¶
Data source: https://www.10xgenomics.com/datasets/xenium-prime-ffpe-human-skin
In [3]:
Copied!
# ! curl -o data/Xenium_Prime_Human_Skin_FFPE_outs.zip https://cf.10xgenomics.com/samples/xenium/3.0.0/Xenium_Prime_Human_Skin_FFPE/Xenium_Prime_Human_Skin_FFPE_outs.zip
# ! unzip data/Xenium_Prime_Human_Skin_FFPE_outs.zip -d data/Xenium_Prime_Human_Skin_FFPE_outs
# ! curl -o data/Xenium_Prime_Human_Skin_FFPE_outs.zip https://cf.10xgenomics.com/samples/xenium/3.0.0/Xenium_Prime_Human_Skin_FFPE/Xenium_Prime_Human_Skin_FFPE_outs.zip
# ! unzip data/Xenium_Prime_Human_Skin_FFPE_outs.zip -d data/Xenium_Prime_Human_Skin_FFPE_outs
Add custom segmentation¶
In [ ]:
Copied!
path_landscape_files="data/xenium_landscape_files/Xenium_Prime_Human_Skin_FFPE_outs"
path_segmentation_files="data/processed_data/xenium_skin/cellpose2/"
dega.pre.add_custom_segmentation(path_landscape_files=path_landscape_files,
path_segmentation_files=path_segmentation_files)
path_landscape_files="data/xenium_landscape_files/Xenium_Prime_Human_Skin_FFPE_outs"
path_segmentation_files="data/processed_data/xenium_skin/cellpose2/"
dega.pre.add_custom_segmentation(path_landscape_files=path_landscape_files,
path_segmentation_files=path_segmentation_files)
========Write meta gene files======== cbg is a dense DataFrame. Proceeding with dense operations. Calculating mean expression Calculating variance All meta gene files are succesfully saved. data/xenium_landscape_files/Xenium_Prime_Human_Skin_FFPE_outs/cbg_cellpose2 ========Write gene-specific parquet files======== Processing gene 0: A2ML1 Processing gene 100: ADIPOR1 Processing gene 200: ANKRD40 Processing gene 300: ATF2 Processing gene 400: BDNF Processing gene 500: CALCRL Processing gene 600: CCL20 Processing gene 700: CD72 Processing gene 800: CFC1 Processing gene 900: CNKSR3 Processing gene 1000: CSNK1A1 Processing gene 1100: CYTH2 Processing gene 1200: DMKN Processing gene 1300: DeprecatedCodeword_0994 Processing gene 1400: DeprecatedCodeword_15617 Processing gene 1500: DeprecatedCodeword_4666 Processing gene 1600: ECD Processing gene 1700: EPCAM Processing gene 1800: FANCC Processing gene 1900: FMO3 Processing gene 2000: GALNS Processing gene 2100: GPATCH11 Processing gene 2200: H3F3B Processing gene 2300: HOXB9 Processing gene 2400: IFNW1 Processing gene 2500: INCA1 Processing gene 2600: JAM2 Processing gene 2700: KIR3DL1 Processing gene 2800: LILRA6 Processing gene 2900: MALL Processing gene 3000: MEST Processing gene 3100: MTCH2 Processing gene 3200: NCSTN Processing gene 3300: NORAD Processing gene 3400: NXPH2 Processing gene 3500: NegControlCodeword_18746 Processing gene 3600: NegControlCodeword_18846 Processing gene 3700: NegControlCodeword_18946 Processing gene 3800: NegControlCodeword_19046 Processing gene 3900: NegControlCodeword_19146 Processing gene 4000: NegControlCodeword_19246 Processing gene 4100: P2RX1 Processing gene 4200: PDE6H Processing gene 4300: PKIA Processing gene 4400: PPARD Processing gene 4500: PRXL2A Processing gene 4600: RABL2B Processing gene 4700: RGN Processing gene 4800: RUBCN Processing gene 4900: SERPINA9 Processing gene 5000: SLC17A8 Processing gene 5100: SMC1A Processing gene 5200: SPATS2L Processing gene 5300: STX7 Processing gene 5400: TENT5B Processing gene 5500: TMEM130 Processing gene 5600: TPX2 Processing gene 5700: TUFM Processing gene 5800: UnassignedCodeword_0100 Processing gene 5900: UnassignedCodeword_0579 Processing gene 6000: UnassignedCodeword_0998 Processing gene 6100: UnassignedCodeword_10427 Processing gene 6200: UnassignedCodeword_10846 Processing gene 6300: UnassignedCodeword_11242 Processing gene 6400: UnassignedCodeword_11661 Processing gene 6500: UnassignedCodeword_12151 Processing gene 6600: UnassignedCodeword_12526 Processing gene 6700: UnassignedCodeword_12880 Processing gene 6800: UnassignedCodeword_13294 Processing gene 6900: UnassignedCodeword_13728 Processing gene 7000: UnassignedCodeword_14115 Processing gene 7100: UnassignedCodeword_14486 Processing gene 7200: UnassignedCodeword_1487 Processing gene 7300: UnassignedCodeword_15237 Processing gene 7400: UnassignedCodeword_15662 Processing gene 7500: UnassignedCodeword_16071 Processing gene 7600: UnassignedCodeword_16476 Processing gene 7700: UnassignedCodeword_16830 Processing gene 7800: UnassignedCodeword_17241 Processing gene 7900: UnassignedCodeword_17672 Processing gene 8000: UnassignedCodeword_18196 Processing gene 8100: UnassignedCodeword_1886 Processing gene 8200: UnassignedCodeword_2384 Processing gene 8300: UnassignedCodeword_2846 Processing gene 8400: UnassignedCodeword_3332 Processing gene 8500: UnassignedCodeword_3845 Processing gene 8600: UnassignedCodeword_4262 Processing gene 8700: UnassignedCodeword_4726 Processing gene 8800: UnassignedCodeword_5195 Processing gene 8900: UnassignedCodeword_5693 Processing gene 9000: UnassignedCodeword_6174 Processing gene 9100: UnassignedCodeword_6629 Processing gene 9200: UnassignedCodeword_7161 Processing gene 9300: UnassignedCodeword_7569 Processing gene 9400: UnassignedCodeword_8046 Processing gene 9500: UnassignedCodeword_8534 Processing gene 9600: UnassignedCodeword_9011 Processing gene 9700: UnassignedCodeword_9525 Processing gene 9800: UnassignedCodeword_9939 Processing gene 9900: XPO1 Processing gene 10000: ZNF687 All gene-specific parquet files are succesfully saved. ========Make meta cells in pixel space======== Done. ========Create clusters and meta clusters files======== Cell clusters and meta cluster files created successfully. ========Create cell boundary spatial tiles========
Processing coarse tiles: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:15<00:00, 1.77s/it]
Done. ========Create cluster gene expression (df_sig)======== Cluster-specific gene expression signatures saved successfully. ========Save landscape parameters======== Done.
Visualize Custom Segmentation Landscape files in Celldega¶
In [5]:
Copied!
base_url = 'https://raw.githubusercontent.com/broadinstitute/celldega_custom_cellpose2_Xenium_Prime_Human_Skin_FFPE_outs/main/Xenium_Prime_Human_Skin_FFPE_outs'
landscape_ist = dega.viz.Landscape(
technology='Xenium',
base_url = base_url,
segmentation='cellpose2'
)
landscape_ist
base_url = 'https://raw.githubusercontent.com/broadinstitute/celldega_custom_cellpose2_Xenium_Prime_Human_Skin_FFPE_outs/main/Xenium_Prime_Human_Skin_FFPE_outs'
landscape_ist = dega.viz.Landscape(
technology='Xenium',
base_url = base_url,
segmentation='cellpose2'
)
landscape_ist
Out[5]:
Landscape(base_url='https://raw.githubusercontent.com/broadinstitute/celldega_custom_cellpose2_Xenium_Prime_Hu…
In [ ]:
Copied!