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 e6213a5. 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: .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: 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/
Untracked files:
Untracked: analysis/deprecated/figures.supplementary_figureX.Rmd
Untracked: analysis/deprecated/figures.supplementary_figure_X.MistyR.Rmd
Unstaged changes:
Deleted: analysis/figures.supplementary_figureX.Rmd
Deleted: analysis/figures.supplementary_figure_X.MistyR.Rmd
Deleted: analysis/figures.supplementary_figure_X.proteomics_qc.Rmd
Deleted: figures/Figure_5.eps
Deleted: figures/Figure_5.pdf
Deleted: figures/Figure_5.png
Deleted: figures/Figure_5.svg
Deleted: figures/Supplementary_Figure_1_Molecular_Cartography_ROIs.png
Deleted: figures/Supplementary_figure_5.segmentation_metrics.poster.eps
Modified: figures/Supplementary_figure_X.proteomics.eps
Modified: figures/Supplementary_figure_X.proteomics.png
Modified: results_cts.lowres.125.sqm
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/proteomics.bulk_de_analysis.Rmd
) and HTML
(docs/proteomics.bulk_de_analysis.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 | 56559c7 | FloWuenne | 2024-03-21 | Cleaned up repository. |
Rmd | c1350a5 | FloWuenne | 2024-03-07 | Updated proteomic analsysi and several plots for molkart. |
Rmd | 5dee03d | FloWuenne | 2023-09-04 | Latest code update. |
html | 5dee03d | FloWuenne | 2023-09-04 | Latest code update. |
html | 67e546d | FloWuenne | 2023-07-23 | Build site. |
Rmd | ed31d81 | FloWuenne | 2023-07-02 | Finalized proteomics analysis. |
html | ed31d81 | FloWuenne | 2023-07-02 | Finalized proteomics analysis. |
html | c1395e6 | FloWuenne | 2023-06-20 | Build site. |
Rmd | 236130c | FloWuenne | 2023-06-20 | Updating proteomic analysis. |
html | 236130c | FloWuenne | 2023-06-20 | Updating proteomic analysis. |
library(data.table)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::between() masks data.table::between()
✖ dplyr::filter() masks stats::filter()
✖ dplyr::first() masks data.table::first()
✖ lubridate::hour() masks data.table::hour()
✖ lubridate::isoweek() masks data.table::isoweek()
✖ dplyr::lag() masks stats::lag()
✖ dplyr::last() masks data.table::last()
✖ lubridate::mday() masks data.table::mday()
✖ lubridate::minute() masks data.table::minute()
✖ lubridate::month() masks data.table::month()
✖ lubridate::quarter() masks data.table::quarter()
✖ lubridate::second() masks data.table::second()
✖ purrr::transpose() masks data.table::transpose()
✖ lubridate::wday() masks data.table::wday()
✖ lubridate::week() masks data.table::week()
✖ lubridate::yday() masks data.table::yday()
✖ lubridate::year() masks data.table::year()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(factoextra)
Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(ggsci)
library(cowplot)
Attaching package: 'cowplot'
The following object is masked from 'package:lubridate':
stamp
library(here)
here() starts at /Users/florian_wuennemann/1_Projects/MI_project/mi_spatialomics
library(proDA)
library(limma)
library(dplyr)
library(tibble)
library(tidyr)
library(ggplot2)
library(pheatmap)
library(ggrepel)
library(eulerr)
library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
library(vsn)
Loading required package: Biobase
Loading required package: BiocGenerics
Attaching package: 'BiocGenerics'
The following object is masked from 'package:limma':
plotMA
The following objects are masked from 'package:lubridate':
intersect, setdiff, union
The following objects are masked from 'package:dplyr':
combine, intersect, setdiff, union
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
anyDuplicated, aperm, append, as.data.frame, basename, cbind,
colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort,
table, tapply, union, unique, unsplit, which.max, which.min
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
library(limma)
source("./code/functions.R")
Here we will perform an analysis to detect differentially expressed proteins (DEPs) between the healthy control endocardial layer (control), the endocardial layer adjacent to the infarct at 1 day post infarction (MI_IZ) and the endocardial layer that is remote to the infarct (MI_remote) from the same heart as the MI_IZ.
We will compare two different methods to perform differential expresssion, proDA, which models missing values in it’s statistical model and limma, which uses linear models and can handle missing values.
First, let’s load the filtered protein table from the previous step Filter proteomic data.
## Import imputed protein table (our "bulk" data)
clean_proteins <- fread(file = "./output/proteomics/proteomics.filtered_proteins.tsv")
## First we format the protein matrix for DEP analysis
## Remove duplicates
dups <- clean_proteins[duplicated(clean_proteins$Genes),"Genes"]
clean_proteins_nd <- subset(clean_proteins,!Genes %in% unique(dups$Genes))
## Store gene and protein IDs
protein_ids <- clean_proteins_nd$Protein_Ids
gene_mapping <- clean_proteins_nd %>%
select(Protein_Ids,Genes)
## Remove annotation columns
abundance_matrix <- clean_proteins_nd %>%
select(-c(Protein_Group,Protein_Ids,Protein_Names,Genes))
rownames(abundance_matrix) <- protein_ids
We use the vsn package to normalize our expression data. The vsn normalization function takes non-logged values as input.
## Use vsn normalization on the raw values (non log-transformed)
vsnMatrix <- normalizeVSN(abundance_matrix)
meanSdPlot(vsnMatrix)
Version | Author | Date |
---|---|---|
ed31d81 | FloWuenne | 2023-07-02 |
## Save vsn normalized protein expression values
vsnMatrix_store <- as.data.frame(vsnMatrix)
vsnMatrix_store$gene <- gene_mapping$Genes
write.table(vsnMatrix_store,
file = "./output/proteomics/proteomics.vsn_norm_proteins.tsv",
col.names = TRUE,
row.names = FALSE,
quote = FALSE)
As a fist QC, we will do a principal component analysis (PCA) of the samples. Due to the strong perturbation effect of myocardial infarction, we expect to find samples distributed by group (control, MI_remote, MI_IZ) in the first principle component.
abundance_matrix_pc <- as.data.frame(vsnMatrix) %>%
drop_na()
## Calculate principal components and plot the firs two PCs
res.pca <- prcomp(t(abundance_matrix_pc), scale = TRUE)
fviz_eig(res.pca, addlabels = TRUE)
pcs <- as.data.frame(res.pca$x)
pcs$sample <- colnames(abundance_matrix_pc)
pcs <- pcs %>%
mutate("group" = if_else(grepl("control",sample),"control",
if_else(grepl("MI_IZ",sample),"MI_IZ","MI_remote"))
)
## Set order of groups
pcs$group <- factor(pcs$group,
levels = c("control","MI_remote","MI_IZ"))
## Plot PCs
ggplot(pcs,aes(PC1,PC2, color = group, fill = group)) +
geom_point(size = 5,pch = 21,color = "black") +
scale_fill_manual(values = proteome_palette,
labels = c("Control","MI_remote","MI_IZ")) +
labs(color = "Group") +
guides(fill=guide_legend(title="Treatment group"))
Version | Author | Date |
---|---|---|
ed31d81 | FloWuenne | 2023-07-02 |
saveRDS(res.pca,
file = "./output/proteomics/proteomics.pca_res.rds")
As expected, samples separate in PC1, based on their group category, confirming that the strongest effect between samples is whether the heart experienced an infarct and the location of the endocardial cells relative to the infarct zone.
Let’s use limma to identif differentially expressed proteins
We will define a design matrix to perform differential expression testing in proDA.
design_matrix <- pcs %>%
select(sample,group)
control_mi_cont <- c(0,0,0,1,1,1,1)
iz_remote_cont <- c(0,0,0,0,1,1,1,1)
## column numbers of different groups
control_idx <- c(1,2,3)
mi_iz_idx <- c(4,5,6,7)
mi_remote_idx <- c(8,9,10,11)
design <- model.matrix(~ 0 + design_matrix$group)
rownames(design) <- design_matrix$sample
colnames(design) <- gsub("design_matrix\\$groupMI_","",colnames(design))
colnames(design) <- gsub("design_matrix\\$group","",colnames(design))
fit <- lmFit(vsnMatrix, design)
Warning: Partial NA coefficients for 123 probe(s)
contrast.matrix <- makeContrasts(MI_vs_Ctr = IZ - control,
remote_vs_Ctr = remote - control,
MI_vs_remote = IZ - remote,
levels = design)
fit_contrast <- contrasts.fit(fit, contrast.matrix)
fit_contrast <- eBayes(fit_contrast)
## MI_IZ vs control
limma_mi_ctr <- topTable(fit_contrast,
n=Inf, adjust.method = 'BH', coef= "MI_vs_Ctr",
sort.by = "none")
limma_mi_ctr$gene <- gene_mapping$Genes
limma_mi_ctr$protein_ids <- gene_mapping$Protein_Ids
limma_mi_ctr <- limma_mi_ctr %>%
arrange(adj.P.Val) %>%
mutate("pval" = P.Value,
"analysis" = "MI_IZ_vs_control")
## MI_remote vs MI_remote
limma_remote_ctr <- topTable(fit_contrast,
n=Inf, adjust.method = 'BH', coef= "remote_vs_Ctr",
sort.by = "none")
limma_remote_ctr$gene <- gene_mapping$Genes
limma_remote_ctr$protein_ids <- gene_mapping$Protein_Ids
limma_remote_ctr <- limma_remote_ctr %>%
arrange(adj.P.Val) %>%
mutate("pval" = P.Value,
"analysis" = "MI_remote_vs_control")
limma_remote_ctr$label_protein <- ""
## MI_IZ vs MI_remote
limma_mi_remote <- topTable(fit_contrast,
n=Inf, adjust.method = 'BH', coef= "MI_vs_remote",
sort.by = "none")
limma_mi_remote$gene <- gene_mapping$Genes
limma_mi_remote$protein_ids <- gene_mapping$Protein_Ids
limma_mi_remote <- limma_mi_remote %>%
arrange(adj.P.Val) %>%
mutate("pval" = P.Value,
"analysis" = "MI_IZ_vs_MI_remote")
Let’s visualize the differential expression results using Volcano plots and highlighting the top protein hits per group.
The first comparison we are interested in is comparing the remote zone from infarcted hearts with controls endocardium. This comparison will highlight programs upregulated mainly due to the systemic inflammatory response to myocardial infarction.
## Volcano plot of IZ_remote vs control
limma_mi_ctr$label_protein <- ""
volc_limma_remote_ctr <- plot_pretty_volcano(limma_mi_ctr,
pt_size = 2,
plot_title = "MI_IZ vs control",
sig_thresh = 0.05,
col_pos_logFC = "#E64B35FF",
col_neg_logFC = "#3DA873FF")
ggplotly(volc_limma_remote_ctr)
## Volcano plot of IZ_remote vs control
limma_mi_remote$label_protein <- ""
volc_limma_IZ_remote <- plot_pretty_volcano(limma_mi_remote,
pt_size = 2,
plot_title = "MI_IZ vs MI_remote",
sig_thresh = 0.05,
col_pos_logFC = "#E64B35FF",
col_neg_logFC = "#4DBBD5FF")
ggplotly(volc_limma_IZ_remote)
Let’s combine the results from the limma test into one big table and save it for later use.
limma_merged_stats <- rbind(limma_mi_ctr,limma_remote_ctr,limma_mi_remote)
write.table(limma_merged_stats,
file = "./output/proteomics/proteomics.limma.full_statistics.tsv",
sep = "\t",
col.names = TRUE,
row.names = FALSE,
quote = FALSE)
limma_mi_ctr_genes <- subset(limma_mi_ctr,adj.P.Val <= 0.05)$gene
limma_remote_ctr_genes <- subset(limma_remote_ctr,adj.P.Val <= 0.05)$gene
limma_mi_remote_genes <- subset(limma_mi_remote,adj.P.Val <= 0.05)$gene
limma_venn_vec <- limma_mi_ctr$gene
limma_venn_df <- data.frame("MI_control" = limma_venn_vec %in% limma_mi_ctr_genes,
"remote_control" = limma_venn_vec %in% limma_remote_ctr_genes,
"MI_IZ_MI_remote" = limma_venn_vec %in% limma_mi_remote_genes)
limma_venn_df$gene <- limma_venn_vec
## Plot the 3 group Venn diagram
plot(venn(limma_venn_df[,1:3]))
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 vsn_3.70.0 Biobase_2.62.0
[4] BiocGenerics_0.48.1 plotly_4.10.4 eulerr_7.0.0
[7] ggrepel_0.9.5 pheatmap_1.0.12 limma_3.58.1
[10] proDA_1.16.0 here_1.0.1 cowplot_1.1.2
[13] ggsci_3.0.0 factoextra_1.0.7 lubridate_1.9.3
[16] forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4
[19] purrr_1.0.2 readr_2.1.5 tidyr_1.3.0
[22] tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0
[25] data.table_1.14.10 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] bitops_1.0-7 rlang_1.1.3
[3] magrittr_2.0.3 git2r_0.33.0
[5] matrixStats_1.2.0 compiler_4.3.1
[7] getPass_0.2-4 polylabelr_0.2.0
[9] callr_3.7.3 vctrs_0.6.5
[11] pkgconfig_2.0.3 crayon_1.5.2
[13] fastmap_1.1.1 ellipsis_0.3.2
[15] backports_1.4.1 XVector_0.42.0
[17] labeling_0.4.3 utf8_1.2.4
[19] promises_1.2.1 rmarkdown_2.25
[21] tzdb_0.4.0 ps_1.7.6
[23] preprocessCore_1.64.0 xfun_0.41
[25] zlibbioc_1.48.0 cachem_1.0.8
[27] GenomeInfoDb_1.38.5 jsonlite_1.8.8
[29] highr_0.10 later_1.3.2
[31] DelayedArray_0.28.0 broom_1.0.5
[33] R6_2.5.1 bslib_0.6.1
[35] stringi_1.8.3 car_3.1-2
[37] GenomicRanges_1.54.1 jquerylib_0.1.4
[39] Rcpp_1.0.12 SummarizedExperiment_1.32.0
[41] knitr_1.45 IRanges_2.36.0
[43] httpuv_1.6.14 Matrix_1.6-5
[45] timechange_0.2.0 tidyselect_1.2.0
[47] rstudioapi_0.15.0 abind_1.4-5
[49] yaml_2.3.8 affy_1.80.0
[51] processx_3.8.3 lattice_0.22-5
[53] withr_2.5.2 evaluate_0.23
[55] polyclip_1.10-6 ggpubr_0.6.0
[57] pillar_1.9.0 affyio_1.72.0
[59] BiocManager_1.30.22 carData_3.0-5
[61] MatrixGenerics_1.14.0 whisker_0.4.1
[63] renv_1.0.3 stats4_4.3.1
[65] generics_0.1.3 rprojroot_2.0.4
[67] RCurl_1.98-1.14 S4Vectors_0.40.2
[69] hms_1.1.3 munsell_0.5.0
[71] scales_1.3.0 glue_1.7.0
[73] lazyeval_0.2.2 tools_4.3.1
[75] hexbin_1.28.3 ggsignif_0.6.4
[77] fs_1.6.3 grid_4.3.1
[79] crosstalk_1.2.1 colorspace_2.1-0
[81] GenomeInfoDbData_1.2.11 cli_3.6.2
[83] fansi_1.0.6 S4Arrays_1.2.0
[85] viridisLite_0.4.2 gtable_0.3.4
[87] rstatix_0.7.2 sass_0.4.8
[89] digest_0.6.34 SparseArray_1.2.3
[91] farver_2.1.1 htmlwidgets_1.6.4
[93] htmltools_0.5.7 lifecycle_1.0.4
[95] httr_1.4.7 statmod_1.5.0