Last updated: 2022-01-10
Checks: 6 1
Knit directory: AD_CO_scRNAseq/
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(20220110)
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 70227c2. 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:
Untracked files:
Untracked: analysis/AD_analysis.Rmd
Untracked: analysis/CO_analysis.Rmd
Untracked: data/AD/
Untracked: data/AD_CO_aggregated/
Untracked: data/CO/
Untracked: data/Kanton_2019/
Untracked: data/selection_dyn_genes.txt
Untracked: output/AD_clusters_res08.csv
Untracked: output/AD_filtered_barcodes.csv
Untracked: output/AD_sub_neuro_barcodes.csv
Untracked: output/AD_sub_neuro_res08.csv
Unstaged changes:
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(Seurat)
library(dplyr)
library(here)
library(ggplot2)
library(ggthemes)
library(SeuratDisk)
# not loaded but required:
# scater - function plotExpression
# SoupX - function quickMarkers
# Nebulosa - function plot_density
D1 <- Read10X(here("data","CO"))
Sat_D1 <- CreateSeuratObject(D1, min.cells = 3)
Sat_D1 <- PercentageFeatureSet(Sat_D1, pattern = "^MT-", col.name = "percent.mt")
Sat_D1 <- PercentageFeatureSet(Sat_D1, pattern = "^RP[SL][[:digit:]]|^RPLP[[:digit:]]|^RPSA", col.name = "percent.ribo")
Idents(Sat_D1) <- rep("CO", length(Sat_D1$orig.ident))
VlnPlot(Sat_D1, c("nFeature_RNA", "nCount_RNA", "percent.mt", "percent.ribo"), ncol = 2, cols = "#4EA2A2") &
theme_tufte() &
theme(legend.position="none")
summary(Sat_D1$nFeature_RNA)
Min. 1st Qu. Median Mean 3rd Qu. Max.
48 1552 3190 3330 4576 11885
summary(Sat_D1$nCount_RNA)
Min. 1st Qu. Median Mean 3rd Qu. Max.
500 3028 8894 12929 16344 133090
summary(Sat_D1$percent.mt)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 2.516 3.860 10.233 6.094 90.238
summary(Sat_D1$percent.ribo)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.692 11.338 18.710 18.207 24.381 69.609
plot1 <- FeatureScatter(Sat_D1, feature1 = "nCount_RNA", feature2 = "percent.mt")
plot2 <- FeatureScatter(Sat_D1, feature1 = "nCount_RNA", feature2 = "nFeature_RNA")
plot1 + plot2
Sat_D1 <- subset(Sat_D1, subset = nFeature_RNA > 1000 & nFeature_RNA < 7000 & percent.mt < 10)
Sat_D1 <- SCTransform(Sat_D1, verbose = FALSE)
Sat_D1 <- CellCycleScoring(Sat_D1, s.features = cc.genes.updated.2019$s.genes,
g2m.features = cc.genes.updated.2019$g2m.genes, set.ident = TRUE)
Sat_D1 <- RunPCA(Sat_D1, features = VariableFeatures(Sat_D1))
Sat_D1 <- RunUMAP(Sat_D1, dims = 1:15)
DimPlot(Sat_D1, group.by = "Phase") +
theme_tufte()
set.seed(42)
Sat_D1 <- FindNeighbors(Sat_D1, dims=1:15, verbose = FALSE)
Sat_D1 <- FindClusters(Sat_D1, resolution = 0.8, verbose = FALSE)
autumn_palette <- c("#751A33", "#B34233", "#D28F33", "#D4B95E", "#4EA2A2", "#506432",
"#1A8693", "#cbdfbd", "#d4e09b", "#f6f4d2", "#f19c79", "#a44a3f")
DimPlot(Sat_D1, label = T, group.by = "SCT_snn_res.0.8", cols = autumn_palette) +
theme_tufte()
VlnPlot(Sat_D1, c("nFeature_RNA", "nCount_RNA", "percent.mt", "percent.ribo"), ncol = 2, cols = autumn_palette) &
theme_tufte() &
theme(legend.position="none")
FindMarkers(Sat_D1, ident.1 = "5", logfc.threshold = 0.5, features = VariableFeatures(Sat_D1), verbose = FALSE) %>%
head(n=20)
p_val avg_log2FC pct.1 pct.2 p_val_adj
MT-CO3 2.097968e-74 -1.8344515 0.901 0.994 4.427341e-70
MT-CO2 4.034208e-74 -1.8511021 0.885 0.996 8.513389e-70
MT-ATP6 2.939489e-70 -1.7831739 0.921 0.994 6.203205e-66
MT-CYB 3.381054e-67 -1.6618836 0.906 0.993 7.135038e-63
MT-CO1 3.307518e-64 -1.5518968 0.906 0.996 6.979856e-60
MT-ND3 3.844274e-64 -1.5954677 0.859 0.993 8.112571e-60
MT-ND4 9.223773e-62 -1.4133227 0.895 0.995 1.946493e-57
SNHG12 4.812971e-60 1.4208926 0.607 0.168 1.015681e-55
GADD45B 1.550028e-57 1.6002299 0.382 0.060 3.271025e-53
DDIT3 4.844988e-54 2.1528115 0.723 0.299 1.022438e-49
EIF1 7.314929e-54 1.3165931 0.995 1.000 1.543669e-49
MT-ND1 6.295736e-51 -1.1313272 0.853 0.990 1.328589e-46
SLC3A2 8.953602e-49 1.5061217 0.927 0.609 1.889479e-44
HSPA6 3.516092e-46 0.6778029 0.131 0.004 7.420010e-42
IGFBP2 1.542992e-42 -1.1962256 0.702 0.922 3.256176e-38
PPP1R15A 2.662413e-41 1.2090298 0.545 0.189 5.618490e-37
ATF4 4.877250e-41 1.0996582 0.848 0.544 1.029246e-36
MT-ND2 2.363002e-40 -0.9112057 0.916 0.993 4.986643e-36
ZFAND2A 7.961523e-40 0.8633638 0.482 0.142 1.680120e-35
SNHG1 1.601679e-39 1.3140208 0.874 0.612 3.380024e-35
Sat_D1_sub <- subset(Sat_D1, SCT_snn_res.0.8 == 5, invert=T)
Sat_D1_sub <- SCTransform(Sat_D1_sub, assay = 'RNA', new.assay.name = 'SCT', verbose = FALSE)
Sat_D1_sub <- RunPCA(Sat_D1_sub, features = VariableFeatures(Sat_D1_sub))
Sat_D1_sub <- RunUMAP(Sat_D1_sub, dims = 1:15)
DimPlot(Sat_D1_sub, label = T, group.by = "Phase") +
theme_tufte()
set.seed(42)
Sat_D1_sub <- FindNeighbors(Sat_D1_sub, dims=1:15, verbose = FALSE)
Sat_D1_sub <- FindClusters(Sat_D1_sub, resolution = 0.8, verbose = FALSE)
DimPlot(Sat_D1_sub, label = T, group.by = "SCT_snn_res.0.8", cols = autumn_palette) +
theme_tufte()
VlnPlot(Sat_D1_sub, c("nFeature_RNA", "nCount_RNA", "percent.mt", "percent.ribo"), cols = autumn_palette ,ncol = 2) &
theme_tufte() &
theme(legend.position="none")
# save cell barcodes to subset the aggregated dataset
write.csv(colnames(Sat_D1_sub), here("output", "CO_filtered_barcodes.csv"),
row.names = FALSE)
# save clusters
write.csv(Sat_D1_sub$SCT_snn_res.0.8, here("output", "CO_clusters_res08.csv"),
row.names = TRUE)
Sat_D1_sub$cc_difference <- Sat_D1_sub$S.Score - Sat_D1_sub$G2M.Score
Sat_D1_sub <- SCTransform(Sat_D1_sub, assay = 'RNA', new.assay.name = 'SCT', vars.to.regress = "cc_difference", verbose = FALSE)
Sat_D1_sub <- RunPCA(Sat_D1_sub, features = VariableFeatures(Sat_D1_sub))
Sat_D1_sub <- RunUMAP(Sat_D1_sub, dims = 1:15)
DimPlot(Sat_D1_sub, group.by = "Phase") +
theme_tufte()
set.seed(42)
Sat_D1_sub <- FindNeighbors(Sat_D1_sub, dims=1:15, verbose = FALSE)
Sat_D1_sub <- FindClusters(Sat_D1_sub, resolution = 0.8, verbose = FALSE)
Sat_D1_sub$annot <- as.character(Sat_D1_sub$SCT_snn_res.0.8)
DimPlot(Sat_D1_sub, label = F, group.by = "SCT_snn_res.0.8", cols = autumn_palette) +
theme_tufte()
VlnPlot(Sat_D1_sub, c("nFeature_RNA", "nCount_RNA", "percent.mt", "percent.ribo"), cols = autumn_palette ,ncol = 2) &
theme_tufte() &
theme(legend.position="none")
# save Sat_D1_sub for SingleR classification
#saveRDS(Sat_D1_sub, here("output", "Sat_D1_sub.rds"))
CO_markers <- SoupX::quickMarkers(Sat_D1_sub@assays$RNA@counts, Sat_D1_sub$SCT_snn_res.0.8, N = 6)
SCE_D1_sub <- as.SingleCellExperiment(Sat_D1_sub)
scater::plotExpression(SCE_D1_sub, features = unique(CO_markers$gene)[1:10], x = "SCT_snn_res.0.8", colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
scater::plotExpression(SCE_D1_sub, features = unique(CO_markers$gene)[11:20], x = "SCT_snn_res.0.8", colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
scater::plotExpression(SCE_D1_sub, features = unique(CO_markers$gene)[21:30], x = "SCT_snn_res.0.8",colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
scater::plotExpression(SCE_D1_sub, features = unique(CO_markers$gene)[31:33], x = "SCT_snn_res.0.8",colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
genes_to_plot <- c("MKI67", "SOX2", "SOX1", "PAX6", "NES", "DCX", "TUBB3", "MAP2",
"MAPT", "OLIG2", "PLP1", "S100B", "TMEM119", "RAX", "SIX3",
"GAD2","ASCL1", "NEUROD1", "NEUROD4", "NEUROG1", "EOMES", "APOE")
# not expressed in this dataset: "LY6H","PDGFR1", "NEUROG4"
for (i in genes_to_plot){
g <- Nebulosa::plot_density(Sat_D1_sub, features = i) +
theme_tufte() +
theme(legend.position="right", axis.ticks = element_blank())
print(g)
}
genes_to_plot <- c("HES1", "HES4", "HES5", "NOTCH1")
for (i in genes_to_plot){
g <- Nebulosa::plot_density(Sat_D1_sub, features = i) +
theme_tufte() +
theme(legend.position="right", axis.ticks = element_blank())
print(g)
}
#saveRDS(Sat_D1_sub, here("output", "Sat_D1_sub.rds"))
Sat_D1_sub_neuro <- subset(Sat_D1_sub, SCT_snn_res.0.8 %in% c(0,4,5,9,6,10), invert = TRUE)
#
tmp_umap <- Sat_D1_sub_neuro@reductions$umap@cell.embeddings
tmp_umap <- tmp_umap[tmp_umap[,1] < 0,]
Sat_D1_sub_neuro <- subset(Sat_D1_sub_neuro, cells = rownames(tmp_umap))
set.seed(42)
Sat_D1_sub_neuro <- FindNeighbors(Sat_D1_sub_neuro, dims=1:15, verbose = FALSE)
Sat_D1_sub_neuro <- FindClusters(Sat_D1_sub_neuro, resolution = 0.8, verbose = FALSE)
DimPlot(Sat_D1_sub_neuro, label = F, group.by = "SCT_snn_res.0.8", cols = autumn_palette) +
theme_tufte()
VlnPlot(Sat_D1_sub_neuro, c("nFeature_RNA", "nCount_RNA", "percent.mt", "percent.ribo"), ncol = 2, cols = autumn_palette) &
theme_tufte() &
theme(legend.position="none")
# save cell barcodes
write.csv(colnames(Sat_D1_sub_neuro), here("output", "CO_sub_neuro.csv"),
row.names = FALSE)
# save clusters
write.csv(Sat_D1_sub_neuro$SCT_snn_res.0.8, here("output", "CO_sub_neuro_res08.csv"),
row.names = TRUE)
# convert to h5ad for CellRank
# Sat_D1_sub_neuro <- RenameCells(Sat_D1_sub_neuro, new.names = paste("D1_", sub("-1", "", colnames(Sat_D1_sub_neuro)), sep=""))
# SaveH5Seurat(Sat_D1_sub_neuro, filename = here("output","Sat_D1_sub.h5Seurat"))
# Convert(here("output","Sat_D1_sub.h5Seurat"), dest="h5ad")
CO_sub_markers <- SoupX::quickMarkers(Sat_D1_sub_neuro@assays$RNA@counts, Sat_D1_sub_neuro$SCT_snn_res.0.8, N = 6)
SCE_D1_sub_neuro <- as.SingleCellExperiment(Sat_D1_sub_neuro)
scater::plotExpression(SCE_D1_sub_neuro, features = unique(CO_sub_markers$gene)[1:10], x = "SCT_snn_res.0.8", colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
scater::plotExpression(SCE_D1_sub_neuro, features = unique(CO_sub_markers$gene)[11:20], x = "SCT_snn_res.0.8", colour_by = "SCT_snn_res.0.8") +
scale_color_manual(values = autumn_palette)
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SeuratDisk_0.0.0.9019 ggthemes_4.2.4 ggplot2_3.3.5
[4] here_1.0.1 dplyr_1.0.7 SeuratObject_4.0.2
[7] Seurat_4.0.3.9011 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] utf8_1.2.1 ks_1.13.2
[3] reticulate_1.20 tidyselect_1.1.1
[5] htmlwidgets_1.5.3 grid_4.1.1
[7] BiocParallel_1.26.1 Rtsne_0.15
[9] munsell_0.5.0 ScaledMatrix_1.0.0
[11] codetools_0.2-18 ica_1.0-2
[13] future_1.21.0 miniUI_0.1.1.1
[15] withr_2.4.2 colorspace_2.0-2
[17] Biobase_2.52.0 highr_0.9
[19] knitr_1.33 stats4_4.1.1
[21] SingleCellExperiment_1.14.1 ROCR_1.0-11
[23] tensor_1.5 listenv_0.8.0
[25] MatrixGenerics_1.4.0 labeling_0.4.2
[27] git2r_0.28.0 GenomeInfoDbData_1.2.6
[29] polyclip_1.10-0 bit64_4.0.5
[31] farver_2.1.0 Nebulosa_1.2.0
[33] rprojroot_2.0.2 parallelly_1.26.1
[35] vctrs_0.3.8 generics_0.1.0
[37] xfun_0.24 R6_2.5.0
[39] GenomeInfoDb_1.28.1 ggbeeswarm_0.6.0
[41] rsvd_1.0.5 hdf5r_1.3.3
[43] bitops_1.0-7 spatstat.utils_2.2-0
[45] DelayedArray_0.18.0 assertthat_0.2.1
[47] promises_1.2.0.1 scales_1.1.1
[49] beeswarm_0.4.0 gtable_0.3.0
[51] beachmat_2.8.0 globals_0.14.0
[53] goftest_1.2-2 rlang_0.4.11
[55] splines_4.1.1 lazyeval_0.2.2
[57] spatstat.geom_2.2-2 yaml_2.2.1
[59] reshape2_1.4.4 abind_1.4-5
[61] httpuv_1.6.1 tools_4.1.1
[63] ellipsis_0.3.2 spatstat.core_2.3-0
[65] jquerylib_0.1.4 RColorBrewer_1.1-2
[67] BiocGenerics_0.38.0 ggridges_0.5.3
[69] Rcpp_1.0.6 plyr_1.8.6
[71] sparseMatrixStats_1.4.0 zlibbioc_1.38.0
[73] purrr_0.3.4 RCurl_1.98-1.3
[75] rpart_4.1-15 deldir_0.2-10
[77] pbapply_1.4-3 viridis_0.6.1
[79] cowplot_1.1.1 S4Vectors_0.30.0
[81] zoo_1.8-9 SummarizedExperiment_1.22.0
[83] ggrepel_0.9.1 cluster_2.1.2
[85] fs_1.5.0 magrittr_2.0.1
[87] data.table_1.14.0 RSpectra_0.16-0
[89] scattermore_0.7 lmtest_0.9-38
[91] RANN_2.6.1 mvtnorm_1.1-2
[93] fitdistrplus_1.1-5 matrixStats_0.59.0
[95] patchwork_1.1.1 mime_0.11
[97] evaluate_0.14 xtable_1.8-4
[99] mclust_5.4.7 IRanges_2.26.0
[101] gridExtra_2.3 compiler_4.1.1
[103] scater_1.20.1 tibble_3.1.2
[105] KernSmooth_2.23-20 crayon_1.4.1
[107] htmltools_0.5.1.1 mgcv_1.8-38
[109] later_1.2.0 tidyr_1.1.3
[111] SoupX_1.5.2 DBI_1.1.1
[113] MASS_7.3-54 Matrix_1.4-0
[115] cli_3.0.0 parallel_4.1.1
[117] igraph_1.2.6 GenomicRanges_1.44.0
[119] pkgconfig_2.0.3 plotly_4.9.4.1
[121] scuttle_1.2.0 spatstat.sparse_2.0-0
[123] vipor_0.4.5 bslib_0.2.5.1
[125] XVector_0.32.0 stringr_1.4.0
[127] digest_0.6.27 pracma_2.3.3
[129] sctransform_0.3.2 RcppAnnoy_0.0.18
[131] spatstat.data_2.1-0 rmarkdown_2.9
[133] leiden_0.3.8 uwot_0.1.10
[135] DelayedMatrixStats_1.14.0 shiny_1.6.0
[137] lifecycle_1.0.0 nlme_3.1-153
[139] jsonlite_1.7.2 BiocNeighbors_1.10.0
[141] viridisLite_0.4.0 limma_3.48.1
[143] fansi_0.5.0 pillar_1.6.1
[145] lattice_0.20-45 fastmap_1.1.0
[147] httr_1.4.2 survival_3.2-13
[149] glue_1.4.2 png_0.1-7
[151] bit_4.0.4 stringi_1.6.2
[153] sass_0.4.0 BiocSingular_1.8.1
[155] irlba_2.3.3 future.apply_1.7.0