Skip to content

10X Xenium Starter Tutorial

Input Data

This tutorial uses SGE data generated with the 10x Genomics Xenium platform, and it has been cropped to a small region of the adult mouse brain for demonstration purposes.

File Format

10X Genomics Xenium platform outputs Spatial Gene Expression (SGE) data in a comma-separated values (CSV) format.

CSV File Format

1
2
3
4
"transcript_id","cell_id","overlaps_nucleus","feature_name","x_location","y_location","z_location","qv"
281827164036151,133793,1,"Sox10",2350.0232,4153.6846,16.592316,40.0
281827164036152,133793,1,"Sox10",2350.2585,4154.5225,17.237207,10.514394
281827164036164,151216,0,"Sox10",2350.5874,4277.699,14.285685,40.0
  • "transcript_id": Unique identifier for each detected transcript molecule.
  • "cell_id": ID of the segmented cell associated with the transcript.
  • "overlaps_nucleus": 1 if the transcript overlaps the nucleus mask, 0 otherwise.
  • "feature_name": Gene or other features name corresponding to the transcript.
  • "x_location": X-coordinate of the transcript.
  • "y_location": Y-coordinate of the transcript.
  • "z_location": Z-coordinate (depth) of the transcript.
  • "qv": Quality value indicating confidence in transcript detection.

Data Access

The example data is hosted on Zenedo ().

Follow the commands below to download the example data.

1
2
3
4
work_dir=/path/to/work/directory
cd $work_dir
wget  https://zenodo.org/records/15786632/files/xenium_starter.raw.tar.gz 
tar --strip-components=1 -zxvf xenium_starter.raw.tar.gz  

Set Up the Environment

Define paths to all required binaries and resources. Optionally, specify a fixed color map for consistent rendering.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ====
# Replace each placeholder with the actual path on your system.  
# ====

work_dir=/path/to/work/directory        # path to work directory that contains the downloaded input data
cd $work_dir

# Define paths to required binaries and resources
spatula=/path/to/spatula/binary         # path to spatula executable
punkst=/path/to/punkst/binary           # path to FICTURE2/punkst executable
tippecanoe=/path/to/tippecanoe/binary   # path to tippecanoe executable
pmtiles=/path/to/pmtiles/binary         # path to pmtiles executable
aws=/path/to/aws/cli/binary             # path to AWS CLI binary

# (Optional) Define path to color map. 
cmap=/path/to/color/map                 # Path to the fixed color map for rendering. cartloader provides a fixed color map at cartloader/assets/fixed_color_map_256.tsv.

# Number of jobs
n_jobs=10                               # If not specify, the number of jobs defaults to 1.

# Activate the bioconda environment
conda activate ENV_NAME                 # replace BIOENV_NAME with your bioconda environment name

Define data ID and analysis parameters:

1
2
3
4
5
6
7
8
# Unique identifier for your dataset
DATA_ID="xenium_hippo"                  # change this to reflect your dataset name
PLATFORM="10x_xenium"                   # platform information
SCALE=1                                 # coordinate to micrometer scaling factor

# LDA parameters
train_width=12                           # define LDA training hexagon width (comma-separated if multiple widths are applied)
n_factor=6,12                            # define number of factors in LDA training (comma-separated if multiple n-factor are applied)

How to Define Scaling Factors for Xenium

The Xenium example data currently used here provides SGE in micrometer units. Use define scaling factor from coordinate to micrometer as 1.

SGE Format Conversion

Convert the raw input to the unified SGE format. See more details in Reference page.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cartloader sge_convert \
  --makefn sge_convert.mk \
  --platform ${PLATFORM} \
  --in-csv ./input.tsv.gz \
  --units-per-um ${SCALE} \
  --out-dir ./sge \
  --exclude-feature-regex '^(BLANK|NegCon|NegPrb)' \
  --sge-visual \
  --spatula ${spatula} \
  --n-jobs ${n_jobs}
Parameter Required Type Description
--platform required string Platform (options: "10x_visium_hd", "seqscope", "10x_xenium", "bgi_stereoseq", "cosmx_smi", "vizgen_merscope", "pixel_seq", "generic")
--in-csv required string Path to the input TSV/CSV file
--units-per-um required float Scale to convert coordinates to microns (default: 1.0)
--out-dir required string Output directory for the converted SGE files
--makefn string File name for the generated Makefile (default: sge_convert.mk)
--exclude-feature-regex regex Pattern to exclude control features
--sge-visual flag Enable SGE visualization step (generates diagnostic image) (default: FALSE)
--spatula string Path to the spatula binary (default: spatula)
--n-jobs int Number of parallel jobs for processing (default: 1)

FICTURE Analysis

Compute spatial factors using punkst (FICTURE2 mode). See more details in Reference page.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
cartloader run_ficture2 \
  --makefn run_ficture2.mk \
  --main \
  --in-transcript ./sge/transcripts.unsorted.tsv.gz \
  --in-feature ./sge/feature.clean.tsv.gz \
  --in-minmax ./sge/coordinate_minmax.tsv \
  --cmap-file ${cmap} \
  --exclude-feature-regex '^(mt-.*$|Gm\d+$)' \
  --out-dir ./ficture2 \
  --width ${train_width} \
  --n-factor ${n_factor} \
  --spatula ${spatula} \
  --ficture2 ${punkst} \
  --n-jobs ${n_jobs} \
  --threads ${n_jobs}
Parameter Required Type Description
--main required 1 flag Enable cartloader to run all five steps
--in-transcript required string Path to input transcript-level SGE file
--out-dir required string Path to output directory
--width required int or comma-separated list LDA training hexagon width(s)
--n-factor required int or comma-separated list Number of LDA factors
--makefn string File name for the generated Makefile (default: run_ficture2.mk )
--in-feature string Path to input feature file
--in-minmax string Path to input coordinate min/max file
--cmap-file string Path to color map file
--exclude-feature-regex regex Pattern to exclude features
--spatula string Path to the spatula binary (default: spatula)
--ficture2 string Path to the punkst directory (defaults to punkst repository within submodules directory of cartloader)
--n-jobs int Number of parallel jobs (default: 1)
--threads int Number of threads per job (default: 1)

1: cartloader requires the user to specify at least one action. Available actions includes: --tile to run tiling step; --segment to run segmentation step; --init-lda to run LDA training step; --decode to run decoding step; --summary to run summarization step; --main to run all above five actions.

cartloader Compilation

Generate pmtiles and web-compatible tile directories. See more details in Reference page.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cartloader run_cartload2 \
  --makefn run_cartload2.mk \
  --fic-dir ./ficture2 \
  --out-dir ./cartload2 \
  --id ${DATA_ID} \
  --spatula ${spatula} \
  --pmtiles ${pmtiles} \
  --tippecanoe ${tippecanoe} \
  --n-jobs ${n_jobs} \
  --threads ${n_jobs}
Parameter Required Type Description
--fic-dir required string Path to the input directory containing FICTURE2 output
--out-dir required string Path to the output directory for PMTiles and web tiles
--id required string Dataset ID used for naming outputs and metadata
--makefn string File name for the generated Makefile (default: run_cartload2.mk)
--spatula string Path to the spatula binary (default: spatula)
--pmtiles string Path to the pmtiles binary (default: pmtiles)
--tippecanoe string Path to the tippecanoe binary (default: tippecanoe)
--n-jobs int Number of parallel jobs (default: 1)
--threads int Number of threads per job (default: 1)

Upload to Data Repository

Choose a data repository to host/share your output

cartloader supports two upload options (AWS and Zenodo) for storing PMTiles of SGE and spatial factors in a data repository.

Choose the one that best suits your needs.

AWS Uploads

Upload the generated cartloader outputs to your designated AWS S3 directory:

1
2
3
4
5
6
7
8
# AWS S3 target location for cartostore
AWS_BUCKET="EXAMPLE_AWS_BUCKET"         # replace EXAMPLE_AWS_BUCKET with your actual S3 bucket name

cartloader upload_aws \
  --in-dir ./cartload2 \
  --s3-dir "s3://${AWS_BUCKET}/${DATA_ID}" \
  --aws ${aws} \
  --n-jobs ${n_jobs}
Parameter Required Type Description
--in-dir required string Path to the input directory containing the cartloader compilation output
--s3-dir required string Path to the target S3 directory for uploading
--aws string Path to the AWS CLI binary
--n-jobs int Number of parallel jobs

Zenodo Uploads

Upload the generated cartloader outputs to your designated Zenodo deposition or a new deposition.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
zenodo_token=/path/to/zenodo/token/file    # replace /path/to/zenodo/token/file by path to your zenodo token file

cartloader upload_zenodo \
  --in-dir ./cartload2 \
  --upload-method catalog \
  --zenodo-token $zenodo_token \
  --create-new-deposition \
  --title  "Yur Title" \
  --creators "Your Name" \
  --description "This is an example description"
Parameter Required Type Description
--in-dir required string Path to the input directory containing the cartloader compilation output
--upload-method required string Method to determine which files to upload. Options: all to upload all files in --in-dir; catalog to upload files listed in a catalog YAML file, user_list to upload files explicitly listed via --in-list
--catalog-yaml string Required if --upload-method catalog. Path to the catalog.yaml file generated in run_cartload2. If absent, will use the catalog.yaml in the input directory specified by --in-dir.
--zenodo-token required string Path to your Zenodo access file
--create-new-deposition flag a new Zenodo deposition will be created.
--title required string Required if --create-new-deposition. Title for the new Zenodo deposition.
--creators required list of str List of creators in "Lastname, Firstname" format.

Output Data

See more details of output at the Reference pages for run_ficture2 and run_cartload2.

Spatial Factor Inference from FICTURE

Below is an example of spatial factor inference results produced by FICTURE using a training width of 12, 12 factors, a fit width of 12, and an anchor resolution of 6.

FICTURE cmap

Factor RGB Weight PostUMI TopGene_pval TopGene_fc TopGene_weight
2 101,255,101 0.16118 699466 Cabp7,Gfap,Arc,Orai2,2010300C02Rik,Arhgap12,Sipa1l3,Kctd12,Lyz2,Shisa6,Pou3f1,Rmst,Arhgap6,Clmn,Chrm2,Cntn6,Cux2,Fibcd1,Wfs1,Pkib Cabp7,Orai2,Slc6a3,Gfap,Arc,Th,Arhgap6,Arhgap12,Pkib,Lyz2,Pou3f1,Ror1,Shisa6,Rmst,Sipa1l3,Vip,Chrm2,Unc13c,2010300C02Rik,Ebf3 Cabp7,Gfap,Slc17a7,Arc,2010300C02Rik,Sipa1l3,Kctd12,Arhgap12,Clmn,Orai2,Acsbg1,Shisa6,Bcl11b,Igfbp5,Bhlhe22,Pou3f1,Rmst,Lyz2,Ntsr2,Wfs1
0 255,101,101 0.13961 605851 Prox1,Calb1,Bhlhe22,Plekha2,Rasgrf2,Pdzd2,Pip5k1b,Rasl10a,Prdm8,Epha4,2010300C02Rik,Npnt,Slc44a5,Nrn1,Bcl11b,Pdyn,Thsd7a,Dpyd,Cntnap5b,Zfpm2 Pdyn,Npnt,Prox1,Plekha2,Calb1,Pdzd2,Rasgrf2,Cntnap5b,Rasl10a,Slc44a5,Bhlhe22,Dpyd,Prdm8,Zfpm2,Thsd7a,Pip5k1b,Syt17,Gsg1l,Npy2r,Cdh9 Prox1,Nrn1,Epha4,2010300C02Rik,Slc17a7,Bhlhe22,Pip5k1b,Calb1,Bcl11b,Rasgrf2,Cpne6,Plekha2,Cpne4,Prdm8,Igfbp5,Rasl10a,Bhlhe40,Tanc1,Gad1,Pdzd2
1 237,238,0 0.12496 542277 Cpne4,Neurod6,Slc17a7,Cpne6,Epha4,Slit2,Nrn1,Prdm8,Sema3e,Dkk3,Nwd2,Npy2r,Strip2,Bdnf,Plcxd2,Shisa6,Tanc1,Rspo2,Mdga1,Car4 Slit2,Cpne4,Neurod6,Rspo2,Npy2r,Strip2,Prss35,Cpne6,Stard5,Bdnf,Prdm8,Nwd2,Sema3e,Plcxd2,Epha4,Shisa6,Slc17a7,Trp73,Nrn1,Tanc1 Slc17a7,Neurod6,Epha4,Nrn1,Cpne4,Cpne6,Cabp7,Dkk3,Dner,Slit2,Tanc1,Prdm8,Sema3e,Sipa1l3,2010300C02Rik,Shisa6,Nwd2,Bhlhe22,Car4,Plcxd2
4 101,101,255 0.10988 476853 Garnl3,Hs3st2,Nxph3,Myl4,Cplx3,Rprm,Satb2,Dpy19l1,Fhod3,Igfbp6,Tle4,Dkk3,Grik3,Ccn2,Gfra2,Gadd45a,Arc,Slc17a7,Igfbp4,Igsf21 Hs3st2,Trbc2,Myl4,Cplx3,Nxph3,Rxfp1,Igfbp6,Satb2,Garnl3,Rprm,Ccn2,Arhgap25,Gadd45a,Fhod3,Sema3a,Sdk2,Foxp2,Tox,Sla,Igsf21 Slc17a7,Garnl3,Dkk3,Nrn1,Arc,Dpy19l1,Neurod6,Id2,Tle4,Igfbp4,Rprm,Nxph3,Gfra2,Epha4,Hs3st2,Myl4,Grik3,2010300C02Rik,Satb2,Fhod3
3 101,254,255 0.1069 463920 Wfs1,Neurod6,Pou3f1,Epha4,Sema3e,Fibcd1,Dkk3,Sorcs3,Igfbp4,Bcl11b,Cpne8,2010300C02Rik,Trpc4,Nell1,Cpne6,Ndst4,Ndst3,Arhgap12,Penk,Mdga1 Wfs1,Pou3f1,Fibcd1,Ndst4,Sorcs3,Cpne8,Penk,Sema3e,Ndst3,Igfbp4,Trpc4,Neurod6,Nell1,Htr1f,Strip2,Bcl11b,Ror1,Mdga1,Dkk3,Epha4 Neurod6,Epha4,Slc17a7,2010300C02Rik,Dkk3,Nrn1,Cpne6,Wfs1,Bcl11b,Pou3f1,Sipa1l3,Sema3e,Arc,Dner,Igfbp4,Pip5k1b,Arhgap12,Cabp7,Sorcs3,Trpc4
5 255,101,254 0.09002 390640 Aqp4,Acsbg1,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rims3,Igfbp4,Kcnmb2,Btbd11,Neto2,Plcxd3,Lypd6
8 0,223,95 0.05087 220765 Gjc3,Opalin,Sox10,Sema6a,Dpy19l1,Zfp536,Adamtsl1,Tmem163,Gng12,Clmn,Cobll1,Cdh20,Vwc2l,Gpr17,Prox1,Fign,Adamts2,Sema3d,Arhgef28,Chrm2 Opalin,Sox10,Gjc3,Adamtsl1,Sema6a,Tmem163,Zfp536,Fign,Adamts2,Cobll1,Dpy19l1,Gpr17,Vwc2l,Cdh20,Gng12,Sema3d,Clmn,Carmn,Chrm2,Parm1 Gjc3,Opalin,Sox10,Dpy19l1,Clmn,Sema6a,Gng12,Zfp536,Prox1,Gfap,Tmem163,Cdh20,Arhgef28,Cobll1,Bhlhe40,Adamtsl1,Igfbp5,Vwc2l,Chrm2,Tanc1
9 101,178,255 0.03417 148267 Slc17a6,Rims3,Necab1,Calb2,Rnf152,Nell1,Clmn,Tmem163,Pde7b,Rorb,Cux2,Foxp2,Opn3,Unc13c,Inpp4b,Btbd11,Thsd7a,Fign,Sema6a,Nrn1 Slc17a6,Rims3,Necab1,Opn3,Calb2,Rnf152,Fign,Unc13c,Nell1,Tmem163,Btbd11,Inpp4b,Foxp2,Cux2,Pde7b,Plch1,Deptor,Tox,Rorb,Thsd7a Rims3,Slc17a6,Nrn1,Necab1,Clmn,Calb2,Epha4,Nell1,Dner,Slc17a7,Rorb,Rnf152,Prox1,Bhlhe40,Pde7b,Nrep,Thsd7a,Tmem163,Tanc1,Sema6a
10 178,101,255 0.029 125838 Nwd2,Calb2,Syt6,Necab2,Sncg,Vat1l,Slc17a6,Gucy1a1,Kctd8,Nrp2,Tmem255a,Chat,Tacr1,Cacna2d2,Thsd7a,Ano1,Dner,Cbln1,Cntnap4,Cbln4 Chat,Sncg,Tacr1,Kctd8,Vat1l,Nwd2,Calb2,Syt6,Cbln1,Ano1,Necab2,Gucy1a1,Slc17a6,Tmem255a,Cacna2d2,Cbln4,Nrp2,Th,Pde11a,Sema3d Nwd2,Nrn1,Calb2,Necab2,Dner,Syt6,Slc17a6,Cpne4,Gucy1a1,Nrp2,Vat1l,Thsd7a,Sncg,Slc17a7,Kctd8,Cacna2d2,Rmst,Garnl3,Tmem255a,Cntnap4
11 255,153,204 0.02895 125631 Pdgfra,Cspg4,Gpr17,Cd24a,Sox11,Sema3d,Spag16,Igfbp5,Gjc3,Trp73,Gfap,Meis2,Nrep,Sox10,Sema5b,Cobll1,Rmst,Vwc2l,Tmem255a,Hat1 Pdgfra,Cspg4,Gpr17,Spag16,Cd24a,Sema3d,Trp73,Sox11,Chodl,Sema5b,Ebf3,Prph,Tmem255a,Plch1,Cdh4,Slc6a3,Sox10,Gjc3,Vwc2l,Cobll1 Pdgfra,Gfap,Igfbp5,Gpr17,Cspg4,Gjc3,Sox11,Cd24a,Nrep,Meis2,Dner,Dkk3,Sox10,Rmst,Bhlhe40,Gng12,Dpy19l1,Sema3d,Sema6a,Cobll1

Packed SGE and Spatial Factor Outputs from run_cartload2

The packed SGE data and spatial factor inferences generated by FICTURE are available in PMTile format on Zenodo: DOI:10.5281/zenodo.15824967.

These datasets can also be loaded directly using the following catalog YAML file:
https://zenodo.org/records/15824968/catalog.yaml