MCMICRO

In this demo, we’ll analyze 12-plex CyCIF data on a human lung adenocarcinoma core, as output by MCMICRO (Schapiro et al. 2022), which stems from a larger tissue microarray (TMA); included are also cell segmentation outputs from both UnMICST and Ilastik, respectively, as well as corresponding channel x cell protein expression matrices (here, corresponding to mean pixel intensities).

preamble

library(sf)
library(dplyr)
library(ggplot2)
library(patchwork)
library(SpatialData)
library(SpatialData.data)
library(SpatialData.plot)
(sd <- LungAdenocarcinomaMCMICRO())
class: SpatialData
- images(1):
  - exemplar-001_image (12,3139,2511)
- labels(2):
  - exemplar-001_cell (3139,2511)
  - exemplar-001_nuclei (3139,2511)
- points(0):
- shapes(0):
- tables(2):
  - exemplar-001--ilastik_cell (12,11607) [exemplar-001_cell]
  - exemplar-001--unmicst_cell (12,11170) [exemplar-001_cell]
coordinate systems(1):
- global(3): exemplar-001_image exemplar-001_cell exemplar-001_nuclei

Let’s start by viewing available channels():

cat(channels(image(sd)))
DNA_6 ELANE CD57 CD45 DNA_7 CD11B SMA CD16 DNA_8 ECAD FOXP3 NCAM

For consistency, we will fix a color to use for each channel:

pal <- c(
    DNA_6="grey",
    DNA_7="grey",
    DNA_8="grey",
    CD57="maroon",  # NK
    FOXP3="yellow", # Treg
    SMA="red",      # stromal
    NCAM="orange",  # myocyte
    CD11B="blue",   # dendritic
    CD16="cyan",    # neutrophil
    ELANE="purple", # neutrophil
    ECAD="green",   # epithelial
    CD45="magenta") # lymphocyte

The original image includes a superfluous empty region, which we’ll remove:

sd <- crop(sd, list(xmin=0, xmax=2500, ymin=600, ymax=3200))

Now, let’s generate a composite image of few selected channels:

ch <- c("CD16", "CD45", "FOXP3", "ELANE", "ECAD", "SMA")
plotSpatialData() + plotImage(sd, ch=ch, c=pal[ch])

We can also visualize channels individually (here, using a smaller region):

bb <- list(
    xmin=1600, xmax=2400, 
    ymin=1200, ymax=2000)
sp <- crop(sd, bb)

ch <- channels(image(sp))
ps <- lapply(ch, \(.) {
    plotSpatialData() + ggtitle(.) + 
    plotImage(sp, ch=., c=pal[.]) })

wrap_plots(ps, nrow=3) & 
    theme_void() & theme(
        legend.position="none", 
        plot.title=element_text(hjust=0.5))

(se <- table(sd))
class: SingleCellExperiment 
dim: 12 11607 
metadata(0):
assays(1): X
rownames(12): DNA_6 ELANE ... FOXP3 NCAM
rowData names(9): channel_number cycle_number ... exposure remove
colnames(11607): 0 1 ... 11605 11606
colData names(7): Area MajorAxisLength ... Extent Orientation
reducedDimNames(1): spatial
mainExpName: NULL
altExpNames(0):

appendix

sessionInfo()
R version 4.6.0 (2026-04-24)
Platform: aarch64-apple-darwin23
Running under: macOS Sequoia 15.6.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Madrid
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] SpatialData.plot_0.99.6 SpatialData.data_0.99.6 SpatialData_0.99.35    
[4] patchwork_1.3.2         ggplot2_4.0.3           dplyr_1.2.1            
[7] sf_1.1-1               

loaded via a namespace (and not attached):
  [1] DBI_1.3.0                   bitops_1.0-9               
  [3] RBGL_1.89.0                 httr2_1.2.2                
  [5] anndataR_1.3.0              rlang_1.2.0                
  [7] magrittr_2.0.5              Rarr_2.1.7                 
  [9] otel_0.2.0                  matrixStats_1.5.0          
 [11] e1071_1.7-17                compiler_4.6.0             
 [13] RSQLite_2.4.6               dir.expiry_1.21.0          
 [15] paws.storage_0.9.0          png_0.1-9                  
 [17] fftwtools_0.9-11            vctrs_0.7.3                
 [19] pkgconfig_2.0.3             wk_0.9.5                   
 [21] crayon_1.5.3                fastmap_1.2.0              
 [23] dbplyr_2.5.2                XVector_0.53.0             
 [25] paws.common_0.8.9           rmarkdown_2.31             
 [27] graph_1.91.0                purrr_1.2.2                
 [29] bit_4.6.0                   xfun_0.57                  
 [31] cachem_1.1.0                grumpy_0.1.0               
 [33] jsonlite_2.0.0              blob_1.3.0                 
 [35] DelayedArray_0.39.1         tweenr_2.0.3               
 [37] jpeg_0.1-11                 tiff_0.1-12                
 [39] parallel_4.6.0              R6_2.6.1                   
 [41] RColorBrewer_1.1-3          reticulate_1.46.0          
 [43] GenomicRanges_1.65.0        Rcpp_1.1.1-1.1             
 [45] Seqinfo_1.3.0               SummarizedExperiment_1.43.0
 [47] knitr_1.51                  R.utils_2.13.0             
 [49] IRanges_2.47.0              Matrix_1.7-5               
 [51] tidyselect_1.2.1            duckspatial_1.0.0          
 [53] rstudioapi_0.18.0           dichromat_2.0-0.1          
 [55] abind_1.4-8                 EBImage_4.55.0             
 [57] curl_7.1.0                  lattice_0.22-9             
 [59] tibble_3.3.1                Biobase_2.73.1             
 [61] withr_3.0.2                 S7_0.2.2                   
 [63] evaluate_1.0.5              units_1.0-1                
 [65] proxy_0.4-29                polyclip_1.10-7            
 [67] BiocFileCache_3.3.0         pillar_1.11.1              
 [69] filelock_1.0.3              MatrixGenerics_1.25.0      
 [71] KernSmooth_2.23-26          stats4_4.6.0               
 [73] generics_0.1.4              RCurl_1.98-1.18            
 [75] nanoarrow_0.8.0             S4Vectors_0.51.1           
 [77] scales_1.4.0                class_7.3-23               
 [79] glue_1.8.1                  tools_4.6.0                
 [81] ggnewscale_0.5.2            locfit_1.5-9.12            
 [83] grid_4.6.0                  SingleCellExperiment_1.35.0
 [85] duckdb_1.5.2                basilisk_1.25.0            
 [87] ggforce_0.5.0               cli_3.6.6                  
 [89] rappdirs_0.3.4              S4Arrays_1.13.0            
 [91] geoarrow_0.4.2              gtable_0.3.6               
 [93] R.methodsS3_1.8.2           digest_0.6.39              
 [95] BiocGenerics_0.59.0         classInt_0.4-11            
 [97] SparseArray_1.13.2          ZarrArray_1.1.0            
 [99] htmlwidgets_1.6.4           farver_2.1.2               
[101] memoise_2.0.1               htmltools_0.5.9            
[103] R.oo_1.27.1                 lifecycle_1.0.5            
[105] bit64_4.8.0                 MASS_7.3-65                

References

Schapiro, Denis, Artem Sokolov, Clarence Yapp, Yu-An Chen, Jeremy L Muhlich, Joshua Hess, Allison L Creason, et al. 2022. MCMICRO: a scalable, modular image-processing pipeline for multiplexed tissue imaging.” Nature Methods 19 (3): 311–15. https://doi.org/10.1038/s41592-021-01308-y.