Last updated: 2022-11-29

Checks: 6 1

Knit directory: humanCardiacFibroblasts/

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


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20210903) 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 2a11889. 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:    data/GSEA/
    Ignored:    data/humanFibroblast/
    Ignored:    figure/DEgenesGZplusSG_Groups.Rmd/.DS_Store

Untracked files:
    Untracked:  analysis/assignLabelshumanHeartsPlusGrazIntWoHH.Rmd

Unstaged changes:
    Modified:   analysis/assignLabelshumanHeartsPlusGrazIntWoGZ24.Rmd
    Modified:   analysis/integrateAcrossPatientsGZplusSG.Rmd
    Modified:   analysis/mergeHumanSamplesPlusGraz.Rmd
    Modified:   metadata2.txt

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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


load packages

suppressPackageStartupMessages({
  library(SingleCellExperiment)
  library(tidyverse)
  library(Seurat)
  library(magrittr)
  library(dplyr)
  library(purrr)
  library(ggplot2)
  library(here)
  library(runSeurat3)
  library(ggsci)
  library(ggpubr)
  library(pheatmap)
  library(viridis)
  library(sctransform)
})

load data

basedir <- here()
seurat <- readRDS(file = paste0(basedir, 
                              "/data/humanHeartsPlusGraz_intPatients_merged", 
                              "_seurat.rds"))
Idents(seurat) <- seurat$seurat_clusters
table(seurat$ID)

 GZ1 GZ14 GZ15 GZ16 GZ17 GZ18  GZ2 GZ20  GZ3  GZ4  GZ5  GZ6  GZ7 SG17 SG21 SG24 
2740 1268 4439  436 1370 2280 1684 2706 2396  545  781  491  653 1321 1536 2381 
SG25 SG28 SG29 SG31 SG32 SG33 SG34 SG35 
3131 1545 2496 1192 1428 6286  620 2363 

assign labels

seurat$label <- "other"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("2","9"))] <- "Endothelial"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("8"))] <- "EndoEC"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("6"))] <- "Tcell"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("5"))] <- "Cardiomyocyte"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("0"))] <- "Fibroblast"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("1"))] <- "Perivascular"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("7"))] <- "SMC"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("3"))] <- "resMacrophage"
seurat$label[which(seurat$integrated_snn_res.0.6 %in% c("8"))] <- "infMacrophage"
seurat$label[which(seurat$integrated_snn_res.0.4 %in% c("10"))] <- "NeuralCells"

## reembedding of cluster 4 (mix of diff cell typpes)
seuratSub <- subset(seurat, integrated_snn_res.0.4=="4")

seuratSub <- rerunSeurat3(seuratSub)
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 3471
Number of edges: 127742

Running Louvain algorithm...
Maximum modularity in 10 random starts: 0.9495
Number of communities: 12
Elapsed time: 0 seconds
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 3471
Number of edges: 127742

Running Louvain algorithm...
Maximum modularity in 10 random starts: 0.9033
Number of communities: 15
Elapsed time: 0 seconds
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 3471
Number of edges: 127742

Running Louvain algorithm...
Maximum modularity in 10 random starts: 0.8787
Number of communities: 17
Elapsed time: 0 seconds
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 3471
Number of edges: 127742

Running Louvain algorithm...
Maximum modularity in 10 random starts: 0.9290
Number of communities: 14
Elapsed time: 0 seconds
Tcell <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("0", "3","6", "5", "11"))]
endo1 <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("1"))]
fibro <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("2"))]
peri <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("9", "12"))]
Adipo <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("7"))]
resmacro <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("4", "13"))]
infmacro <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("8"))]
LEC <- colnames(seuratSub)[which(seuratSub$RNA_snn_res.0.4 %in% c("10"))]


seurat$label[which(colnames(seurat) %in% Tcell)] <- "Tcell"
seurat$label[which(colnames(seurat) %in% peri)] <- "Perivascular"
seurat$label[which(colnames(seurat) %in% endo1)] <- "Endothelial"
seurat$label[which(colnames(seurat) %in% fibro)] <- "Fibroblast"
seurat$label[which(colnames(seurat) %in% Adipo)] <- "Adipocytes"
seurat$label[which(colnames(seurat) %in% resmacro)] <- "resMacrophage"
seurat$label[which(colnames(seurat) %in% infmacro)] <- "infMacrophage"
seurat$label[which(colnames(seurat) %in% LEC)] <- "LEC"

unique(seurat$integrated_snn_res.0.4)
 [1] 8  2  4  3  6  0  1  5  7  9  10
Levels: 0 1 2 3 4 5 6 7 8 9 10
seurat$clust <- as.character(seurat$integrated_snn_res.0.4)
seurat$clust[which(seurat$integrated_snn_res.0.6 == "8")] <- "11"
seurat$clust[which(colnames(seurat) %in% Tcell)] <- "12"
seurat$clust[which(colnames(seurat) %in% peri)] <- "13"
seurat$clust[which(colnames(seurat) %in% endo1)] <- "14"
seurat$clust[which(colnames(seurat) %in% fibro)] <- "15"
seurat$clust[which(colnames(seurat) %in% Adipo)] <- "16"
seurat$clust[which(colnames(seurat) %in% resmacro)] <- "17"
seurat$clust[which(colnames(seurat) %in% infmacro)] <- "18"
seurat$clust[which(colnames(seurat) %in% LEC)] <- "19"

color vectors

colPal <- c(pal_igv()(12),
            pal_aaas()(10))[1:length(levels(seurat))]
colTec <- pal_jama()(length(unique(seurat$technique)))
colSmp <- c(pal_uchicago()(9), pal_npg()(10), pal_aaas()(10), 
            pal_jama()(7))[1:length(unique(seurat$dataset))]
colCond <- pal_npg()(length(unique(seurat$cond)))
colID <- c(pal_jco()(10), pal_npg()(10), pal_futurama()(10),
           pal_d3()(10))[1:length(unique(seurat$ID))]
colOrig <- pal_aaas()(length(unique(seurat$origin)))
colIso <- pal_nejm()(length(unique(seurat$isolation)))
colProc <- pal_aaas()(length(unique(seurat$processing)))
colLab <- c(pal_futurama()(8), pal_uchicago()(6))[1:length(unique(seurat$label))]
colClust <- c(pal_igv()(12),
            pal_aaas()(10))[1:length(unique(seurat$clust))]

names(colPal) <- levels(seurat)
names(colTec) <- unique(seurat$technique)
names(colSmp) <- unique(seurat$dataset)
names(colCond) <- unique(seurat$cond)
names(colID) <- unique(seurat$ID)
names(colOrig) <- unique(seurat$origin)
names(colIso) <- unique(seurat$isolation)
names(colProc) <- unique(seurat$processing)
names(colLab) <- unique(seurat$label)
names(colClust) <- unique(seurat$clust)

vis data

clusters

DimPlot(seurat, reduction = "umap", cols=colPal)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

DimPlot(seurat, reduction = "umap", cols=colPal,
        shuffle = T)+
  theme_void()

cluster plus re-embedding

DimPlot(seurat, reduction = "umap", cols=colClust, group.by = "clust")+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

DimPlot(seurat, reduction = "umap", cols=colClust, group.by = "clust",
        shuffle = F)+
  theme_void()

label

DimPlot(seurat, reduction = "umap",  group.by = "label", cols=colLab)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

DimPlot(seurat, reduction = "umap", group.by = "label", cols=colLab,
        shuffle = T)+
  theme_void()

technique

DimPlot(seurat, reduction = "umap", group.by = "technique", cols=colTec)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

Sample

DimPlot(seurat, reduction = "umap", group.by = "dataset", cols=colSmp)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

ID

DimPlot(seurat, reduction = "umap", group.by = "ID", cols=colID, shuffle = T)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

DimPlot(seurat, reduction = "umap", group.by = "ID", cols=colID,
        shuffle = T)+
  theme_void()

Origin

DimPlot(seurat, reduction = "umap", group.by = "origin", cols=colOrig,
        shuffle = T)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

DimPlot(seurat, reduction = "umap", group.by = "origin", cols=colOrig,
        shuffle = T)+
  theme_void()

isolation

DimPlot(seurat, reduction = "umap", group.by = "isolation", cols=colIso)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

cond

DimPlot(seurat, reduction = "umap", group.by = "cond", cols=colCond)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

processing

DimPlot(seurat, reduction = "umap", group.by = "processing", cols=colProc)+
  theme_bw() +
  theme(axis.text = element_blank(), axis.ticks = element_blank(), 
        panel.grid.minor = element_blank()) +
  xlab("UMAP1") +
  ylab("UMAP2")

cnt tables

per patient

## total cells per patient
knitr::kable(table(seurat$ID))
Var1 Freq
GZ1 2740
GZ14 1268
GZ15 4439
GZ16 436
GZ17 1370
GZ18 2280
GZ2 1684
GZ20 2706
GZ3 2396
GZ4 545
GZ5 781
GZ6 491
GZ7 653
SG17 1321
SG21 1536
SG24 2381
SG25 3131
SG28 1545
SG29 2496
SG31 1192
SG32 1428
SG33 6286
SG34 620
SG35 2363
## celltype per patient counts
knitr::kable(table(seurat$label, seurat$ID))
GZ1 GZ14 GZ15 GZ16 GZ17 GZ18 GZ2 GZ20 GZ3 GZ4 GZ5 GZ6 GZ7 SG17 SG21 SG24 SG25 SG28 SG29 SG31 SG32 SG33 SG34 SG35
Adipocytes 0 0 0 0 0 0 1 0 2 1 0 0 45 1 1 3 49 3 1 0 5 8 0 0
Cardiomyocyte 208 51 115 25 71 329 107 46 238 45 39 12 90 56 96 299 397 71 182 178 40 216 177 303
EndoEC 173 32 78 21 20 182 127 301 192 64 39 46 12 23 39 92 98 48 99 60 73 82 18 61
Endothelial 290 290 961 54 167 456 312 933 374 119 207 108 111 826 186 376 548 506 461 197 511 189 82 522
Fibroblast 813 321 1185 126 377 630 667 652 867 143 263 156 240 165 613 882 871 316 422 354 324 414 120 794
infMacrophage 76 22 149 32 135 23 20 38 39 20 10 15 5 114 29 53 102 10 379 35 15 1393 8 55
LEC 5 0 0 0 0 6 5 2 30 0 0 0 3 1 1 9 0 0 9 0 2 0 0 0
NeuralCells 58 10 76 6 28 28 28 20 33 7 26 2 8 19 7 27 27 26 21 22 27 38 5 28
Perivascular 473 337 1299 18 144 380 264 337 401 55 117 54 63 46 302 285 437 406 297 179 240 178 122 322
resMacrophage 225 72 174 24 200 73 63 104 80 34 21 47 12 13 126 118 150 8 391 91 55 651 42 145
SMC 224 102 256 22 45 144 57 149 108 31 41 19 58 40 93 139 139 134 113 51 82 35 22 73
Tcell 195 31 146 108 183 29 33 124 32 26 18 32 6 17 43 98 313 17 121 25 54 3082 24 60
## celltype percentages per patient
datLab <- data.frame(table(seurat$label, seurat$ID))
colnames(datLab) <- c("label", "ID", "cnt")
datPat <- data.frame(table(seurat$ID))
colnames(datPat) <- c("ID", "total")
datFrac <- datLab %>% left_join(., datPat, by="ID") %>% 
  mutate(percentage = cnt*100/total)
knitr::kable(datFrac)
label ID cnt total percentage
Adipocytes GZ1 0 2740 0.0000000
Cardiomyocyte GZ1 208 2740 7.5912409
EndoEC GZ1 173 2740 6.3138686
Endothelial GZ1 290 2740 10.5839416
Fibroblast GZ1 813 2740 29.6715328
infMacrophage GZ1 76 2740 2.7737226
LEC GZ1 5 2740 0.1824818
NeuralCells GZ1 58 2740 2.1167883
Perivascular GZ1 473 2740 17.2627737
resMacrophage GZ1 225 2740 8.2116788
SMC GZ1 224 2740 8.1751825
Tcell GZ1 195 2740 7.1167883
Adipocytes GZ14 0 1268 0.0000000
Cardiomyocyte GZ14 51 1268 4.0220820
EndoEC GZ14 32 1268 2.5236593
Endothelial GZ14 290 1268 22.8706625
Fibroblast GZ14 321 1268 25.3154574
infMacrophage GZ14 22 1268 1.7350158
LEC GZ14 0 1268 0.0000000
NeuralCells GZ14 10 1268 0.7886435
Perivascular GZ14 337 1268 26.5772871
resMacrophage GZ14 72 1268 5.6782334
SMC GZ14 102 1268 8.0441640
Tcell GZ14 31 1268 2.4447950
Adipocytes GZ15 0 4439 0.0000000
Cardiomyocyte GZ15 115 4439 2.5906736
EndoEC GZ15 78 4439 1.7571525
Endothelial GZ15 961 4439 21.6490200
Fibroblast GZ15 1185 4439 26.6952016
infMacrophage GZ15 149 4439 3.3566118
LEC GZ15 0 4439 0.0000000
NeuralCells GZ15 76 4439 1.7120973
Perivascular GZ15 1299 4439 29.2633476
resMacrophage GZ15 174 4439 3.9198018
SMC GZ15 256 4439 5.7670647
Tcell GZ15 146 4439 3.2890291
Adipocytes GZ16 0 436 0.0000000
Cardiomyocyte GZ16 25 436 5.7339450
EndoEC GZ16 21 436 4.8165138
Endothelial GZ16 54 436 12.3853211
Fibroblast GZ16 126 436 28.8990826
infMacrophage GZ16 32 436 7.3394495
LEC GZ16 0 436 0.0000000
NeuralCells GZ16 6 436 1.3761468
Perivascular GZ16 18 436 4.1284404
resMacrophage GZ16 24 436 5.5045872
SMC GZ16 22 436 5.0458716
Tcell GZ16 108 436 24.7706422
Adipocytes GZ17 0 1370 0.0000000
Cardiomyocyte GZ17 71 1370 5.1824818
EndoEC GZ17 20 1370 1.4598540
Endothelial GZ17 167 1370 12.1897810
Fibroblast GZ17 377 1370 27.5182482
infMacrophage GZ17 135 1370 9.8540146
LEC GZ17 0 1370 0.0000000
NeuralCells GZ17 28 1370 2.0437956
Perivascular GZ17 144 1370 10.5109489
resMacrophage GZ17 200 1370 14.5985401
SMC GZ17 45 1370 3.2846715
Tcell GZ17 183 1370 13.3576642
Adipocytes GZ18 0 2280 0.0000000
Cardiomyocyte GZ18 329 2280 14.4298246
EndoEC GZ18 182 2280 7.9824561
Endothelial GZ18 456 2280 20.0000000
Fibroblast GZ18 630 2280 27.6315789
infMacrophage GZ18 23 2280 1.0087719
LEC GZ18 6 2280 0.2631579
NeuralCells GZ18 28 2280 1.2280702
Perivascular GZ18 380 2280 16.6666667
resMacrophage GZ18 73 2280 3.2017544
SMC GZ18 144 2280 6.3157895
Tcell GZ18 29 2280 1.2719298
Adipocytes GZ2 1 1684 0.0593824
Cardiomyocyte GZ2 107 1684 6.3539192
EndoEC GZ2 127 1684 7.5415677
Endothelial GZ2 312 1684 18.5273159
Fibroblast GZ2 667 1684 39.6080760
infMacrophage GZ2 20 1684 1.1876485
LEC GZ2 5 1684 0.2969121
NeuralCells GZ2 28 1684 1.6627078
Perivascular GZ2 264 1684 15.6769596
resMacrophage GZ2 63 1684 3.7410926
SMC GZ2 57 1684 3.3847981
Tcell GZ2 33 1684 1.9596200
Adipocytes GZ20 0 2706 0.0000000
Cardiomyocyte GZ20 46 2706 1.6999261
EndoEC GZ20 301 2706 11.1234294
Endothelial GZ20 933 2706 34.4789357
Fibroblast GZ20 652 2706 24.0946046
infMacrophage GZ20 38 2706 1.4042868
LEC GZ20 2 2706 0.0739098
NeuralCells GZ20 20 2706 0.7390983
Perivascular GZ20 337 2706 12.4538064
resMacrophage GZ20 104 2706 3.8433112
SMC GZ20 149 2706 5.5062823
Tcell GZ20 124 2706 4.5824095
Adipocytes GZ3 2 2396 0.0834725
Cardiomyocyte GZ3 238 2396 9.9332220
EndoEC GZ3 192 2396 8.0133556
Endothelial GZ3 374 2396 15.6093489
Fibroblast GZ3 867 2396 36.1853088
infMacrophage GZ3 39 2396 1.6277129
LEC GZ3 30 2396 1.2520868
NeuralCells GZ3 33 2396 1.3772955
Perivascular GZ3 401 2396 16.7362270
resMacrophage GZ3 80 2396 3.3388982
SMC GZ3 108 2396 4.5075125
Tcell GZ3 32 2396 1.3355593
Adipocytes GZ4 1 545 0.1834862
Cardiomyocyte GZ4 45 545 8.2568807
EndoEC GZ4 64 545 11.7431193
Endothelial GZ4 119 545 21.8348624
Fibroblast GZ4 143 545 26.2385321
infMacrophage GZ4 20 545 3.6697248
LEC GZ4 0 545 0.0000000
NeuralCells GZ4 7 545 1.2844037
Perivascular GZ4 55 545 10.0917431
resMacrophage GZ4 34 545 6.2385321
SMC GZ4 31 545 5.6880734
Tcell GZ4 26 545 4.7706422
Adipocytes GZ5 0 781 0.0000000
Cardiomyocyte GZ5 39 781 4.9935980
EndoEC GZ5 39 781 4.9935980
Endothelial GZ5 207 781 26.5044814
Fibroblast GZ5 263 781 33.6747759
infMacrophage GZ5 10 781 1.2804097
LEC GZ5 0 781 0.0000000
NeuralCells GZ5 26 781 3.3290653
Perivascular GZ5 117 781 14.9807939
resMacrophage GZ5 21 781 2.6888604
SMC GZ5 41 781 5.2496799
Tcell GZ5 18 781 2.3047375
Adipocytes GZ6 0 491 0.0000000
Cardiomyocyte GZ6 12 491 2.4439919
EndoEC GZ6 46 491 9.3686354
Endothelial GZ6 108 491 21.9959267
Fibroblast GZ6 156 491 31.7718941
infMacrophage GZ6 15 491 3.0549898
LEC GZ6 0 491 0.0000000
NeuralCells GZ6 2 491 0.4073320
Perivascular GZ6 54 491 10.9979633
resMacrophage GZ6 47 491 9.5723014
SMC GZ6 19 491 3.8696538
Tcell GZ6 32 491 6.5173116
Adipocytes GZ7 45 653 6.8912711
Cardiomyocyte GZ7 90 653 13.7825421
EndoEC GZ7 12 653 1.8376723
Endothelial GZ7 111 653 16.9984686
Fibroblast GZ7 240 653 36.7534456
infMacrophage GZ7 5 653 0.7656968
LEC GZ7 3 653 0.4594181
NeuralCells GZ7 8 653 1.2251149
Perivascular GZ7 63 653 9.6477795
resMacrophage GZ7 12 653 1.8376723
SMC GZ7 58 653 8.8820827
Tcell GZ7 6 653 0.9188361
Adipocytes SG17 1 1321 0.0757002
Cardiomyocyte SG17 56 1321 4.2392127
EndoEC SG17 23 1321 1.7411052
Endothelial SG17 826 1321 62.5283876
Fibroblast SG17 165 1321 12.4905375
infMacrophage SG17 114 1321 8.6298259
LEC SG17 1 1321 0.0757002
NeuralCells SG17 19 1321 1.4383043
Perivascular SG17 46 1321 3.4822104
resMacrophage SG17 13 1321 0.9841030
SMC SG17 40 1321 3.0280091
Tcell SG17 17 1321 1.2869039
Adipocytes SG21 1 1536 0.0651042
Cardiomyocyte SG21 96 1536 6.2500000
EndoEC SG21 39 1536 2.5390625
Endothelial SG21 186 1536 12.1093750
Fibroblast SG21 613 1536 39.9088542
infMacrophage SG21 29 1536 1.8880208
LEC SG21 1 1536 0.0651042
NeuralCells SG21 7 1536 0.4557292
Perivascular SG21 302 1536 19.6614583
resMacrophage SG21 126 1536 8.2031250
SMC SG21 93 1536 6.0546875
Tcell SG21 43 1536 2.7994792
Adipocytes SG24 3 2381 0.1259975
Cardiomyocyte SG24 299 2381 12.5577488
EndoEC SG24 92 2381 3.8639227
Endothelial SG24 376 2381 15.7916842
Fibroblast SG24 882 2381 37.0432591
infMacrophage SG24 53 2381 2.2259555
LEC SG24 9 2381 0.3779924
NeuralCells SG24 27 2381 1.1339773
Perivascular SG24 285 2381 11.9697606
resMacrophage SG24 118 2381 4.9559009
SMC SG24 139 2381 5.8378832
Tcell SG24 98 2381 4.1159177
Adipocytes SG25 49 3131 1.5649952
Cardiomyocyte SG25 397 3131 12.6796551
EndoEC SG25 98 3131 3.1299904
Endothelial SG25 548 3131 17.5023954
Fibroblast SG25 871 3131 27.8185883
infMacrophage SG25 102 3131 3.2577451
LEC SG25 0 3131 0.0000000
NeuralCells SG25 27 3131 0.8623443
Perivascular SG25 437 3131 13.9572022
resMacrophage SG25 150 3131 4.7908017
SMC SG25 139 3131 4.4394762
Tcell SG25 313 3131 9.9968061
Adipocytes SG28 3 1545 0.1941748
Cardiomyocyte SG28 71 1545 4.5954693
EndoEC SG28 48 1545 3.1067961
Endothelial SG28 506 1545 32.7508091
Fibroblast SG28 316 1545 20.4530744
infMacrophage SG28 10 1545 0.6472492
LEC SG28 0 1545 0.0000000
NeuralCells SG28 26 1545 1.6828479
Perivascular SG28 406 1545 26.2783172
resMacrophage SG28 8 1545 0.5177994
SMC SG28 134 1545 8.6731392
Tcell SG28 17 1545 1.1003236
Adipocytes SG29 1 2496 0.0400641
Cardiomyocyte SG29 182 2496 7.2916667
EndoEC SG29 99 2496 3.9663462
Endothelial SG29 461 2496 18.4695513
Fibroblast SG29 422 2496 16.9070513
infMacrophage SG29 379 2496 15.1842949
LEC SG29 9 2496 0.3605769
NeuralCells SG29 21 2496 0.8413462
Perivascular SG29 297 2496 11.8990385
resMacrophage SG29 391 2496 15.6650641
SMC SG29 113 2496 4.5272436
Tcell SG29 121 2496 4.8477564
Adipocytes SG31 0 1192 0.0000000
Cardiomyocyte SG31 178 1192 14.9328859
EndoEC SG31 60 1192 5.0335570
Endothelial SG31 197 1192 16.5268456
Fibroblast SG31 354 1192 29.6979866
infMacrophage SG31 35 1192 2.9362416
LEC SG31 0 1192 0.0000000
NeuralCells SG31 22 1192 1.8456376
Perivascular SG31 179 1192 15.0167785
resMacrophage SG31 91 1192 7.6342282
SMC SG31 51 1192 4.2785235
Tcell SG31 25 1192 2.0973154
Adipocytes SG32 5 1428 0.3501401
Cardiomyocyte SG32 40 1428 2.8011204
EndoEC SG32 73 1428 5.1120448
Endothelial SG32 511 1428 35.7843137
Fibroblast SG32 324 1428 22.6890756
infMacrophage SG32 15 1428 1.0504202
LEC SG32 2 1428 0.1400560
NeuralCells SG32 27 1428 1.8907563
Perivascular SG32 240 1428 16.8067227
resMacrophage SG32 55 1428 3.8515406
SMC SG32 82 1428 5.7422969
Tcell SG32 54 1428 3.7815126
Adipocytes SG33 8 6286 0.1272669
Cardiomyocyte SG33 216 6286 3.4362074
EndoEC SG33 82 6286 1.3044862
Endothelial SG33 189 6286 3.0066815
Fibroblast SG33 414 6286 6.5860643
infMacrophage SG33 1393 6286 22.1603563
LEC SG33 0 6286 0.0000000
NeuralCells SG33 38 6286 0.6045180
Perivascular SG33 178 6286 2.8316895
resMacrophage SG33 651 6286 10.3563474
SMC SG33 35 6286 0.5567929
Tcell SG33 3082 6286 49.0295896
Adipocytes SG34 0 620 0.0000000
Cardiomyocyte SG34 177 620 28.5483871
EndoEC SG34 18 620 2.9032258
Endothelial SG34 82 620 13.2258065
Fibroblast SG34 120 620 19.3548387
infMacrophage SG34 8 620 1.2903226
LEC SG34 0 620 0.0000000
NeuralCells SG34 5 620 0.8064516
Perivascular SG34 122 620 19.6774194
resMacrophage SG34 42 620 6.7741935
SMC SG34 22 620 3.5483871
Tcell SG34 24 620 3.8709677
Adipocytes SG35 0 2363 0.0000000
Cardiomyocyte SG35 303 2363 12.8226830
EndoEC SG35 61 2363 2.5814642
Endothelial SG35 522 2363 22.0905628
Fibroblast SG35 794 2363 33.6013542
infMacrophage SG35 55 2363 2.3275497
LEC SG35 0 2363 0.0000000
NeuralCells SG35 28 2363 1.1849344
Perivascular SG35 322 2363 13.6267457
resMacrophage SG35 145 2363 6.1362675
SMC SG35 73 2363 3.0892933
Tcell SG35 60 2363 2.5391452
ordVec <- datFrac %>% dplyr::filter(label=="Tcell") %>% 
  arrange(., percentage)
ordBar <- c("Tcell","infMacrophage","resMacrophage","Fibroblast","Perivascular",
            "SMC","Endothelial","EndoEC","LEC","Cardiomyocyte","Adipocytes",
            "NeuralCells")
datFrac <-datFrac %>% mutate(labelFac=factor(label, levels = ordBar))
ggbarplot(datFrac, x="ID", y="percentage",
          fill = "labelFac",
          palette = colLab,
          order= ordVec$ID) +
  rotate_x_text(angle = 90)

## only Myocarditis patients
selMyo <- unique(seurat$ID[which(seurat$cond != "HH")])
datFracSel <- datFrac %>% filter(ID %in% selMyo)
ggbarplot(datFracSel, x="ID", y="percentage",
          fill = "labelFac",
          palette = colLab,
          order= ordVec$ID) +
  rotate_x_text(angle = 90)

assign groups based on T cell fraction

vis marker for celltype assignment

heatmap

genes <- data.frame(gene=rownames(seurat)) %>% 
    mutate(geneID=gsub("^.*\\.", "", gene)) 

selGenesAll <- read_tsv(file = paste0(basedir,
                                      "/data/markerLabels.txt")) %>% 
  left_join(., genes, by = "geneID")

Idents(seurat) <- seurat$seurat_clusters
pOut <- avgHeatmap(seurat = seurat, selGenes = selGenesAll,
                  colVecIdent = colPal, 
                  ordVec=levels(seurat),
                  gapVecR=NULL, gapVecC=NULL,cc=T,
                  cr=F, condCol=F)

Idents(seurat) <- seurat$label
pOut <- avgHeatmap(seurat = seurat, selGenes = selGenesAll,
                  colVecIdent = colLab, 
                  ordVec=levels(seurat),
                  gapVecR=NULL, gapVecC=NULL,cc=T,
                  cr=F, condCol=F)

Dotplot

DotPlot(seurat, assay="RNA", features = selGenesAll$gene, scale =T,
        cluster.idents = T) +
  scale_color_viridis_c() +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  scale_x_discrete(breaks=selGenesAll$gene, labels=selGenesAll$geneID) +
  xlab("") + ylab("")

Idents(seurat) <- seurat$seurat_clusters
DotPlot(seurat, assay="RNA", features = selGenesAll$gene, scale =T,
        cluster.idents = T) +
  scale_color_viridis_c() +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  scale_x_discrete(breaks=selGenesAll$gene, labels=selGenesAll$geneID) +
  xlab("") + ylab("")

violin plots selected marker

genesDat <- data.frame(EnsID=rownames(seurat)) %>% 
  mutate(gene=gsub(".*\\.", "", EnsID))
selGenes <- data.frame(gene=c("CD2", "TNNT2", "PECAM1", "NRG1", "PROX1",
                              "PDGFRA", "RGS5", "MYH11", "C1QA", "NRXN1",
                              "PLIN1")) %>% 
  left_join(., genesDat, by="gene")

pList <- sapply(selGenes$EnsID, function(x){
  p <- VlnPlot(object = seurat, features = x,
               group.by = "label",
               cols = colLab, pt.size = 0
               ) + 
    theme(legend.position = "none")
    
  plot(p)
})

pList <- sapply(selGenes$EnsID, function(x){
  p <- VlnPlot(object = seurat, features = x,
               group.by = "label",
               cols = colLab, pt.size = 0.3
               ) + 
    theme(legend.position = "none")
    
  plot(p)
})

Feature plots BMPs

## list with all gene names for mapping of EnsIDs
genesDat <- data.frame(EnsID=rownames(seurat)) %>% 
  mutate(gene=gsub(".*\\.", "", EnsID))

## selected genes to plot
selGenes <- data.frame(gene=c("BMP2", "BMP4", "BMPR1A", "BMPR2")) %>% 
  left_join(., genesDat, by="gene")

## plotting loop order=F
pList <- sapply(selGenes$EnsID, function(x){
p <- FeaturePlot(seurat, reduction = "umap", 
            features = x,
            cols=c("lightgrey", "darkred"),
            order = F)+
  theme(legend.position="right")
  plot(p)
})

## plotting loop order=T
pList <- sapply(selGenes$EnsID, function(x){
p <- FeaturePlot(seurat, reduction = "umap", 
            features = x,
            cols=c("lightgrey", "darkred"),
            order = T)+
  theme(legend.position="right")
  plot(p)
})

average counts BMPs in Fibroblasts

seuratSub <- subset(seurat, label=="Fibroblast")

## assay data
clusterAssigned <- as.data.frame(seuratSub$ID) %>%
  dplyr::mutate(cell=rownames(.))
colnames(clusterAssigned)[1] <- "ident"
seuratDat <- GetAssayData(seuratSub)
  
  ## genes of interest
genes <- data.frame(gene=rownames(seuratSub)) %>% 
  mutate(geneID=gsub("^.*\\.", "", gene)) %>% filter(geneID %in% selGenes$gene)

  ## matrix with averaged cnts per ident
logNormExpres <- as.data.frame(t(as.matrix(
  seuratDat[which(rownames(seuratDat) %in% genes$gene),])))
logNormExpres <- logNormExpres %>% dplyr::mutate(cell=rownames(.)) %>%
  dplyr::left_join(.,clusterAssigned, by=c("cell")) %>%
  dplyr::select(-cell) %>% dplyr::group_by(ident) %>%
  dplyr::summarise_all(mean)

write.table(logNormExpres, 
            file=paste0(basedir, "/data/BmpCntsFibroblastsPerPatient_woHH.txt"),
            row.names = F, col.names = T, sep = "\t", quote = F)

save seurat object

saveRDS(seurat, file = paste0(basedir, 
                              "/data/humanHeartsPlusGraz_intPatients_merged", 
                              "labeled_woHH_seurat.rds"))

session info

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] sctransform_0.3.5           viridis_0.6.2              
 [3] viridisLite_0.4.1           pheatmap_1.0.12            
 [5] ggpubr_0.4.0                ggsci_2.9                  
 [7] runSeurat3_0.1.0            here_1.0.1                 
 [9] magrittr_2.0.3              sp_1.5-0                   
[11] SeuratObject_4.1.2          Seurat_4.2.0               
[13] forcats_0.5.2               stringr_1.4.1              
[15] dplyr_1.0.10                purrr_0.3.5                
[17] readr_2.1.3                 tidyr_1.2.1                
[19] tibble_3.1.8                ggplot2_3.3.6              
[21] tidyverse_1.3.2             SingleCellExperiment_1.18.1
[23] SummarizedExperiment_1.26.1 Biobase_2.56.0             
[25] GenomicRanges_1.48.0        GenomeInfoDb_1.32.4        
[27] IRanges_2.30.1              S4Vectors_0.34.0           
[29] BiocGenerics_0.42.0         MatrixGenerics_1.8.1       
[31] matrixStats_0.62.0         

loaded via a namespace (and not attached):
  [1] utf8_1.2.2             reticulate_1.26        tidyselect_1.2.0      
  [4] htmlwidgets_1.5.4      grid_4.2.1             Rtsne_0.16            
  [7] munsell_0.5.0          codetools_0.2-18       ica_1.0-3             
 [10] future_1.28.0          miniUI_0.1.1.1         withr_2.5.0           
 [13] spatstat.random_2.2-0  colorspace_2.0-3       progressr_0.11.0      
 [16] highr_0.9              knitr_1.40             rstudioapi_0.14       
 [19] ROCR_1.0-11            ggsignif_0.6.4         tensor_1.5            
 [22] listenv_0.8.0          labeling_0.4.2         git2r_0.30.1          
 [25] GenomeInfoDbData_1.2.8 polyclip_1.10-4        bit64_4.0.5           
 [28] farver_2.1.1           rprojroot_2.0.3        parallelly_1.32.1     
 [31] vctrs_0.5.0            generics_0.1.3         xfun_0.34             
 [34] R6_2.5.1               ggbeeswarm_0.6.0       bitops_1.0-7          
 [37] spatstat.utils_3.0-1   cachem_1.0.6           DelayedArray_0.22.0   
 [40] assertthat_0.2.1       vroom_1.6.0            promises_1.2.0.1      
 [43] scales_1.2.1           googlesheets4_1.0.1    beeswarm_0.4.0        
 [46] rgeos_0.5-9            gtable_0.3.1           globals_0.16.1        
 [49] goftest_1.2-3          workflowr_1.7.0        rlang_1.0.6           
 [52] splines_4.2.1          rstatix_0.7.0          lazyeval_0.2.2        
 [55] gargle_1.2.1           spatstat.geom_2.4-0    broom_1.0.1           
 [58] yaml_2.3.6             reshape2_1.4.4         abind_1.4-5           
 [61] modelr_0.1.9           backports_1.4.1        httpuv_1.6.6          
 [64] tools_4.2.1            ellipsis_0.3.2         spatstat.core_2.4-4   
 [67] jquerylib_0.1.4        RColorBrewer_1.1-3     ggridges_0.5.4        
 [70] Rcpp_1.0.9             plyr_1.8.7             zlibbioc_1.42.0       
 [73] RCurl_1.98-1.9         rpart_4.1.19           deldir_1.0-6          
 [76] pbapply_1.5-0          cowplot_1.1.1          zoo_1.8-11            
 [79] haven_2.5.1            ggrepel_0.9.1          cluster_2.1.4         
 [82] fs_1.5.2               data.table_1.14.4      scattermore_0.8       
 [85] lmtest_0.9-40          reprex_2.0.2           RANN_2.6.1            
 [88] googledrive_2.0.0      fitdistrplus_1.1-8     hms_1.1.2             
 [91] patchwork_1.1.2        mime_0.12              evaluate_0.17         
 [94] xtable_1.8-4           readxl_1.4.1           gridExtra_2.3         
 [97] compiler_4.2.1         KernSmooth_2.23-20     crayon_1.5.2          
[100] htmltools_0.5.3        mgcv_1.8-41            later_1.3.0           
[103] tzdb_0.3.0             lubridate_1.8.0        DBI_1.1.3             
[106] dbplyr_2.2.1           MASS_7.3-58.1          Matrix_1.5-1          
[109] car_3.1-1              cli_3.4.1              parallel_4.2.1        
[112] igraph_1.3.5           pkgconfig_2.0.3        plotly_4.10.0         
[115] spatstat.sparse_3.0-0  xml2_1.3.3             vipor_0.4.5           
[118] bslib_0.4.0            XVector_0.36.0         rvest_1.0.3           
[121] digest_0.6.30          RcppAnnoy_0.0.19       spatstat.data_3.0-0   
[124] rmarkdown_2.17         cellranger_1.1.0       leiden_0.4.3          
[127] uwot_0.1.14            shiny_1.7.2            lifecycle_1.0.3       
[130] nlme_3.1-160           jsonlite_1.8.3         carData_3.0-5         
[133] fansi_1.0.3            pillar_1.8.1           lattice_0.20-45       
[136] ggrastr_1.0.1          fastmap_1.1.0          httr_1.4.4            
[139] survival_3.4-0         glue_1.6.2             png_0.1-7             
[142] bit_4.0.4              stringi_1.7.8          sass_0.4.2            
[145] irlba_2.3.5.1          future.apply_1.9.1    
date()
[1] "Tue Nov 29 15:51:21 2022"

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] sctransform_0.3.5           viridis_0.6.2              
 [3] viridisLite_0.4.1           pheatmap_1.0.12            
 [5] ggpubr_0.4.0                ggsci_2.9                  
 [7] runSeurat3_0.1.0            here_1.0.1                 
 [9] magrittr_2.0.3              sp_1.5-0                   
[11] SeuratObject_4.1.2          Seurat_4.2.0               
[13] forcats_0.5.2               stringr_1.4.1              
[15] dplyr_1.0.10                purrr_0.3.5                
[17] readr_2.1.3                 tidyr_1.2.1                
[19] tibble_3.1.8                ggplot2_3.3.6              
[21] tidyverse_1.3.2             SingleCellExperiment_1.18.1
[23] SummarizedExperiment_1.26.1 Biobase_2.56.0             
[25] GenomicRanges_1.48.0        GenomeInfoDb_1.32.4        
[27] IRanges_2.30.1              S4Vectors_0.34.0           
[29] BiocGenerics_0.42.0         MatrixGenerics_1.8.1       
[31] matrixStats_0.62.0         

loaded via a namespace (and not attached):
  [1] utf8_1.2.2             reticulate_1.26        tidyselect_1.2.0      
  [4] htmlwidgets_1.5.4      grid_4.2.1             Rtsne_0.16            
  [7] munsell_0.5.0          codetools_0.2-18       ica_1.0-3             
 [10] future_1.28.0          miniUI_0.1.1.1         withr_2.5.0           
 [13] spatstat.random_2.2-0  colorspace_2.0-3       progressr_0.11.0      
 [16] highr_0.9              knitr_1.40             rstudioapi_0.14       
 [19] ROCR_1.0-11            ggsignif_0.6.4         tensor_1.5            
 [22] listenv_0.8.0          labeling_0.4.2         git2r_0.30.1          
 [25] GenomeInfoDbData_1.2.8 polyclip_1.10-4        bit64_4.0.5           
 [28] farver_2.1.1           rprojroot_2.0.3        parallelly_1.32.1     
 [31] vctrs_0.5.0            generics_0.1.3         xfun_0.34             
 [34] R6_2.5.1               ggbeeswarm_0.6.0       bitops_1.0-7          
 [37] spatstat.utils_3.0-1   cachem_1.0.6           DelayedArray_0.22.0   
 [40] assertthat_0.2.1       vroom_1.6.0            promises_1.2.0.1      
 [43] scales_1.2.1           googlesheets4_1.0.1    beeswarm_0.4.0        
 [46] rgeos_0.5-9            gtable_0.3.1           globals_0.16.1        
 [49] goftest_1.2-3          workflowr_1.7.0        rlang_1.0.6           
 [52] splines_4.2.1          rstatix_0.7.0          lazyeval_0.2.2        
 [55] gargle_1.2.1           spatstat.geom_2.4-0    broom_1.0.1           
 [58] yaml_2.3.6             reshape2_1.4.4         abind_1.4-5           
 [61] modelr_0.1.9           backports_1.4.1        httpuv_1.6.6          
 [64] tools_4.2.1            ellipsis_0.3.2         spatstat.core_2.4-4   
 [67] jquerylib_0.1.4        RColorBrewer_1.1-3     ggridges_0.5.4        
 [70] Rcpp_1.0.9             plyr_1.8.7             zlibbioc_1.42.0       
 [73] RCurl_1.98-1.9         rpart_4.1.19           deldir_1.0-6          
 [76] pbapply_1.5-0          cowplot_1.1.1          zoo_1.8-11            
 [79] haven_2.5.1            ggrepel_0.9.1          cluster_2.1.4         
 [82] fs_1.5.2               data.table_1.14.4      scattermore_0.8       
 [85] lmtest_0.9-40          reprex_2.0.2           RANN_2.6.1            
 [88] googledrive_2.0.0      fitdistrplus_1.1-8     hms_1.1.2             
 [91] patchwork_1.1.2        mime_0.12              evaluate_0.17         
 [94] xtable_1.8-4           readxl_1.4.1           gridExtra_2.3         
 [97] compiler_4.2.1         KernSmooth_2.23-20     crayon_1.5.2          
[100] htmltools_0.5.3        mgcv_1.8-41            later_1.3.0           
[103] tzdb_0.3.0             lubridate_1.8.0        DBI_1.1.3             
[106] dbplyr_2.2.1           MASS_7.3-58.1          Matrix_1.5-1          
[109] car_3.1-1              cli_3.4.1              parallel_4.2.1        
[112] igraph_1.3.5           pkgconfig_2.0.3        plotly_4.10.0         
[115] spatstat.sparse_3.0-0  xml2_1.3.3             vipor_0.4.5           
[118] bslib_0.4.0            XVector_0.36.0         rvest_1.0.3           
[121] digest_0.6.30          RcppAnnoy_0.0.19       spatstat.data_3.0-0   
[124] rmarkdown_2.17         cellranger_1.1.0       leiden_0.4.3          
[127] uwot_0.1.14            shiny_1.7.2            lifecycle_1.0.3       
[130] nlme_3.1-160           jsonlite_1.8.3         carData_3.0-5         
[133] fansi_1.0.3            pillar_1.8.1           lattice_0.20-45       
[136] ggrastr_1.0.1          fastmap_1.1.0          httr_1.4.4            
[139] survival_3.4-0         glue_1.6.2             png_0.1-7             
[142] bit_4.0.4              stringi_1.7.8          sass_0.4.2            
[145] irlba_2.3.5.1          future.apply_1.9.1