Clustering
Resolution 0.4 UMAP
# Resolution and color palette
i=2
res= paste0("RNA_snn_res.", resolution_values[i])
palette <- wesanderson::wes_palette("FantasticFox1", length(levels(obj.srt@meta.data[,res])), type = "continuous")
DimPlot(obj.srt, group.by = res, cols = palette, alpha = 0.8) +
theme(plot.title = element_blank()) + xlab("UMAP1") + ylab("UMAP2")
Resolution 0.4 UMAP (label)
DimPlot(obj.srt, group.by = res, alpha = 0.8,
label = T, label.box = T, label.size = 3, cols = palette) + theme(plot.title = element_blank())
Cell numbers
obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=!!sym(res))) +
geom_bar(alpha=0.7, color="grey5", size=0.1) +
geom_text(stat="count", aes(label= ..count..), vjust=-0.5, size=3) +
scale_fill_manual(values=palette) +
xlab("") +
theme_classic() +
theme(legend.title = element_blank(),
axis.text.x = element_text(angle = 45, vjust=0.5)) +
ggtitle("Cluster")
Markers
Marker Table
mks %>% DT::datatable(width = "700px", extensions = "Buttons", options = list(dom="Bfrtip",buttons=c("csv","excel"), scrollX=TRUE), filter = "bottom")
Top marker table
df = mks %>% group_by(cluster) %>% top_n(50, avg_log2FC)
df2 = data.frame(matrix(nrow = length(unique(df$cluster)), ncol = 1))
rownames(df2) = unique(df$cluster)
colnames(df2) = "cluster"
df2$cluster = rownames(df2)
for(i in rownames(df2)){
tmp=df %>% filter(cluster== i) %>% top_n(20, avg_log2FC) %>% select(gene) %>% pull() %>% paste0(collapse = ", ")
df2[i,"top 20 genes"] = tmp
tmp=df %>% filter(cluster== i) %>% top_n(50, avg_log2FC) %>% select(gene) %>% pull() %>% paste0(collapse = ", ")
df2[i,"top 50 genes"] = tmp
}
df2 %>%
DT::datatable(extensions = "Buttons",
rownames = F,
width = "800px",
options = list(scrollX=TRUE,
dom="Bfrtip",
buttons=c("csv","excel")))
Top marker plot
top_genes = mks %>% group_by(cluster) %>% top_n(5, avg_log2FC) %>% select(gene) %>% pull() %>% unique()
DotPlot(obj.srt, features = top_genes, group.by = "RNA_snn_res.0.4", cols = c("grey88","red")) +theme_bw() +ylab("")+ xlab("") +RotatedAxis()
sessionInfo()
## R version 4.4.1 (2024-06-14)
## Platform: aarch64-apple-darwin20
## Running under: macOS Sonoma 14.6.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.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: America/Detroit
## tzcode source: internal
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] SeuratWrappers_0.4.0 SingleCellExperiment_1.26.0
## [3] SummarizedExperiment_1.34.0 Biobase_2.64.0
## [5] GenomicRanges_1.56.1 GenomeInfoDb_1.40.1
## [7] IRanges_2.38.1 S4Vectors_0.42.1
## [9] BiocGenerics_0.50.0 MatrixGenerics_1.16.0
## [11] matrixStats_1.4.1 scCustomize_2.1.2
## [13] Seurat_5.1.0 SeuratObject_5.0.2
## [15] sp_2.1-4 dplyr_1.1.4
## [17] ggrepel_0.9.6 ggplot2_3.5.1
##
## loaded via a namespace (and not attached):
## [1] RcppAnnoy_0.0.22 splines_4.4.1 later_1.4.1
## [4] tibble_3.2.1 R.oo_1.27.0 polyclip_1.10-7
## [7] janitor_2.2.0 fastDummies_1.7.4 lifecycle_1.0.4
## [10] globals_0.16.3 lattice_0.22-6 MASS_7.3-60.2
## [13] crosstalk_1.2.1 magrittr_2.0.3 plotly_4.10.4
## [16] sass_0.4.9 rmarkdown_2.29 wesanderson_0.3.7
## [19] jquerylib_0.1.4 yaml_2.3.10 remotes_2.5.0
## [22] httpuv_1.6.15 sctransform_0.4.1 spam_2.11-0
## [25] spatstat.sparse_3.1-0 reticulate_1.40.0 cowplot_1.1.3
## [28] pbapply_1.7-2 RColorBrewer_1.1-3 lubridate_1.9.3
## [31] abind_1.4-8 zlibbioc_1.50.0 Rtsne_0.17
## [34] purrr_1.0.2 R.utils_2.12.3 circlize_0.4.16
## [37] GenomeInfoDbData_1.2.12 irlba_2.3.5.1 listenv_0.9.1
## [40] spatstat.utils_3.1-1 goftest_1.2-3 RSpectra_0.16-2
## [43] spatstat.random_3.3-2 fitdistrplus_1.2-1 parallelly_1.39.0
## [46] leiden_0.4.3.1 codetools_0.2-20 DelayedArray_0.30.1
## [49] DT_0.33 tidyselect_1.2.1 shape_1.4.6.1
## [52] UCSC.utils_1.0.0 farver_2.1.2 spatstat.explore_3.3-3
## [55] jsonlite_1.8.9 progressr_0.15.1 ggridges_0.5.6
## [58] survival_3.6-4 tools_4.4.1 ica_1.0-3
## [61] Rcpp_1.0.13-1 glue_1.8.0 gridExtra_2.3
## [64] SparseArray_1.4.8 xfun_0.49 withr_3.0.2
## [67] BiocManager_1.30.25 fastmap_1.2.0 fansi_1.0.6
## [70] rsvd_1.0.5 digest_0.6.37 timechange_0.3.0
## [73] R6_2.5.1 mime_0.12 ggprism_1.0.5
## [76] colorspace_2.1-1 scattermore_1.2 tensor_1.5
## [79] spatstat.data_3.1-4 R.methodsS3_1.8.2 utf8_1.2.4
## [82] tidyr_1.3.1 generics_0.1.3 data.table_1.16.2
## [85] httr_1.4.7 htmlwidgets_1.6.4 S4Arrays_1.4.1
## [88] uwot_0.2.2 pkgconfig_2.0.3 gtable_0.3.6
## [91] lmtest_0.9-40 XVector_0.44.0 htmltools_0.5.8.1
## [94] dotCall64_1.2 scales_1.3.0 png_0.1-8
## [97] spatstat.univar_3.1-1 snakecase_0.11.1 knitr_1.49
## [100] rstudioapi_0.16.0 reshape2_1.4.4 nlme_3.1-164
## [103] cachem_1.1.0 zoo_1.8-12 GlobalOptions_0.1.2
## [106] stringr_1.5.1 KernSmooth_2.23-24 parallel_4.4.1
## [109] miniUI_0.1.1.1 vipor_0.4.7 ggrastr_1.0.2
## [112] pillar_1.9.0 grid_4.4.1 vctrs_0.6.5
## [115] RANN_2.6.2 promises_1.3.2 xtable_1.8-4
## [118] cluster_2.1.6 beeswarm_0.4.0 paletteer_1.6.0
## [121] evaluate_1.0.1 cli_3.6.3 compiler_4.4.1
## [124] rlang_1.1.4 crayon_1.5.3 future.apply_1.11.3
## [127] labeling_0.4.3 rematch2_2.1.2 plyr_1.8.9
## [130] forcats_1.0.0 ggbeeswarm_0.7.2 stringi_1.8.4
## [133] viridisLite_0.4.2 deldir_2.0-4 munsell_0.5.1
## [136] lazyeval_0.2.2 spatstat.geom_3.3-4 Matrix_1.7-0
## [139] RcppHNSW_0.6.0 patchwork_1.3.0 future_1.34.0
## [142] shiny_1.9.1 ROCR_1.0-11 igraph_2.1.1
## [145] bslib_0.8.0