Generation of SPRING coordinates for an object previously generated containing WT and Gmnc KO cells from P0.
library(Seurat)
library(cowplot)
library(dplyr)
library(ggplot2)
library(ggExtra)
library(ggrepel)
library(reticulate)
library(Matrix)
library(viridis)
library(RColorBrewer)
library(MetBrewer)
library(wesanderson)
library(R.utils)
# Set ggplot theme as classic
theme_set(theme_classic())
<- readRDS("Gmnc.combined.RDS")
Gmnc.combined
DimPlot(Gmnc.combined, reduction = "umap", label = T, label.size = 4, pt.size = 0.1, group.by = "seurat_clusters", cols = met.brewer("Klimt", 23)) + NoAxes()
<- as.matrix(GetAssayData(Gmnc.combined))
ExprsMatrix <- Matrix(ExprsMatrix, sparse = TRUE)
exprData writeMM(exprData, "Spring_files/ExprData.mtx")
## NULL
gzip("Spring_files/ExprData.mtx", overwrite=T)
<- row.names(ExprsMatrix)
Genelist write.table(Genelist, "Spring_files/Genelist.csv", sep="\t", col.names = F, row.names = F)
rm(ExprsMatrix, exprData, Genelist)
<- c("S.Score",Gmnc.combined$S.Score)
S.Score <- paste(S.Score, sep=",", collapse=",")
S.Score <- c("G2M.Score",Gmnc.combined$G2M.Score)
G2M.Score <- paste(G2M.Score, sep=",", collapse=",")
G2M.Score <- c("Percent.mt", Gmnc.combined$percent.mt)
Percent.mt <- paste(Percent.mt, sep = ",", collapse = ",")
Percent.mt <- c("Percent.rb", Gmnc.combined$percent.rb)
Percent.rb <- paste(Percent.rb, sep = ",", collapse = ",")
Percent.rb <- c("nCount", Gmnc.combined$nCount_RNA)
nCount <- paste(nCount, sep = ",", collapse = ",")
nCount <- c("nFeature", Gmnc.combined$nFeature_RNA)
nFeature <- paste(nFeature, sep = ",", collapse = ",")
nFeature
<- rbind(S.Score, G2M.Score, Percent.mt, Percent.rb, nCount, nFeature)
ColorTrack write.table(ColorTrack, "Spring_files/ColorTrack.csv", quote =F, row.names = F, col.names = F)
rm(S.Score, G2M.Score, Percent.mt, Percent.rb, nCount, nFeature, ColorTrack)
<- c("Seurat Clusters", paste0("Cluster",as.character(Gmnc.combined$seurat_clusters)))
Seurat.clusters <- paste(Seurat.clusters, sep=",", collapse=",")
Seurat.clusters <- c("Phase", Gmnc.combined$Phase)
Phase <- paste(Phase, sep=",", collapse=",")
Phase <- c("orig.ident", Gmnc.combined$orig.ident)
orig.ident <- paste(orig.ident, sep = ",", collapse = ",")
orig.ident <- rbind(Seurat.clusters, Phase, orig.ident)
Cellgrouping write.table(Cellgrouping, "Spring_files/Cellgrouping.csv", quote =F, row.names = F, col.names = F)
rm(Cellgrouping, Seurat.clusters, Phase, orig.ident)
<- cbind(c(0:dim(Gmnc.combined)[2]-1),Gmnc.combined@reductions[["umap"]]@cell.embeddings)
Coordinates
# Symmetry transform of the coordinates
<- function(x){
Spring.Sym = abs(max(Coordinates[,3])-x)
x
}
3] <- sapply(Coordinates[,3] , function(x) Spring.Sym(x))
Coordinates[,
# Change x and y axis values for a better display in SPRING
<- Coordinates * 100
Coordinates
write.table(Coordinates, "Spring_files/umap.txt", quote =F, row.names = F, col.names = F, sep = ",")
rm(Coordinates)
ExprData.mtx, Genelist.csv, ColorTrack.csv, Cellgrouping.csv and umap.txt are then used as input for the Spring App
A doublet score is calculated using the SPRING app built-in function (based on scrublet) using default parameters (k=50, r=2, f=0.1)
<- read.table("Spring_files/doublet_results.tsv", header = T)
doublet.score <- filter(doublet.score, Observed_or_Simulated == "Observed")
doublet.score $doublet.score <-doublet.score$Score
Gmnc.combined
FeaturePlot(object = Gmnc.combined,
features = "doublet.score",
reduction = "umap",
pt.size = 0.4) + scale_color_gradientn(colors= c("grey90", brewer.pal(9,"RdPu"))) + NoAxes()
ggplot(doublet.score, aes(x = Score, stat(ndensity))) +
geom_histogram(bins = 200, colour ="lightgrey")+
geom_vline(xintercept = 0.25, colour = "red", linetype = 2)
rm(doublet.score)
Cell coordinates of the Spring dimensionality reduction are generated using the following parameters (excluding cells with a doublet score >0.25): Min expressing cells (gene filtering): 3 Min number of UMIs (gene filtering): 3 Gene variability %ile (gene filtering): 90 Number of principal components: 20 Number of nearest neighbors: 8 Number of force layout iterations: 500
<- function(x){x = abs(max(Coordinates[,2])-x)} # Symmetry transform of the coordinates
Spring.Sym
<- read.table("Spring_files/coordinates.txt", sep = ",", header = F)[,c(2,3)]
Coordinates <- subset(Gmnc.combined, doublet.score < 0.25)
Gmnc.cleanup rownames(Coordinates) <- colnames(Gmnc.cleanup)
colnames(Coordinates) <- paste0("Spring_", 1:2)
2] <- sapply(Coordinates[,2] , function(x) Spring.Sym(x))
Coordinates[,"Spring"]] <- CreateDimReducObject(embeddings = as.matrix(Coordinates), key = "Spring_")
Gmnc.cleanup[[
rm(Coordinates)
# Spring visualization
DimPlot(Gmnc.cleanup, reduction = "Spring", pt.size = 0.2, label = T, label.size = 3, cols = met.brewer("Klimt", 23)) + NoAxes() + NoLegend()
DimPlot(Gmnc.cleanup, reduction = "Spring", pt.size = 0.2, label = F, group.by = "orig.ident", cols = met.brewer("Egypt", 2)) + NoAxes()
saveRDS(Gmnc.cleanup, "Gmnc.cleanup.RDS")
#date
format(Sys.time(), "%d %B, %Y, %:%M")
## [1] "09 January, 2024, %:44"
#Packages used
sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-conda-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
##
## Matrix products: default
## BLAS/LAPACK: /shared/ifbstor1/software/miniconda/envs/r-4.1.1/lib/libopenblasp-r0.3.18.so
##
## 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] R.utils_2.11.0 R.oo_1.24.0 R.methodsS3_1.8.1 wesanderson_0.3.6
## [5] MetBrewer_0.2.0 RColorBrewer_1.1-3 viridis_0.6.2 viridisLite_0.4.1
## [9] Matrix_1.6-4 reticulate_1.24 ggrepel_0.9.1 ggExtra_0.9
## [13] ggplot2_3.3.6 dplyr_1.0.10 cowplot_1.1.1 Seurat_5.0.1
## [17] SeuratObject_5.0.1 sp_2.1-2
##
## loaded via a namespace (and not attached):
## [1] Rtsne_0.16 colorspace_2.0-3 deldir_1.0-6
## [4] ellipsis_0.3.2 ggridges_0.5.3 RcppHNSW_0.3.0
## [7] spatstat.data_3.0-3 rstudioapi_0.13 farver_2.1.1
## [10] leiden_0.3.10 listenv_0.8.0 RSpectra_0.16-1
## [13] fansi_1.0.3 codetools_0.2-18 splines_4.1.1
## [16] knitr_1.40 polyclip_1.10-0 spam_2.7-0
## [19] jsonlite_1.8.2 ica_1.0-2 cluster_2.1.2
## [22] png_0.1-7 uwot_0.1.11 spatstat.sparse_3.0-3
## [25] shiny_1.7.1 sctransform_0.4.1 compiler_4.1.1
## [28] httr_1.4.4 assertthat_0.2.1 fastmap_1.1.0
## [31] lazyeval_0.2.2 cli_3.4.1 later_1.3.0
## [34] htmltools_0.5.2 tools_4.1.1 igraph_1.3.1
## [37] dotCall64_1.0-1 gtable_0.3.1 glue_1.6.2
## [40] RANN_2.6.1 reshape2_1.4.4 Rcpp_1.0.9
## [43] scattermore_1.2 jquerylib_0.1.4 vctrs_0.4.2
## [46] nlme_3.1-153 spatstat.explore_3.2-5 progressr_0.10.0
## [49] lmtest_0.9-40 spatstat.random_3.2-2 xfun_0.34
## [52] stringr_1.4.1 globals_0.14.0 mime_0.12
## [55] miniUI_0.1.1.1 lifecycle_1.0.3 irlba_2.3.5.1
## [58] goftest_1.2-3 future_1.25.0 MASS_7.3-54
## [61] zoo_1.8-10 scales_1.2.1 spatstat.utils_3.0-4
## [64] promises_1.2.0.1 parallel_4.1.1 yaml_2.3.6
## [67] pbapply_1.5-0 gridExtra_2.3 sass_0.4.1
## [70] stringi_1.7.8 highr_0.9 fastDummies_1.7.3
## [73] rlang_1.0.6 pkgconfig_2.0.3 matrixStats_0.62.0
## [76] evaluate_0.17 lattice_0.20-45 tensor_1.5
## [79] ROCR_1.0-11 purrr_0.3.5 labeling_0.4.2
## [82] patchwork_1.1.1 htmlwidgets_1.5.4 tidyselect_1.2.0
## [85] parallelly_1.31.1 RcppAnnoy_0.0.19 plyr_1.8.7
## [88] magrittr_2.0.3 R6_2.5.1 generics_0.1.3
## [91] DBI_1.1.2 withr_2.5.0 pillar_1.8.1
## [94] fitdistrplus_1.1-8 abind_1.4-5 survival_3.2-13
## [97] tibble_3.1.8 future.apply_1.9.0 crayon_1.5.2
## [100] KernSmooth_2.23-20 utf8_1.2.2 spatstat.geom_3.2-7
## [103] plotly_4.10.0 rmarkdown_2.11 grid_4.1.1
## [106] data.table_1.14.2 digest_0.6.30 xtable_1.8-4
## [109] tidyr_1.2.1 httpuv_1.6.5 munsell_0.5.0
## [112] bslib_0.3.1
IPNP & Imagine Institute, Paris, France, frederic.causeret@inserm.fr↩︎