Last updated: 2021-02-09
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 file has unstaged changes. 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 1de80dd. 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: 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/endo-int-FYA-filtered.Rds
Untracked: output/fetal-int.Rds
Untracked: output/fetalObjs.Rdata
Untracked: output/heartFYA.Rds
Untracked: output/immune-int-FYA-filtered.Rds
Untracked: output/smc-int-FYA-filtered.Rds
Untracked: output/young-int.Rds
Untracked: output/youngObjs.Rdata
Unstaged changes:
Modified: analysis/12-ClustImmune.Rmd
Modified: analysis/13-ClustNeuron.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.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/12-ClustImmune.Rmd
) and HTML (docs/12-ClustImmune.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 | ffb8763 | bphipson | 2021-02-08 | Added all analysis files |
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)
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,]
fetal.integrated <- readRDS(file="./output/RDataObjects/fetal-int.Rds")
load(file="./output/RDataObjects/fetalObjs.Rdata")
young.integrated <- readRDS(file="./output/RDataObjects/young-int.Rds")
load(file="./output/RDataObjects/youngObjs.Rdata")
adult.integrated <- readRDS(file="./output/RDataObjects/adult-int.Rds")
load(file="./output/RDataObjects/adultObjs.Rdata")
heart <- merge(fetal.integrated, y = c(young.integrated, adult.integrated), project = "heart")
DefaultAssay(object = heart) <- "RNA"
immune <- subset(heart,subset = Broad_celltype == "Immune cells")
Check for cells with very low number of uniquely detected genes.
par(mfrow=c(1,2))
plot(density(immune$nFeature_RNA),main="Number of genes detected")
abline(v=500,col=2)
plot(density(immune$nCount_RNA),main="Library size")
abline(v=2500,col=2)
#immune <- subset(immune, subset = nFeature_RNA > 500 & nCount_RNA > 2500)
dim(immune)
[1] 17926 4131
table(immune$biorep)
a1 a2 a3 f1 f2 f3 y1 y2 y3
449 530 519 287 274 196 337 808 731
immune.list <- SplitObject(immune, split.by = "biorep")
for (i in 1:length(immune.list)) {
immune.list[[i]] <- SCTransform(immune.list[[i]], verbose = FALSE)
}
kf <- min(sapply(immune.list, ncol))
immune.anchors <- FindIntegrationAnchors(object.list = immune.list, dims=1:30,anchor.features = 3000,k.filter=kf)
immune.integrated <- IntegrateData(anchorset = immune.anchors,dims=1:30)
DefaultAssay(object = immune.integrated) <- "integrated"
immune.integrated <- ScaleData(immune.integrated, verbose = FALSE)
immune.integrated <- RunPCA(immune.integrated, npcs = 50, verbose = FALSE)
ElbowPlot(immune.integrated,ndims=50)
VizDimLoadings(immune.integrated, dims = 1:4, reduction = "pca")
DimPlot(immune.integrated, reduction = "pca",group.by="orig.ident")
DimPlot(immune.integrated, reduction = "pca",group.by="biorep")
DimPlot(immune.integrated, reduction = "pca",group.by="sex")
DimPlot(immune.integrated, reduction = "pca",group.by="batch")
DimHeatmap(immune.integrated, dims = 1:15, cells = 500, balanced = TRUE)
DimHeatmap(immune.integrated, dims = 16:30, cells = 500, balanced = TRUE)
#DimHeatmap(immune.integrated, dims = 31:45, cells = 500, balanced = TRUE)
immune.integrated <- FindNeighbors(immune.integrated, dims = 1:15)
immune.integrated <- FindClusters(immune.integrated, resolution = 0.1)
table(Idents(immune.integrated))
0 1 2 3 4 5 6
2311 563 445 344 219 209 40
par(mfrow=c(1,1))
par(mar=c(5,4,2,2))
barplot(table(Idents(immune.integrated)),ylab="Number of cells",xlab="Clusters")
title("Number of cells in each cluster")
set.seed(10)
immune.integrated <- RunTSNE(immune.integrated, reduction = "pca", dims = 1:15)
DimPlot(immune.integrated, reduction = "tsne",label=TRUE,label.size = 6,pt.size = 0.5)+NoLegend()
pdf(file="./output/Figures/tsne-immuneALL-res01.pdf",width=10,height=8,onefile = FALSE)
DimPlot(immune.integrated, reduction = "tsne",label=TRUE,label.size = 6,pt.size = 0.5)+NoLegend()
dev.off()
DimPlot(immune.integrated, reduction = "tsne", group.by = "orig.ident")
DimPlot(immune.integrated, reduction = "tsne", split.by = "orig.ident")
DimPlot(immune.integrated, reduction = "tsne", group.by = "biorep")
DimPlot(immune.integrated, reduction = "tsne", group.by = "sex")
DimPlot(immune.integrated, reduction = "tsne", split.by = "sex")
DimPlot(immune.integrated, reduction = "tsne", group.by = "batch")
par(mfrow=c(1,1))
par(mar=c(4,4,2,2))
tab <- table(Idents(immune.integrated),immune.integrated$biorep)
barplot(t(tab/rowSums(tab)),beside=TRUE,col=ggplotColors(9),legend=TRUE)
par(mfrow=c(1,1))
par(mar=c(4,4,2,2))
tab <- table(Idents(immune.integrated),immune.integrated$orig.ident)
barplot(t(tab/rowSums(tab)),beside=TRUE,col=ggplotColors(3))
legend("topleft",legend=colnames(tab),fill=ggplotColors(3))
clusres <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2)
for(i in 1:length(clusres)){
immune.integrated <- FindClusters(immune.integrated,
resolution = clusres[i])
}
pct.male <- function(x) {mean(x=="m")}
pct.female <- function(x) {mean(x=="f")}
pct.fetal <- function(x) {mean(x=="fetal")}
pct.young <- function(x) {mean(x=="young")}
pct.adult <- function(x) {mean(x=="adult")}
clustree(immune.integrated, prefix = "integrated_snn_res.")
clustree(immune.integrated, prefix = "integrated_snn_res.",
node_colour = "sex", node_colour_aggr = "pct.female",assay="RNA")
clustree(immune.integrated, prefix = "integrated_snn_res.",
node_colour = "sex", node_colour_aggr = "pct.male",assay="RNA")
clustree(immune.integrated, prefix = "integrated_snn_res.",
node_colour = "orig.ident", node_colour_aggr = "pct.fetal",assay="RNA")
clustree(immune.integrated, prefix = "integrated_snn_res.",
node_colour = "orig.ident", node_colour_aggr = "pct.young",assay="RNA")
clustree(immune.integrated, prefix = "integrated_snn_res.",
node_colour = "orig.ident", node_colour_aggr = "pct.adult",assay="RNA")
DefaultAssay(immune.integrated) <- "RNA"
Idents(immune.integrated) <- immune.integrated$integrated_snn_res.0.1
saveRDS(immune.integrated,file="./output/RDataObjects/immune-int-FYA-filtered.Rds")
#immune.integrated <- readRDS(file="./output/RDataObjects/immune-int-FYA.Rds")
# Load unfiltered counts matrix for every sample (object all)
load("./output/RDataObjects/all-counts.Rdata")
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] splines parallel stats4 stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] dplyr_1.0.2 clustree_0.4.3
[3] ggraph_2.0.4 NMF_0.23.0
[5] cluster_2.1.0 rngtools_1.5
[7] pkgmaker_0.32.2 registry_0.5-1
[9] scran_1.18.1 SingleCellExperiment_1.12.0
[11] SummarizedExperiment_1.20.0 GenomicRanges_1.42.0
[13] GenomeInfoDb_1.26.1 DelayedArray_0.16.0
[15] MatrixGenerics_1.2.0 matrixStats_0.57.0
[17] cowplot_1.1.0 monocle_2.18.0
[19] DDRTree_0.1.5 irlba_2.3.3
[21] VGAM_1.1-4 ggplot2_3.3.2
[23] Matrix_1.2-18 Seurat_3.2.2
[25] org.Hs.eg.db_3.12.0 AnnotationDbi_1.52.0
[27] IRanges_2.24.0 S4Vectors_0.28.0
[29] Biobase_2.50.0 BiocGenerics_0.36.0
[31] RColorBrewer_1.1-2 edgeR_3.32.0
[33] 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] grid_4.0.2 combinat_0.0-8
[7] docopt_0.7.1 BiocParallel_1.24.1
[9] Rtsne_0.15 munsell_0.5.0
[11] codetools_0.2-18 ica_1.0-2
[13] statmod_1.4.35 future_1.20.1
[15] miniUI_0.1.1.1 withr_2.3.0
[17] colorspace_2.0-0 fastICA_1.2-2
[19] knitr_1.30 rstudioapi_0.13
[21] ROCR_1.0-11 tensor_1.5
[23] listenv_0.8.0 labeling_0.4.2
[25] git2r_0.27.1 slam_0.1-47
[27] GenomeInfoDbData_1.2.4 polyclip_1.10-0
[29] farver_2.0.3 bit64_4.0.5
[31] pheatmap_1.0.12 rprojroot_2.0.2
[33] parallelly_1.21.0 vctrs_0.3.5
[35] generics_0.1.0 xfun_0.19
[37] R6_2.5.0 doParallel_1.0.16
[39] graphlayouts_0.7.1 rsvd_1.0.3
[41] locfit_1.5-9.4 bitops_1.0-6
[43] spatstat.utils_1.17-0 assertthat_0.2.1
[45] promises_1.1.1 scales_1.1.1
[47] gtable_0.3.0 beachmat_2.6.2
[49] globals_0.14.0 goftest_1.2-2
[51] tidygraph_1.2.0 rlang_0.4.9
[53] lazyeval_0.2.2 checkmate_2.0.0
[55] yaml_2.2.1 reshape2_1.4.4
[57] abind_1.4-5 backports_1.2.0
[59] httpuv_1.5.4 tools_4.0.2
[61] gridBase_0.4-7 ellipsis_0.3.1
[63] ggridges_0.5.2 Rcpp_1.0.5
[65] plyr_1.8.6 sparseMatrixStats_1.2.0
[67] zlibbioc_1.36.0 purrr_0.3.4
[69] RCurl_1.98-1.2 densityClust_0.3
[71] rpart_4.1-15 deldir_0.2-3
[73] pbapply_1.4-3 viridis_0.5.1
[75] zoo_1.8-8 ggrepel_0.8.2
[77] fs_1.5.0 magrittr_2.0.1
[79] data.table_1.13.2 lmtest_0.9-38
[81] RANN_2.6.1 whisker_0.4
[83] fitdistrplus_1.1-1 patchwork_1.1.0
[85] mime_0.9 evaluate_0.14
[87] xtable_1.8-4 sparsesvd_0.2
[89] gridExtra_2.3 HSMMSingleCell_1.10.0
[91] compiler_4.0.2 tibble_3.0.4
[93] KernSmooth_2.23-18 crayon_1.3.4
[95] htmltools_0.5.0 mgcv_1.8-33
[97] later_1.1.0.1 tidyr_1.1.2
[99] DBI_1.1.0 tweenr_1.0.1
[101] MASS_7.3-53 igraph_1.2.6
[103] pkgconfig_2.0.3 plotly_4.9.2.1
[105] scuttle_1.0.3 foreach_1.5.1
[107] dqrng_0.2.1 XVector_0.30.0
[109] stringr_1.4.0 digest_0.6.27
[111] sctransform_0.3.1 RcppAnnoy_0.0.17
[113] spatstat.data_1.5-2 rmarkdown_2.5
[115] leiden_0.3.5 uwot_0.1.9
[117] DelayedMatrixStats_1.12.1 shiny_1.5.0
[119] lifecycle_0.2.0 nlme_3.1-150
[121] jsonlite_1.7.1 BiocNeighbors_1.8.1
[123] viridisLite_0.3.0 pillar_1.4.7
[125] lattice_0.20-41 fastmap_1.0.1
[127] httr_1.4.2 survival_3.2-7
[129] glue_1.4.2 qlcMatrix_0.9.7
[131] FNN_1.1.3 spatstat_1.64-1
[133] png_0.1-7 iterators_1.0.13
[135] bluster_1.0.0 bit_4.0.4
[137] ggforce_0.3.2 stringi_1.5.3
[139] blob_1.2.1 BiocSingular_1.6.0
[141] memoise_1.1.0 future.apply_1.6.0