library(Seurat)
## Attaching SeuratObject
library(SeuratData)
## ── Installed datasets ───────────────────────────────────── SeuratData v0.2.2 ──
## ✓ ifnb 3.1.0 ✓ pbmcsca 3.0.0
## ✓ panc8 3.0.2
## ────────────────────────────────────── Key ─────────────────────────────────────
## ✓ Dataset loaded successfully
## > Dataset built with a newer version of Seurat than installed
## ❓ Unknown version of Seurat installed
library(SeuratWrappers)
library(Rmagic)
## Loading required package: Matrix
library(ggplot2)
library(viridis)
## Loading required package: viridisLite
library(phateR)
##
## Attaching package: 'phateR'
## The following object is masked from 'package:Rmagic':
##
## library.size.normalize
library(devtools)
## Loading required package: usethis
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(cowplot)
The first step is converting seurat to “data.frame” data
pbmc <- readRDS("/mnt/nectar_volume/home/eraz0001/KELLY 2020/E11.5/Final_15_clusters.RDS")
pbmc
## An object of class Seurat
## 16968 features across 2333 samples within 1 assay
## Active assay: RNA (16968 features, 2000 variable features)
## 2 dimensional reductions calculated: pca, umap
counts.df <- pbmc@assays$RNA@counts %>% as.matrix %>% t %>% as.data.frame
analysing with Rmagic. I also selected three candiodate genes, here.
data_magic <- magic(counts.df, genes=c("Col2a1", "Hes1", "Sox9"))
data_magic
## MAGIC with elements
## $result : (2333, 3)
## $operator : Python MAGIC operator
## $params : list with elements (data, knn, knn.max, decay, t, npca, knn.dist.method)
x <- ggplot(counts.df) + geom_point(aes(Col2a1, Hes1, color=Sox9)) + scale_color_viridis(option="C") + xlab("Gene Expression of Col2a1") + ylab("Gene Expression of Hes1")+theme(text = element_text(size = 14, angle = 0, face = "italic"))
x
z <- ggplot(data_magic) + geom_point(aes(Col2a1, Hes1, color=Sox9)) + scale_color_viridis(option="C") + xlab("Gene Expression of Col2a1") + ylab("Gene Expression of Hes1")+theme(text = element_text(size = 14, angle = 0, face = "italic"))
z
what if we change t value here?
magic1 <- magic(counts.df, genes=c("Col2a1", "Hes1","Sox9"), t=6)
y <- ggplot(magic1) + geom_point(aes(Col2a1, Hes1, color=Sox9)) + scale_color_viridis(option="C") + xlab("Gene Expression of Col2a1") + ylab("Gene Expression of Hes1")+theme(text = element_text(size = 14, angle = 0, face = "italic"))
y
magic1 <- magic(counts.df, genes=c("Col2a1", "Hes1","Sox9"), t=8)
r <- ggplot(magic1) + geom_point(aes(Col2a1, Hes1, color=Sox9)) + scale_color_viridis(option="C") + xlab("Gene Expression of Col2a1") + ylab("Gene Expression of Hes1")+theme(text = element_text(size = 14, angle = 0, face = "italic"))
r
Visualizing MAGIC values on PCA We can visualize the results of MAGIC on
PCA with genes=“pca_only”.
magic_PCA <- magic(counts.df, genes= "pca_only", t=6)
a <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Sox9)) + scale_color_viridis(option="B") + labs(color="Sox9")
b <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Col2a1)) + scale_color_viridis(option="B") + labs(color="Col2a1")
c <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Hes1)) + scale_color_viridis(option="B") + labs(color="Hes1")
d <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Grem1)) + scale_color_viridis(option="B") + labs(color="Grem1")
e <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Nes)) + scale_color_viridis(option="B") + labs(color="Nes")
f <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Foxa1)) + scale_color_viridis(option="B") + labs(color="Foxa1")
g <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Lepr)) + scale_color_viridis(option="B") + labs(color="Lepr")
h <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Pdgfra)) + scale_color_viridis(option="B") + labs(color="Pdgfra")
i <- ggplot(magic_PCA) + geom_point(aes(x=PC1, y=PC2, color= counts.df$Pdgfrb)) + scale_color_viridis(option="B") + labs(color="Pdgfrb")
plot_grid(a, b, c, d, e, f, g, h, i)
session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
## setting value
## version R version 4.0.2 (2020-06-22)
## os Ubuntu 20.04.4 LTS
## system x86_64, linux-gnu
## ui X11
## language (EN)
## collate en_AU.UTF-8
## ctype en_AU.UTF-8
## tz Australia/Melbourne
## date 2022-06-16
## pandoc 2.17.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/ (via rmarkdown)
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date (UTC) lib source
## abind 1.4-5 2016-07-21 [1] CRAN (R 4.0.2)
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
## BiocManager 1.30.16 2021-06-15 [1] CRAN (R 4.0.2)
## brio 1.1.3 2021-11-30 [1] CRAN (R 4.0.2)
## bslib 0.3.1 2021-10-06 [1] CRAN (R 4.0.2)
## cachem 1.0.6 2021-08-19 [1] CRAN (R 4.0.2)
## callr 3.7.0 2021-04-20 [1] CRAN (R 4.0.2)
## cli 3.2.0 2022-02-14 [1] CRAN (R 4.0.2)
## cluster 2.1.3 2022-03-28 [1] CRAN (R 4.0.2)
## codetools 0.2-16 2018-12-24 [2] CRAN (R 4.0.2)
## colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.0.2)
## cowplot * 1.1.1 2020-12-30 [1] CRAN (R 4.0.2)
## crayon 1.4.2 2021-10-29 [1] CRAN (R 4.0.2)
## data.table 1.14.2 2021-09-27 [1] CRAN (R 4.0.2)
## DBI 1.1.2 2021-12-20 [1] CRAN (R 4.0.2)
## deldir 1.0-6 2021-10-23 [1] CRAN (R 4.0.2)
## desc 1.4.0 2021-09-28 [1] CRAN (R 4.0.2)
## devtools * 2.4.3 2021-11-30 [1] CRAN (R 4.0.2)
## digest 0.6.29 2021-12-01 [1] CRAN (R 4.0.2)
## dplyr * 1.0.8 2022-02-08 [1] CRAN (R 4.0.2)
## ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.2)
## evaluate 0.15 2022-02-18 [1] CRAN (R 4.0.2)
## fansi 1.0.2 2022-01-14 [1] CRAN (R 4.0.2)
## farver 2.1.0 2021-02-28 [1] CRAN (R 4.0.2)
## fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.2)
## fitdistrplus 1.1-6 2021-09-28 [1] CRAN (R 4.0.2)
## fs 1.5.2 2021-12-08 [1] CRAN (R 4.0.2)
## future 1.23.0 2021-10-31 [1] CRAN (R 4.0.2)
## future.apply 1.8.1 2021-08-10 [1] CRAN (R 4.0.2)
## generics 0.1.2 2022-01-31 [1] CRAN (R 4.0.2)
## ggplot2 * 3.3.6 2022-05-03 [1] CRAN (R 4.0.2)
## ggrepel 0.9.1 2021-01-15 [1] CRAN (R 4.0.2)
## ggridges 0.5.3 2021-01-08 [1] CRAN (R 4.0.2)
## globals 0.14.0 2020-11-22 [1] CRAN (R 4.0.2)
## glue 1.6.1 2022-01-22 [1] CRAN (R 4.0.2)
## goftest 1.2-3 2021-10-07 [1] CRAN (R 4.0.2)
## gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.2)
## gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2)
## highr 0.9 2021-04-16 [1] CRAN (R 4.0.2)
## htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.0.2)
## htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.0.2)
## httpuv 1.6.5 2022-01-05 [1] CRAN (R 4.0.2)
## httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.2)
## ica 1.0-2 2018-05-24 [1] CRAN (R 4.0.2)
## ifnb.SeuratData * 3.1.0 2022-05-04 [1] local
## igraph 1.2.11 2022-01-04 [1] CRAN (R 4.0.2)
## irlba 2.3.5 2021-12-06 [1] CRAN (R 4.0.2)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.0.2)
## jsonlite 1.7.3 2022-01-17 [1] CRAN (R 4.0.2)
## KernSmooth 2.23-17 2020-04-26 [2] CRAN (R 4.0.2)
## knitr 1.39 2022-04-26 [1] CRAN (R 4.0.2)
## labeling 0.4.2 2020-10-20 [1] CRAN (R 4.0.2)
## later 1.3.0 2021-08-18 [1] CRAN (R 4.0.2)
## lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.2)
## lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.0.2)
## leiden 0.3.9 2021-07-27 [1] CRAN (R 4.0.2)
## lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.0.2)
## listenv 0.8.0 2019-12-05 [1] CRAN (R 4.0.2)
## lmtest 0.9-39 2021-11-07 [1] CRAN (R 4.0.2)
## magrittr 2.0.2 2022-01-26 [1] CRAN (R 4.0.2)
## MASS 7.3-51.6 2020-04-26 [2] CRAN (R 4.0.2)
## Matrix * 1.4-0 2021-12-08 [1] CRAN (R 4.0.2)
## matrixStats 0.61.0 2021-09-17 [1] CRAN (R 4.0.2)
## memoise 2.0.1 2021-11-26 [1] CRAN (R 4.0.2)
## mgcv 1.8-31 2019-11-09 [2] CRAN (R 4.0.2)
## mime 0.12 2021-09-28 [1] CRAN (R 4.0.2)
## miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.0.2)
## munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2)
## nlme 3.1-148 2020-05-24 [2] CRAN (R 4.0.2)
## panc8.SeuratData * 3.0.2 2022-05-04 [1] local
## parallelly 1.30.0 2021-12-17 [1] CRAN (R 4.0.2)
## patchwork 1.1.1 2020-12-17 [1] CRAN (R 4.0.2)
## pbapply 1.5-0 2021-09-16 [1] CRAN (R 4.0.2)
## pbmcsca.SeuratData * 3.0.0 2022-05-04 [1] local
## phateR * 1.0.7 2021-02-12 [1] CRAN (R 4.0.2)
## pillar 1.7.0 2022-02-01 [1] CRAN (R 4.0.2)
## pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.0.2)
## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
## pkgload 1.2.4 2021-11-30 [1] CRAN (R 4.0.2)
## plotly 4.10.0 2021-10-09 [1] CRAN (R 4.0.2)
## plyr 1.8.6 2020-03-03 [1] CRAN (R 4.0.2)
## png 0.1-7 2013-12-03 [1] CRAN (R 4.0.2)
## polyclip 1.10-0 2019-03-14 [1] CRAN (R 4.0.2)
## prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
## processx 3.5.2 2021-04-30 [1] CRAN (R 4.0.2)
## promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.0.2)
## ps 1.6.0 2021-02-28 [1] CRAN (R 4.0.2)
## purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.2)
## R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.0.2)
## R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.0.2)
## R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.0.2)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.0.2)
## RANN 2.6.1 2019-01-08 [1] CRAN (R 4.0.2)
## rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.0.2)
## RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.2)
## Rcpp 1.0.8 2022-01-13 [1] CRAN (R 4.0.2)
## RcppAnnoy 0.0.19 2021-07-30 [1] CRAN (R 4.0.2)
## remotes 2.4.2 2021-11-30 [1] CRAN (R 4.0.2)
## reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.0.2)
## reticulate 1.24 2022-01-26 [1] CRAN (R 4.0.2)
## rlang 1.0.2 2022-03-04 [1] CRAN (R 4.0.2)
## Rmagic * 2.0.3 2019-11-21 [1] CRAN (R 4.0.2)
## rmarkdown 2.14 2022-04-25 [1] CRAN (R 4.0.2)
## ROCR 1.0-11 2020-05-02 [1] CRAN (R 4.0.2)
## rpart 4.1-15 2019-04-12 [2] CRAN (R 4.0.2)
## rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.2)
## rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.2)
## rsvd 1.0.5 2021-04-16 [1] CRAN (R 4.0.2)
## Rtsne 0.15 2018-11-10 [1] CRAN (R 4.0.2)
## sass 0.4.0 2021-05-12 [1] CRAN (R 4.0.2)
## scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
## scattermore 0.7 2020-11-24 [1] CRAN (R 4.0.2)
## sctransform 0.3.3 2022-01-13 [1] CRAN (R 4.0.2)
## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.0.2)
## Seurat * 4.1.0 2022-01-14 [1] CRAN (R 4.0.2)
## SeuratData * 0.2.2 2022-05-04 [1] Github (satijalab/seurat-data@d6a8ce6)
## SeuratObject * 4.0.4 2021-11-23 [1] CRAN (R 4.0.2)
## SeuratWrappers * 0.3.0 2022-02-02 [1] Github (satijalab/seurat-wrappers@8510069)
## shiny 1.7.1 2021-10-02 [1] CRAN (R 4.0.2)
## spatstat.core 2.3-2 2021-11-26 [1] CRAN (R 4.0.2)
## spatstat.data 2.1-2 2021-12-17 [1] CRAN (R 4.0.2)
## spatstat.geom 2.3-1 2021-12-10 [1] CRAN (R 4.0.2)
## spatstat.sparse 2.1-0 2021-12-17 [1] CRAN (R 4.0.2)
## spatstat.utils 2.3-0 2021-12-12 [1] CRAN (R 4.0.2)
## stringi 1.7.6 2021-11-29 [1] CRAN (R 4.0.2)
## stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2)
## survival 3.1-12 2020-04-10 [2] CRAN (R 4.0.2)
## tensor 1.5 2012-05-05 [1] CRAN (R 4.0.2)
## testthat 3.1.2 2022-01-20 [1] CRAN (R 4.0.2)
## tibble 3.1.6 2021-11-07 [1] CRAN (R 4.0.2)
## tidyr 1.2.0 2022-02-01 [1] CRAN (R 4.0.2)
## tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.0.2)
## usethis * 2.1.5 2021-12-09 [1] CRAN (R 4.0.2)
## utf8 1.2.2 2021-07-24 [1] CRAN (R 4.0.2)
## uwot 0.1.11 2021-12-02 [1] CRAN (R 4.0.2)
## vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.2)
## viridis * 0.6.2 2021-10-13 [1] CRAN (R 4.0.2)
## viridisLite * 0.4.0 2021-04-13 [1] CRAN (R 4.0.2)
## withr 2.4.3 2021-11-30 [1] CRAN (R 4.0.2)
## xfun 0.30 2022-03-02 [1] CRAN (R 4.0.2)
## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.2)
## yaml 2.2.2 2022-01-25 [1] CRAN (R 4.0.2)
## zoo 1.8-9 2021-03-09 [1] CRAN (R 4.0.2)
##
## [1] /mnt/nectar_volume/home/eraz0001/R/x86_64-pc-linux-gnu-library/4.0
## [2] /mnt/nectar_volume/software/apps/R/4.0.2/lib/R/library
##
## ─ Python configuration ───────────────────────────────────────────────────────
## python: /usr/bin/python3.8
## libpython: /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so
## pythonhome: //usr://usr
## version: 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
## numpy: /mnt/nectar_volume/home/eraz0001/.local/lib/python3.8/site-packages/numpy
## numpy_version: 1.22.2
## magic: /home/eraz0001/.local/lib/python3.8/site-packages/magic
##
## NOTE: Python version was forced by RETICULATE_PYTHON
##
## ──────────────────────────────────────────────────────────────────────────────