Last updated: 2021-02-10
Checks: 6 1
Knit directory: Human_Development_snRNAseq/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20200812)
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 84a97c7. 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: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.DS_Store
Untracked files:
Untracked: analysis/14-MarkerAnalysisBCT.Rmd
Untracked: data/adult-clust.txt
Untracked: data/cellinfoALL.Rdata
Untracked: data/dcm-clust.txt
Untracked: data/fetal-clust.txt
Untracked: data/gstlist-adult.Rdata
Untracked: data/gstlist-dcm-res03.Rdata
Untracked: data/gstlist-dcm.Rdata
Untracked: data/gstlist-fetal.Rdata
Untracked: data/gstlist-young.Rdata
Untracked: data/heart-markers-long.txt
Untracked: data/immune-markers-long.txt
Untracked: data/pseudobulk.Rds
Untracked: data/targets_pools.txt
Untracked: data/young-clust.txt
Untracked: output/adult-int.Rds
Untracked: output/adultObjs.Rdata
Untracked: output/all-counts.Rdata
Untracked: output/bct-treat-all.RData
Untracked: output/endo-int-FYA-filtered.Rds
Untracked: output/fetal-int.Rds
Untracked: output/fetalObjs.Rdata
Untracked: output/heart-int-FYA.Rds
Untracked: output/heartFYA.Rds
Untracked: output/human_c2_v5p2.rdata
Untracked: output/immune-int-FYA-filtered.Rds
Untracked: output/intermediateObs.Rdata
Untracked: output/neuron-int-FYA-filtered.Rds
Untracked: output/smc-int-FYA-filtered.Rds
Untracked: output/young-int.Rds
Untracked: output/youngObjs.Rdata
Unstaged changes:
Modified: analysis/06-Celltype-Composition.Rmd
Modified: analysis/15-MarkerAnalysisBCT.Rmd
Modified: analysis/index.Rmd
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.
library(edgeR)
library(RColorBrewer)
library(org.Hs.eg.db)
library(limma)
library(Seurat)
library(monocle)
library(cowplot)
library(DelayedArray)
library(scran)
library(NMF)
library(workflowr)
library(ggplot2)
library(clustree)
library(dplyr)
library(gridBase)
library(grid)
library(speckle)
targets <- read.delim("./data/targets.txt",header=TRUE, stringsAsFactors = FALSE)
targets$FileName2 <- paste(targets$FileName,"/",sep="")
targets$Group_ID2 <- gsub("LV_","",targets$Group_ID)
group <- c("Fetal_1","Fetal_2","Fetal_3",
"Young_1","Young_2","Young_3",
"Adult_1","Adult_2","Adult_3",
"Diseased_1","Diseased_2",
"Diseased_3","Diseased_4")
m <- match(group, targets$Group_ID2)
targets <- targets[m,]
# Load unfiltered counts matrix for every sample (object all)
load("./output/all-counts.Rdata")
heart <- readRDS(file="./output/heartFYA.Rds")
heart$Broad_celltype <- factor(heart$Broad_celltype,
levels=c("Cardiomyocytes","Fibroblast","Endothelial cells",
"Immune cells","Epicardial cells","Neurons",
"Smooth muscle cells","Erythroid"))
heart$biorep <- factor(heart$biorep,levels=c("f1","f2","f3","y1","y2","y3","a1","a2","a3"))
table(heart$biorep,heart$Broad_celltype)
all.bct <- factor(heart$Broad_celltype,
levels=c("Cardiomyocytes","Fibroblast","Endothelial cells",
"Immune cells","Epicardial cells","Neurons",
"Smooth muscle cells","Erythroid"))
sample <- heart$biorep
m <- match(colnames(heart),colnames(all))
all.counts <- all[,m]
columns(org.Hs.eg.db)
ann <- AnnotationDbi:::select(org.Hs.eg.db,keys=rownames(all.counts),columns=c("SYMBOL","ENTREZID","ENSEMBL","GENENAME","CHR"),keytype = "SYMBOL")
m <- match(rownames(all.counts),ann$SYMBOL)
ann <- ann[m,]
mito <- grep("mitochondrial",ann$GENENAME)
ribo <- grep("ribosomal",ann$GENENAME)
missingEZID <- which(is.na(ann$ENTREZID))
chuck <- unique(c(mito,ribo,missingEZID))
all.counts.keep <- all.counts[-chuck,]
ann.keep <- ann[-chuck,]
numzero.genes <- rowSums(all.counts.keep==0)
keep.genes <- numzero.genes < (ncol(all.counts.keep)-20)
all.keep <- all.counts.keep[keep.genes,]
ann.keep.all <- ann.keep[keep.genes,]
logcounts.all <- normCounts(all.keep,log=TRUE,prior.count=0.5)
design <- model.matrix(~0+all.bct+sample)
colnames(design)[1:(length(levels(all.bct)))] <- levels(all.bct)
mycont <- matrix(0,ncol=length(levels(all.bct)),nrow=length(levels(all.bct)))
colnames(mycont)<-levels(all.bct)
diag(mycont)<-1
mycont[upper.tri(mycont)]<- -1/(length(levels(all.bct))-1)
mycont[lower.tri(mycont)]<- -1/(length(levels(all.bct))-1)
# Fill out remaining rows with 0s
zero.rows <- matrix(0,ncol=length(levels(all.bct)),nrow=(ncol(design)-length(levels(all.bct))))
test <- rbind(mycont,zero.rows)
fit <- lmFit(logcounts.all,design)
fit.cont <- contrasts.fit(fit,contrasts=test)
fit.cont <- eBayes(fit.cont,trend=TRUE,robust=TRUE)
fit.cont$genes <- ann.keep.all
treat.all <- treat(fit.cont,lfc=0.5)
dt <- decideTests(treat.all)
summary(dt)
Cardiomyocytes Fibroblast Endothelial cells Immune cells
Down 323 207 418 610
NotSig 18056 18314 18407 17783
Up 822 680 376 808
Epicardial cells Neurons Smooth muscle cells Erythroid
Down 125 261 79 1493
NotSig 18512 18392 18627 17340
Up 564 548 495 368
par(mfrow=c(3,3))
par(mar=c(5,5,2,2))
for(i in 1:ncol(treat.all)){
plotMD(treat.all,coef=i,status = dt[,i],hl.cex=0.5)
abline(h=0,col=colours()[c(226)])
lines(lowess(treat.all$Amean,treat.all$coefficients[,i]),lwd=1.5,col=4)
}
heart <- readRDS("./output/heartFYA.Rds")
DefaultAssay(heart) <- "RNA"
sig.genes <- gene.label <- vector("list", ncol(treat.all))
for(i in 1:length(sig.genes)){
top <- topTreat(treat.all,coef=i,n=Inf,sort.by="t")
sig.genes[[i]] <- rownames(top)[top$logFC>0][1:10]
gene.label[[i]] <- paste(rownames(top)[top$logFC>0][1:10],colnames(treat.all)[i],sep="-")
}
csig <- unlist(sig.genes)
genes <- unlist(gene.label)
missing <- is.na(match(csig,rownames(heart)))
csig2 <- csig[!missing]
gene.cols <- rep(c(ggplotColors(7),"grey"),each=10)
gene.cols <- gene.cols[!missing]
d <- duplicated(csig2)
csig2 <- csig2[!d]
gene.cols <- gene.cols[!d]
DotPlot(heart,features=unique(csig2),group.by="Broad_celltype",cols = c("lightgrey", "red"))+RotatedAxis() + FontSize(y.text = 8, x.text=14) + labs(y=element_blank(),x=element_blank()) + coord_flip() + theme(axis.text.y = element_text(color=(gene.cols)))
load("./output/human_c2_v5p2.rdata")
c2.id <- ids2indices(Hs.c2,treat.all$genes$ENTREZID)
reactome.id <-c2.id[grep("REACTOME",names(c2.id))]
cardio.camera <- cameraPR(treat.all$t[,1],reactome.id)
cardio.camera.up <- cardio.camera[cardio.camera[,2]=="Up",]
fibro.camera <- cameraPR(treat.all$t[,2],reactome.id)
fibro.camera.up <- fibro.camera[fibro.camera[,2]=="Up",]
endo.camera <- cameraPR(treat.all$t[,3],reactome.id)
endo.camera.up <- endo.camera[endo.camera[,2]=="Up",]
immune.camera <- cameraPR(treat.all$t[,4],reactome.id)
immune.camera.up <- immune.camera[immune.camera[,2]=="Up",]
epic.camera <- cameraPR(treat.all$t[,5],reactome.id)
epic.camera.up <- epic.camera[epic.camera[,2]=="Up",]
neuron.camera <- cameraPR(treat.all$t[,6],reactome.id)
neuron.camera.up <- neuron.camera[neuron.camera[,2]=="Up",]
smc.camera <- cameraPR(treat.all$t[,7],reactome.id)
smc.camera.up <- smc.camera[smc.camera[,2]=="Up",]
eryth.camera <- cameraPR(treat.all$t[,8],reactome.id)
eryth.camera.up <- eryth.camera[eryth.camera[,2]=="Up",]
nsets <- 5
all.cam <- rbind(cardio.camera.up[1:nsets,], fibro.camera.up[1:nsets,],
endo.camera.up[1:nsets,],immune.camera.up[1:nsets,],
epic.camera.up[1:nsets,],neuron.camera.up[1:nsets,],
smc.camera.up[1:nsets,],eryth.camera.up[1:nsets,])
scores <- -log10(all.cam$PValue)
names(scores) <- rownames(all.cam)
names(scores) <- gsub("REACTOME_","",names(scores))
par(mfrow=c(1,1))
par(mar=c(5,41,3,2))
barplot(scores[length(scores):1],horiz = T,las=2,col=rev(rep(c(ggplotColors(7),"grey"),each=nsets)),cex.names=0.9,
cex.axis = 1.5,xlab="-log10(PValue)",cex.lab=1.5)
abline(v= -log10(0.05),lty=2)
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] grid splines parallel stats4 stats graphics grDevices
[8] utils datasets methods base
other attached packages:
[1] speckle_0.0.2 gridBase_0.4-7
[3] dplyr_1.0.2 clustree_0.4.3
[5] ggraph_2.0.4 NMF_0.23.0
[7] cluster_2.1.0 rngtools_1.5
[9] pkgmaker_0.32.2 registry_0.5-1
[11] scran_1.18.1 SingleCellExperiment_1.12.0
[13] SummarizedExperiment_1.20.0 GenomicRanges_1.42.0
[15] GenomeInfoDb_1.26.1 DelayedArray_0.16.0
[17] MatrixGenerics_1.2.0 matrixStats_0.57.0
[19] cowplot_1.1.0 monocle_2.18.0
[21] DDRTree_0.1.5 irlba_2.3.3
[23] VGAM_1.1-4 ggplot2_3.3.2
[25] Matrix_1.2-18 Seurat_3.2.2
[27] org.Hs.eg.db_3.12.0 AnnotationDbi_1.52.0
[29] IRanges_2.24.0 S4Vectors_0.28.0
[31] Biobase_2.50.0 BiocGenerics_0.36.0
[33] RColorBrewer_1.1-2 edgeR_3.32.0
[35] limma_3.46.0 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] reticulate_1.18 tidyselect_1.1.0
[3] RSQLite_2.2.1 htmlwidgets_1.5.2
[5] combinat_0.0-8 docopt_0.7.1
[7] BiocParallel_1.24.1 Rtsne_0.15
[9] munsell_0.5.0 codetools_0.2-18
[11] ica_1.0-2 statmod_1.4.35
[13] future_1.20.1 miniUI_0.1.1.1
[15] withr_2.3.0 colorspace_2.0-0
[17] fastICA_1.2-2 knitr_1.30
[19] rstudioapi_0.13 ROCR_1.0-11
[21] tensor_1.5 listenv_0.8.0
[23] labeling_0.4.2 git2r_0.27.1
[25] slam_0.1-47 GenomeInfoDbData_1.2.4
[27] polyclip_1.10-0 farver_2.0.3
[29] bit64_4.0.5 pheatmap_1.0.12
[31] rprojroot_2.0.2 parallelly_1.21.0
[33] vctrs_0.3.5 generics_0.1.0
[35] xfun_0.19 R6_2.5.0
[37] doParallel_1.0.16 graphlayouts_0.7.1
[39] rsvd_1.0.3 locfit_1.5-9.4
[41] bitops_1.0-6 spatstat.utils_1.17-0
[43] assertthat_0.2.1 promises_1.1.1
[45] scales_1.1.1 gtable_0.3.0
[47] beachmat_2.6.2 globals_0.14.0
[49] goftest_1.2-2 tidygraph_1.2.0
[51] rlang_0.4.9 lazyeval_0.2.2
[53] yaml_2.2.1 reshape2_1.4.4
[55] abind_1.4-5 httpuv_1.5.4
[57] tools_4.0.2 ellipsis_0.3.1
[59] ggridges_0.5.2 Rcpp_1.0.5
[61] plyr_1.8.6 sparseMatrixStats_1.2.0
[63] zlibbioc_1.36.0 purrr_0.3.4
[65] RCurl_1.98-1.2 densityClust_0.3
[67] rpart_4.1-15 deldir_0.2-3
[69] pbapply_1.4-3 viridis_0.5.1
[71] zoo_1.8-8 ggrepel_0.8.2
[73] fs_1.5.0 magrittr_2.0.1
[75] data.table_1.13.2 lmtest_0.9-38
[77] RANN_2.6.1 fitdistrplus_1.1-1
[79] patchwork_1.1.0 mime_0.9
[81] evaluate_0.14 xtable_1.8-4
[83] sparsesvd_0.2 gridExtra_2.3
[85] HSMMSingleCell_1.10.0 compiler_4.0.2
[87] tibble_3.0.4 KernSmooth_2.23-18
[89] crayon_1.3.4 htmltools_0.5.0
[91] mgcv_1.8-33 later_1.1.0.1
[93] tidyr_1.1.2 DBI_1.1.0
[95] tweenr_1.0.1 MASS_7.3-53
[97] igraph_1.2.6 pkgconfig_2.0.3
[99] plotly_4.9.2.1 scuttle_1.0.3
[101] foreach_1.5.1 dqrng_0.2.1
[103] XVector_0.30.0 stringr_1.4.0
[105] digest_0.6.27 sctransform_0.3.1
[107] RcppAnnoy_0.0.17 spatstat.data_1.5-2
[109] rmarkdown_2.5 leiden_0.3.5
[111] uwot_0.1.9 DelayedMatrixStats_1.12.1
[113] shiny_1.5.0 lifecycle_0.2.0
[115] nlme_3.1-150 jsonlite_1.7.1
[117] BiocNeighbors_1.8.1 viridisLite_0.3.0
[119] pillar_1.4.7 lattice_0.20-41
[121] fastmap_1.0.1 httr_1.4.2
[123] survival_3.2-7 glue_1.4.2
[125] qlcMatrix_0.9.7 FNN_1.1.3
[127] spatstat_1.64-1 png_0.1-7
[129] iterators_1.0.13 bluster_1.0.0
[131] bit_4.0.4 ggforce_0.3.2
[133] stringi_1.5.3 blob_1.2.1
[135] BiocSingular_1.6.0 memoise_1.1.0
[137] future.apply_1.6.0