Last updated: 2025-05-23

Checks: 7 0

Knit directory: CosMx_pipeline_LGA/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20250517) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 349fa2a. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/
    Ignored:    NBClust-Plots/
    Ignored:    analysis/figure/
    Ignored:    data/flatFiles/CoronalHemisphere/Run1000_S1_Half_exprMat_file.csv
    Ignored:    data/flatFiles/CoronalHemisphere/Run1000_S1_Half_fov_positions_file.csv
    Ignored:    data/flatFiles/CoronalHemisphere/Run1000_S1_Half_metadata_file.csv
    Ignored:    output/processed_data/Log/
    Ignored:    output/processed_data/RC/
    Ignored:    output/processed_data/SCT/
    Ignored:    output/processed_data/exprMat_unfiltered.RDS
    Ignored:    output/processed_data/fov_positions_unfiltered.RDS
    Ignored:    output/processed_data/metadata_unfiltered.RDS
    Ignored:    output/processed_data/negMat_unfiltered.RDS
    Ignored:    output/processed_data/seu_filtered.RDS
    Ignored:    output/processed_data/seu_semifiltered.RDS

Untracked files:
    Untracked:  analysis/images/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/pipeline.Rmd) and HTML (docs/pipeline.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 349fa2a lidiaga 2025-05-23 Add final executing times in pipeline.Rmd
html 56a8ca8 lidiaga 2025-05-23 Build site.
html 51b3104 lidiaga 2025-05-23 Build site.
Rmd 510334a lidiaga 2025-05-23 Fix grammatical and format errors in web and README
html ec56fee lidiaga 2025-05-20 Build site.
Rmd df0ca86 lidiaga 2025-05-20 Fix formatting errors in web sections
html 8a9f079 lidiaga 2025-05-20 Build site.
Rmd 2efdd16 lidiaga 2025-05-20 Fix pipeline diagram positioning and caption
Rmd 2760a85 lidiaga 2025-05-19 Add pipeline diagram image
Rmd cf77662 lidiaga 2025-05-19 Edit website files

Introduction

CosMx™ SMI technology is an imaged-based spatial transcriptomics technology based on ISH and fluorescence techniques, and, as such, an important step of processing its data would be processing the histology and fluorescence images to extract the expression matrix and the spatial location coordinates of cells and transcripts. However, for this project, it was decided to start the pipeline from the data obtained after segmentation and the construction of expression and localization matrices, since, this steps can be efficiently carried out in AtoMx™ SIP (the data-storing platform of the SMI instrument), avoiding the need to download large amounts of image files. Additionally, if open-source alternatives are preferred, there are already pipelines available that allow this phase to be performed separately [1,2].

For the construction and structuring of this pipeline, a depth review of open-source tools, available automatic pipelines and exploration of various vignettes and practical usage examples was performed. Additionally, resources and recommendations from the manufacturer, NanoString® [3,4], as well as relevant technical documentation [5,6], were also reviewed.

Finally, special mention to the Scratch Space Vignette: Basics of CosMx Analysis in R [7] and the CosMxLite vignette [8], which where very helpful for developing this work and understanding the basics of this type of data analysis process. However, all references to these and other sources have been commented and linked on the code when needed.

Pipeline

The proposed pipeline consists of five main phases: data loading, QC and filtering, normalization, dimensional reduction and cell typing:

Figure 1. Pipeline flowchart. Created using Lucidchart software. Blue: potential input files to the pipeline; Dark gray: main processes; Light gray: subprocesses; Orange: output files, with those involved in later stages of the workflow highlighted in dark; Solid lines: gray, general pipeline flow, and blue, file input flow; Dashed lines: alternative or optional flows. Red represents processes that were not developed in this work due to time constraints, but could be included in future versions or pipeline improvements, such as the multi-sample integration phase or the semi-supervised clustering alternative.

With the goal of creating a flexible pipeline, the documents have been parameterized, as far as possible, to allow for a variety of options without affecting their proper functioning. However, the Cell typing phase is subdivided into three independent scripts, given the complexity of executing the different alternatives that the pipeline contemplates:

  1. Two starting points are available:

    1. If starting from the AtoMx™ SIP exported flat files (.csv): start in 0.0_data_loading.Rmd file.

    2. If starting from the AtoMx™ SIP exported Seurat object: start in 1.0_qc_and_filtering.Rmd file.

  2. Three normalization methods are available: RC, Log and SCT (see Normalization section for more information)

  3. Three cell typing methods are available: supervised classification with InSituType, unsupervied clustering with InSitutype or unsupervised clustering with Seurat (see Cell typing section for more information).

Total time and memory

Phase Total_time_sec Total_memory_Mb
0.0_data_loading_PR.csv 42.77 596.4
1.0_qc_and_filtering_PR.csv 53.68 898.9
2.0_normalization_PR.csv 87.59 1357.9
3.0_dimensional_reduction_PR.csv 135.82 1416.1
4.0_insitutype_cell_typing_PR.csv 1022.54 2022.4
Total 1342.40 6291.7

In terms of time and memory usage, the example analysis shown in the pipeline vignettes (using SCTransform as normalization method and InSituType Supervised classification for cell typing) takes ~23 minutes to execute, and 62,9 Gb of memory consumption.

However, other pipeline alternatives have also been executed in this project and their total performances in time and memory are:

Alternative Total_time_sec Total_memory_Mb
RC 266.51 3423.6
Log 251.19 3423.6
SCT 319.86 4269.3
SCT_ISTSup 1342.40 6291.7
SCT_ISTUnsup 579.12 6273.6
SCT_SL 486.53 5864.1

The first three rows correspond to the total time an memory consuption of the execution of the pipeline from data loading to dimensional reduction, using each of the different normalization alternatives:

  • RC: ~4 minutes and 34.2 Gb.

  • Log: ~4 minutes and 34.2 Gb.

  • SCT: ~5 minutes and 42.7 Gb.

The last three rows correspond to the total time an memory consuption of the execution of the pipeline from data loading to cell typing, using the SCTransform normalization and each of the different cell typing alternatives:

  • SCT + Supervised InSituType: ~23 minutes and 62,9 Gb.

  • SCT + Unsupervised InSituType: ~10 minutes and 62,7 Gb.

  • SCT + Seurat-Louvain: ~8 minutes and 58,6 Gb.


Bibliography

  1. Blampey Q, Mulder K, Gardet M, Christodoulidis S, Dutertre CA, André F, et al. Sopa: a technology-invariant pipeline for analyses of image-based spatial omics. Nat Commun [Internet]. 2024 Jun 11 [cited 2025 Mar 3];15(1):4981. Available from: https://www.nature.com/articles/s41467-024-48981-z

  2. Pollaris L, Vanneste B, Rombaut B, Defauw A, Vernaillen F, Mortier J, et al. SPArrOW: a flexible, interactive and scalable pipeline for spatial transcriptomics analysis [Internet]. 2024 [cited 2025 Mar 27]. Available from: http://biorxiv.org/lookup/doi/10.1101/2024.07.04.601829

  3. Bruker Spatial Biology, Inc. CosMx® Analysis Scratch Space [Internet]. CosMx® Analysis Scratch Space. Available from: https://nanostring-biostats.github.io/CosMx-Analysis-Scratch-Space/

  4. GitHub - Nanostring-Biostats/CosMx-Analysis-Scratch-Space [Internet]. CosMx-Analysis-Scratch-Space. Available from: https://github.com/Nanostring-Biostats/CosMx-Analysis-Scratch-Space

  5. Bruker Spatial Biology. CosMx SMI Instrument User Manual (Software v1.5) [Internet]. [cited 2025 Mar 21]. Available from: https://university.nanostring.com/cosmx-smi-instrument-user-manual-software-v15

  6. Bruker Spatial Biology. CosMx SMI Data Analysis User Manual (on AtoMx v1.4.0) [Internet]. [cited 2025 Mar 21]. Available from: https://nanostring.com/resources/cosmx-smi-data-analysis-user-manual-software-v1-3/

  7. Danaher P. Vignette: Basics of CosMx Analysis in R – Blog [Internet]. CosMx® Analysis Scratch Space. 2024 [cited 2025 Mar 27]. Available from: https://nanostring-biostats.github.io/CosMx-Analysis-Scratch-Space/posts/vignette-basic-analysis/

  8. O Hora B, Laddach R, Nuamah R, Chiappini C, Grigoriadis A, Quist J. GitHub - cancerbioinformatics/CosMx_Lite [Internet]. CosMxLite. 2024 [cited 2025 Mar 27]. Available from: https://github.com/cancerbioinformatics/CosMx_Lite


sessionInfo()
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22000)

Matrix products: default


locale:
[1] LC_COLLATE=Spanish_Spain.utf8  LC_CTYPE=Spanish_Spain.utf8   
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C                  
[5] LC_TIME=Spanish_Spain.utf8    

time zone: Europe/Madrid
tzcode source: internal

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

other attached packages:
[1] kableExtra_1.4.0  dplyr_1.1.4       here_1.0.1        data.table_1.17.0
[5] workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] jsonlite_1.9.1    compiler_4.4.3    promises_1.3.2    tidyselect_1.2.1 
 [5] Rcpp_1.0.14       xml2_1.3.7        stringr_1.5.1     git2r_0.35.0     
 [9] callr_3.7.6       later_1.4.1       jquerylib_0.1.4   systemfonts_1.2.1
[13] scales_1.3.0      yaml_2.3.10       fastmap_1.2.0     R6_2.6.1         
[17] generics_0.1.3    knitr_1.50        tibble_3.2.1      munsell_0.5.1    
[21] rprojroot_2.0.4   svglite_2.1.3     bslib_0.9.0       pillar_1.10.1    
[25] rlang_1.1.6       cachem_1.1.0      stringi_1.8.4     httpuv_1.6.15    
[29] xfun_0.51         getPass_0.2-4     fs_1.6.5          sass_0.4.9       
[33] viridisLite_0.4.2 cli_3.6.4         magrittr_2.0.3    ps_1.9.0         
[37] digest_0.6.37     processx_3.8.6    rstudioapi_0.17.1 lifecycle_1.0.4  
[41] vctrs_0.6.5       evaluate_1.0.3    glue_1.8.0        whisker_0.4.1    
[45] colorspace_2.1-1  rmarkdown_2.29    httr_1.4.7        tools_4.4.3      
[49] pkgconfig_2.0.3   htmltools_0.5.8.1