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_9.proteomics_qc.Rmd) and HTML (docs/figures.supplementary_figure_9.proteomics_qc.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 e6213a5 FloWuenne 2024-03-21 Publish all updated files.

This supplementary figure contains QC plots for the proteomic data analysis.

## load data
metadata_counts <- fread("./output/proteomics/proteomics.protein_missing_stats.tsv")

Subfigure A - Total proteins identified per group

## Summarize observations across group
metadata_counts_stat <- data_summary(metadata_counts,
                                     varname = "wo_cont", groupnames = c("group"))
Loading required package: plyr
------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------

Attaching package: 'plyr'
The following objects are masked from 'package:plotly':

    arrange, mutate, rename, summarise
The following object is masked from 'package:here':

    here
The following objects are masked from 'package:dplyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize
The following object is masked from 'package:purrr':

    compact
avg_proteins <- mean(metadata_counts$wo_cont)
avg_proteins <- sd(metadata_counts$wo_cont)

metadata_counts_stat$group <- factor(metadata_counts_stat$group,
                                     levels = c("MI_IZ","MI_remote","control"))

## Barplot to show the number of proteins detected per group (excluding contaminants)
n_prot_plot <- ggplot(metadata_counts_stat,aes(group,wo_cont)) +
  geom_bar(aes(fill = group),stat="identity", color="black", 
           position=position_dodge()) +
  geom_point(data = metadata_counts, aes(group,wo_cont),
             fill = "white",pch = 21, color= "black",size = 4) +
  geom_errorbar(aes(ymin=wo_cont, ymax=wo_cont+sd), width=.2,
                 position=position_dodge(.9)) + 
  coord_flip() +
  scale_fill_manual(values = proteome_palette,
                    labels = c("Control","MI_remote","MI_IZ")) +
  labs(x = "",
       y = "Proteins detected") +
  theme(legend.position = "none")

n_prot_plot

Version Author Date
a2cf304 FloWuenne 2024-03-21

Subfigure B - % missing proteins vs number of nuclei collected

metadata_counts$group <- factor(metadata_counts$group,
                                levels = c("control","MI_remote","MI_IZ"))

missingness_plot <- ggplot(metadata_counts,aes(missingness,n_nuclei, label = sample)) +
  geom_point(pch = 21, size = 5,aes(fill = group)) +
  scale_fill_manual(values = proteome_palette,
                    labels = c("Control","MI_remote","MI_IZ")) +
  geom_label_repel() +
  labs(x = "% missing values",
       y = "# nuclei in tissue collected",
       fill = "Group") +
  theme(legend.position = "top")
missingness_plot

Version Author Date
a2cf304 FloWuenne 2024-03-21

Subfigure C - % variance explained by PCs

pca_res <- readRDS("./output/proteomics/proteomics.pca_res.rds")

sdev <- pca_res$sdev[1:5]
var_explained <- data.frame(PC = paste0("PC",1:5),
                            var_expl = (sdev)^2/sum((sdev)^2)
                            )

pca_var <- ggplot(var_explained,aes(PC,var_expl)) +
  geom_bar(stat = "identity", color = "black", fill = "grey30") +
  geom_text(aes(label = paste(100*round(var_expl,2),sep = "")), vjust=1.4, color = "white", size =6) +
  labs(x = "Principal components",
       y = "% Variance explained")

pca_var

Version Author Date
a2cf304 FloWuenne 2024-03-21

Subfigure D - Upset plot for shared proteins between conditions

library(ggplot2)
library(ComplexUpset)

## Load limma results and subset for significantly differential proteins between conditions
limma_res <- fread("./output/proteomics/proteomics.limma.full_statistics.tsv")
limma_res_sig <- subset(limma_res,adj.P.Val <= 0.05)
limma_res_sig <- limma_res_sig %>%
  select(gene,analysis) %>%
  mutate(value = 1) %>%
  # Reshape the data frame so that each gene has 1 row entry for each comparison
  pivot_wider(names_from = analysis, 
              values_from = value, 
              values_fill = list(value = 0)) %>%
  # Sum rows by gene
  group_by(gene) %>%
  summarise_all(sum) %>%
  ungroup()
              
analysis_groups <- c("MI_IZ_vs_control","MI_remote_vs_control","MI_IZ_vs_MI_remote")
upset_plot <- upset(limma_res_sig, analysis_groups , name='Comparison',
                    width_ratio=0.1,
                    set_sizes=(
                      upset_set_size()
        + theme(axis.text.x=element_text(angle=90))
    ))
upset_plot

Version Author Date
a2cf304 FloWuenne 2024-03-21

Assemble final figure

supp_figure_X <- n_prot_plot + missingness_plot + pca_var + wrap_elements(upset_plot)

supp_figure_X <- supp_figure_X + 
  plot_layout(nrow = 2,ncol =2 , widths = c(1,2)) +
  plot_annotation(tag_levels = 'a') & 
  theme(plot.tag = element_text(size = 25)) &
  theme(plot.background = element_rect(fill = "white"))

supp_figure_X

Version Author Date
a2cf304 FloWuenne 2024-03-21
save_plot(filename = "./figures/Supplementary_figure_X.proteomics.png",
          plot = supp_figure_X,
          base_height = 8)


save_plot(filename = "./figures/Supplementary_figure_X.proteomics.eps",
          plot = supp_figure_X,
          base_height = 8)

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] ComplexUpset_1.3.3  plyr_1.8.9          RColorBrewer_1.1-3 
 [4] ggsci_3.0.0         cowplot_1.1.2       ggbeeswarm_0.7.2   
 [7] ggsignif_0.6.4      heatmaply_1.5.0     plotly_4.10.4      
[10] viridis_0.6.4       viridisLite_0.4.2   ggVennDiagram_1.5.0
[13] patchwork_1.2.0     ggrepel_0.9.5       here_1.0.1         
[16] data.table_1.14.10  lubridate_1.9.3     forcats_1.0.0      
[19] stringr_1.5.1       dplyr_1.1.4         purrr_1.0.2        
[22] readr_2.1.5         tidyr_1.3.0         tibble_3.2.1       
[25] ggplot2_3.4.4       tidyverse_2.0.0     workflowr_1.7.1    

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