Last updated: 2024-03-21

Checks: 7 0

Knit directory: mi_spatialomics/

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(20230612) 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 4c4da66. 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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/deprecated/.DS_Store
    Ignored:    analysis/molecular_cartography_python/.DS_Store
    Ignored:    analysis/seqIF_python/.DS_Store
    Ignored:    analysis/seqIF_python/pixie/.DS_Store
    Ignored:    analysis/seqIF_python/pixie/cell_clustering/
    Ignored:    annotations/.DS_Store
    Ignored:    annotations/SeqIF/.DS_Store
    Ignored:    annotations/molkart/.DS_Store
    Ignored:    annotations/molkart/Figure1_regions/.DS_Store
    Ignored:    annotations/molkart/Supplementary_Figure4_regions/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/140623.calcagno_et_al.seurat_object.rds
    Ignored:    data/Calcagno2022_int_logNorm_annot.h5Seurat
    Ignored:    data/IC_03_IF_CCR2_CD68 cell numbers.xlsx
    Ignored:    data/Traditional_IF_absolute_cell_counts.csv
    Ignored:    data/Traditional_IF_relative_cell_counts.csv
    Ignored:    data/pixie.cell_table_size_normalized_cell_labels.csv
    Ignored:    data/results_cts_100.sqm
    Ignored:    data/seqIF_regions_annotations/
    Ignored:    data/seurat/
    Ignored:    omnipathr-log/
    Ignored:    output/.DS_Store
    Ignored:    output/mol_cart.harmony_object.h5Seurat
    Ignored:    output/molkart/
    Ignored:    output/proteomics/
    Ignored:    output/results_cts.lowres.125.sqm
    Ignored:    output/seqIF/
    Ignored:    pipeline_configs/.DS_Store
    Ignored:    plots/
    Ignored:    references/.DS_Store
    Ignored:    renv/.DS_Store
    Ignored:    renv/library/
    Ignored:    renv/staging/

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/figures.supplementary_figure_4.segmentation_metrics.Rmd) and HTML (docs/figures.supplementary_figure_4.segmentation_metrics.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 4c4da66 FloWuenne 2024-03-21 wflow_publish(c("analysis/figures.supplementary_figure_4.segmentation_metrics.Rmd",
html a2cf304 FloWuenne 2024-03-21 Build site.
Rmd 56559c7 FloWuenne 2024-03-21 Cleaned up repository.
Rmd 21b927e FloWuenne 2024-03-17 Updates supplementary figure code.
Rmd b06dcd3 FloWuenne 2024-02-25 Updated Figure 1,4 and S4 and 5 code.
Rmd b760056 FloWuenne 2024-01-31 Updated Supplementary Figure 4.

Introduction

# Load data
qc_dir <- "../data/nf-core_molkart/molkartqc"
files <- fs::dir_ls(path = qc_dir, glob = "*csv")
qc_data <- vroom(files)
Rows: 48 Columns: 12
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (2): sample_id, segmentation_method
dbl (10): total_cells, avg_area, total_spots, spot_assign_per_cell, spot_ass...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
qc_data <- qc_data %>%
  separate(sample_id,
           into = c("string","time","replicate","slide","segmentation"),
           remove = TRUE) %>%
  mutate("sample_ID" = paste(string,time,replicate,slide,sep= "_"))

qc_data$avg_area <- qc_data$avg_area *0.138 * 0.138

qc_data$time  <- factor(qc_data$time,
                        levels = c("control","4h","2d","4d"))

qc_data$segmentation_method <- factor(qc_data$segmentation_method,
                                      levels = c("mesmer","ilastik","cellpose"
                                                 ))

final_samples <- c("sample_control_r1_s1","sample_control_r2_s1",
                   "sample_4h_r1_s1","sample_4h_r2_s2",
                   "sample_2d_r1_s1","sample_2d_r2_s1",
                   "sample_4d_r1_s2","sample_4d_r2_s1")

qc_data <- subset(qc_data,sample_ID %in% final_samples)

qc_data <- qc_data %>%
  pivot_longer(total_cells:spot_assign_percent,
               names_to = "group",
               values_to = "values") %>%
  subset(group %in% c("avg_area","spot_assign_per_cell","spot_assign_percent","total_cells"))

Plot the data

qc_data$group <- gsub("avg_area",paste("Average area (","\U00B5","m2)",sep=""),qc_data$group)
qc_data$group <- gsub("spot_assign_per_cell","Spots / cell",qc_data$group)
qc_data$group <- gsub("spot_assign_percent","% spots in cells",qc_data$group)
qc_data$group <- gsub("total_cells","Total # cells ",qc_data$group)

spots_assigned <- ggplot(qc_data,aes(segmentation_method, y= values, group = segmentation_method)) +
  geom_boxplot(aes(color = segmentation_method, fill = segmentation_method),
               outlier.size = 0, alpha = 0.3) +
  # coord_flip() +
  scale_fill_brewer(palette = "Dark2") +
  scale_color_brewer(palette = "Dark2") +
  scale_x_discrete(labels=c("cellpose" = "Cellpose 2",
                            "ilastik" = "Ilastik Multicut",
                            "mesmer" = "Mesmer")) +
  labs(x = "") +
  theme(legend.position = "none") +
  facet_wrap(~ group, scales = "free") +
  theme(plot.background = element_rect(fill = "white")) +
  geom_point(size = 3.5, aes(fill = segmentation_method), color = "black" ,
             pch = 21, alpha = 1) +
  panel_border()

spots_assigned

Version Author Date
a2cf304 FloWuenne 2024-03-21
save_plot(filename = here("./plots/Supplementary_figure_3.segmentation_metrics.png"),
          plot = spots_assigned,
          base_height = 2.5,
          base_width = 5)


save_plot(filename = here("./plots/Supplementary_figure_3.segmentation_metrics.pdf"),
          plot = spots_assigned,
          base_height = 6)

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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/Berlin
tzcode source: internal

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

other attached packages:
 [1] RColorBrewer_1.1-3 ggsci_3.0.0        ggbeeswarm_0.7.2   here_1.0.1        
 [5] cowplot_1.1.2      ggpubr_0.6.0       lubridate_1.9.3    forcats_1.0.0     
 [9] stringr_1.5.1      purrr_1.0.2        readr_2.1.5        tidyr_1.3.0       
[13] ggplot2_3.4.4      tidyverse_2.0.0    tibble_3.2.1       dplyr_1.1.4       
[17] vroom_1.6.5        workflowr_1.7.1   

loaded via a namespace (and not attached):
 [1] beeswarm_0.4.0      gtable_0.3.4        xfun_0.41          
 [4] bslib_0.6.1         processx_3.8.3      rstatix_0.7.2      
 [7] callr_3.7.3         tzdb_0.4.0          vctrs_0.6.5        
[10] tools_4.3.1         ps_1.7.6            generics_0.1.3     
[13] parallel_4.3.1      fansi_1.0.6         highr_0.10         
[16] pkgconfig_2.0.3     lifecycle_1.0.4     farver_2.1.1       
[19] compiler_4.3.1      git2r_0.33.0        textshaping_0.3.7  
[22] munsell_0.5.0       getPass_0.2-4       carData_3.0-5      
[25] vipor_0.4.7         httpuv_1.6.14       htmltools_0.5.7    
[28] sass_0.4.8          yaml_2.3.8          car_3.1-2          
[31] later_1.3.2         pillar_1.9.0        crayon_1.5.2       
[34] jquerylib_0.1.4     whisker_0.4.1       cachem_1.0.8       
[37] abind_1.4-5         tidyselect_1.2.0    digest_0.6.34      
[40] stringi_1.8.3       labeling_0.4.3      rprojroot_2.0.4    
[43] fastmap_1.1.1       grid_4.3.1          colorspace_2.1-0   
[46] cli_3.6.2           magrittr_2.0.3      utf8_1.2.4         
[49] broom_1.0.5         withr_2.5.2         backports_1.4.1    
[52] scales_1.3.0        promises_1.2.1      bit64_4.0.5        
[55] timechange_0.2.0    rmarkdown_2.25      httr_1.4.7         
[58] bit_4.0.5           ggsignif_0.6.4      ragg_1.2.7         
[61] hms_1.1.3           evaluate_0.23       knitr_1.45         
[64] rlang_1.1.3         Rcpp_1.0.12         glue_1.7.0         
[67] BiocManager_1.30.22 renv_1.0.3          rstudioapi_0.15.0  
[70] jsonlite_1.8.8      R6_2.5.1            systemfonts_1.0.5  
[73] fs_1.6.3