#Loading the Data
library(Seurat)
## Attaching SeuratObject
library(sctransform)
library(MAST)
## Loading required package: SingleCellExperiment
## Loading required package: SummarizedExperiment
## Loading required package: MatrixGenerics
## Loading required package: matrixStats
##
## Attaching package: 'MatrixGenerics'
## The following objects are masked from 'package:matrixStats':
##
## colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
## colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
## colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
## colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
## colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
## colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
## colWeightedMeans, colWeightedMedians, colWeightedSds,
## colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
## rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
## rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
## rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
## rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
## rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
## rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
## rowWeightedSds, rowWeightedVars
## Loading required package: GenomicRanges
## Loading required package: stats4
## Loading required package: BiocGenerics
##
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## anyDuplicated, aperm, append, as.data.frame, basename, cbind,
## colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
## get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
## match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
## Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort,
## table, tapply, union, unique, unsplit, which.max, which.min
## Loading required package: S4Vectors
##
## Attaching package: 'S4Vectors'
## The following objects are masked from 'package:base':
##
## expand.grid, I, unname
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: Biobase
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
##
## Attaching package: 'Biobase'
## The following object is masked from 'package:MatrixGenerics':
##
## rowMedians
## The following objects are masked from 'package:matrixStats':
##
## anyMissing, rowMedians
##
## Attaching package: 'SummarizedExperiment'
## The following object is masked from 'package:SeuratObject':
##
## Assays
## The following object is masked from 'package:Seurat':
##
## Assays
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.2 ✔ purrr 1.0.1
## ✔ tibble 3.2.1 ✔ dplyr 1.1.2
## ✔ tidyr 1.3.0 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::collapse() masks IRanges::collapse()
## ✖ dplyr::combine() masks Biobase::combine(), BiocGenerics::combine()
## ✖ dplyr::count() masks matrixStats::count()
## ✖ dplyr::desc() masks IRanges::desc()
## ✖ tidyr::expand() masks S4Vectors::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::first() masks S4Vectors::first()
## ✖ dplyr::lag() masks stats::lag()
## ✖ ggplot2::Position() masks BiocGenerics::Position(), base::Position()
## ✖ purrr::reduce() masks GenomicRanges::reduce(), IRanges::reduce()
## ✖ dplyr::rename() masks S4Vectors::rename()
## ✖ dplyr::slice() masks IRanges::slice()
library(rcna)
library(openxlsx)
library(HGNChelper)
library(harmony)
## Loading required package: Rcpp
library(glmGamPoi)
##
## Attaching package: 'glmGamPoi'
##
## The following object is masked from 'package:dplyr':
##
## vars
##
## The following object is masked from 'package:ggplot2':
##
## vars
library(reshape2)
##
## Attaching package: 'reshape2'
##
## The following object is masked from 'package:tidyr':
##
## smiths
library(dplyr)
library(ggrepel)
options(ggrepel.max.overlaps = Inf)
library(cowplot)
theme_set(theme_cowplot())
theme(plot.title = element_text(hjust = 0.5,face = "plain"))
## List of 1
## $ plot.title:List of 11
## ..$ family : NULL
## ..$ face : chr "plain"
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0.5
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi FALSE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi FALSE
## - attr(*, "validate")= logi TRUE
library(forcats)
setwd('/hpc/group/patellab/aam131/UW44SliceCultureNew/UW44scx')
slice = readRDS("annotatedUW44Data.RDS")
slice$Time <- factor(slice$Time, levels = c("D0", "D2", "D4","D5","D7","D10","D12","D14","D16"))
new.cluster.ids <- c("Tumor","Tumor","Tumor", "Radial Glial Cells","Tumor", "Microglia","Oligodendrocytes","Microglia", "Neuroepithelial Cells","Astrocytes","Oligodendrocytes","Pericytes","Microglia","Endothelial Cells","Neurons","Astrocytes","Neurons")
names(new.cluster.ids) <- levels(slice)
slice <- RenameIdents(slice, new.cluster.ids)
slice$AnnotedClustedShallow <- Idents(slice)
Idents(slice)<-'Time'
slice7and10<-subset(slice, idents=c('D7','D10'))
#Loading Data Packages and Preparing Data for Single Cell
library(ComplexHeatmap)
## Loading required package: grid
## ========================================
## ComplexHeatmap version 2.14.0
## Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
## Github page: https://github.com/jokergoo/ComplexHeatmap
## Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
##
## If you use it in published research, please cite either one:
## - Gu, Z. Complex Heatmap Visualization. iMeta 2022.
## - Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional
## genomic data. Bioinformatics 2016.
##
##
## The new InteractiveComplexHeatmap package can directly export static
## complex heatmaps into an interactive Shiny app with zero effort. Have a try!
##
## This message can be suppressed by:
## suppressPackageStartupMessages(library(ComplexHeatmap))
## ========================================
library(CellChat)
## Loading required package: igraph
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:dplyr':
##
## as_data_frame, groups, union
## The following objects are masked from 'package:purrr':
##
## compose, simplify
## The following object is masked from 'package:tidyr':
##
## crossing
## The following object is masked from 'package:tibble':
##
## as_data_frame
## The following object is masked from 'package:GenomicRanges':
##
## union
## The following object is masked from 'package:IRanges':
##
## union
## The following object is masked from 'package:S4Vectors':
##
## union
## The following objects are masked from 'package:BiocGenerics':
##
## normalize, path, union
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
library(patchwork)
##
## Attaching package: 'patchwork'
## The following object is masked from 'package:cowplot':
##
## align_plots
options(stringsAsFactors = FALSE)
Idents(slice7and10)<-'Condition'
Ctrl <- subset(x = slice7and10, idents = c("Ctrl"))
Ivo <- subset(x = slice7and10, idents = c("Ivosidenib"))
SOC <- subset(x = slice7and10, idents = c("XRT/TMZ"))
# Ctrl
#Ctrl <- SetIdent(Ctrl, value = "AnnotedClustedShallow")
#levels(Ctrl)
#cellchat <- createCellChat(object = Ctrl,, group.by = "AnnotedClustedShallow")
#CellChatDB <- CellChatDB.human # CHANGE IF MOUSE
#showDatabaseCategory(CellChatDB)
#CellChatDB.use <- CellChatDB
#cellchat@DB <- CellChatDB.use
#cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
#future::plan("multiprocess", workers = 5) # do parallel
#cellchat <- identifyOverExpressedGenes(cellchat)
#cellchat <- identifyOverExpressedInteractions(cellchat)
#cellchat@idents = droplevels(cellchat@idents, exclude = setdiff(levels(cellchat@idents),unique(cellchat@idents)))
#cellchat <- computeCommunProb(cellchat)
#cellchat <- filterCommunication(cellchat, min.cells = 10)
#cellchat <- computeCommunProbPathway(cellchat)
#cellchat <- aggregateNet(cellchat)
#groupSize <- as.numeric(table(cellchat@idents))
#cellchat@netP$pathways
#cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
#cco.Ctrl <- cellchat
#saveRDS(cco.Ctrl, file = "cco.Ctrl.rds")
cco.Ctrl<-readRDS("cco.Ctrl.rds")
reticulate::py_install(packages ='umap-learn')
## Using virtual environment '/hpc/home/aam131/.virtualenvs/r-reticulate' ...
## + '/hpc/home/aam131/.virtualenvs/r-reticulate/bin/python' -m pip install --upgrade --no-user 'umap-learn'
# Ivo
#Ivo <- SetIdent(Ivo, value = "AnnotedClustedShallow")
#levels(Ivo)
#cellchat <- createCellChat(object = Ivo,, group.by = "AnnotedClustedShallow")
#CellChatDB <- CellChatDB.human # CHANGE IF MOUSE
#showDatabaseCategory(CellChatDB)
#CellChatDB.use <- CellChatDB
#cellchat@DB <- CellChatDB.use
#cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
#future::plan("multiprocess", workers = 5) # do parallel
#cellchat <- identifyOverExpressedGenes(cellchat)
#cellchat <- identifyOverExpressedInteractions(cellchat)
#cellchat@idents = droplevels(cellchat@idents, exclude = setdiff(levels(cellchat@idents),unique(cellchat@idents)))
#cellchat <- computeCommunProb(cellchat)
#cellchat <- filterCommunication(cellchat, min.cells = 10)
#cellchat <- computeCommunProbPathway(cellchat)
#cellchat <- aggregateNet(cellchat)
#groupSize <- as.numeric(table(cellchat@idents))
#cellchat@netP$pathways
#cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
#cco.Ivo <- cellchat
#saveRDS(cco.Ivo, file = "cco.Ivo.rds")
cco.Ivo<-readRDS("cco.Ivo.rds")
reticulate::py_install(packages ='umap-learn')
## Using virtual environment '/hpc/home/aam131/.virtualenvs/r-reticulate' ...
## + '/hpc/home/aam131/.virtualenvs/r-reticulate/bin/python' -m pip install --upgrade --no-user 'umap-learn'
# SOC
#SOC <- SetIdent(SOC, value = "AnnotedClustedShallow")
#levels(SOC)
#cellchat <- createCellChat(object = SOC,, group.by = "AnnotedClustedShallow")
#CellChatDB <- CellChatDB.human # CHANGE IF MOUSE
#showDatabaseCategory(CellChatDB)
#CellChatDB.use <- CellChatDB
#cellchat@DB <- CellChatDB.use
#cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
#future::plan("multiprocess", workers = 5) # do parallel
#cellchat <- identifyOverExpressedGenes(cellchat)
#cellchat <- identifyOverExpressedInteractions(cellchat)
#cellchat@idents = droplevels(cellchat@idents, exclude = setdiff(levels(cellchat@idents),unique(cellchat@idents)))
#cellchat <- computeCommunProb(cellchat)
#cellchat <- filterCommunication(cellchat, min.cells = 10)
#cellchat <- computeCommunProbPathway(cellchat)
#cellchat <- aggregateNet(cellchat)
#groupSize <- as.numeric(table(cellchat@idents))
#cellchat@netP$pathways
#cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
#cco.SOC <- cellchat
#saveRDS(cco.SOC, file = "cco.SOC.rds")
cco.SOC<-readRDS("cco.SOC.rds")
reticulate::py_install(packages ='umap-learn')
## Using virtual environment '/hpc/home/aam131/.virtualenvs/r-reticulate' ...
## + '/hpc/home/aam131/.virtualenvs/r-reticulate/bin/python' -m pip install --upgrade --no-user 'umap-learn'
#Pathways In Each Condition
pathCTRL<-cco.Ctrl@netP$pathways
pathCTRL
## [1] "COLLAGEN" "LAMININ" "NCAM" "NRXN" "NRG" "FN1"
## [7] "SPP1" "PTN" "CNTN" "PTPRM" "VISFATIN" "TENASCIN"
## [13] "VEGF" "CADM" "JAM" "NGL" "SEMA3" "BMP"
## [19] "SEMA6" "PECAM1" "PDGF" "NOTCH" "CDH" "ANGPTL"
## [25] "EPHB" "NEGR" "GALECTIN" "NECTIN" "ANGPT" "THBS"
## [31] "VWF" "CD46" "FGF" "MPZ" "PROS" "ESAM"
## [37] "KIT" "CD226" "SEMA7" "WNT" "CD45" "CDH5"
## [43] "CD99" "GAS" "LIFR" "TGFb" "CSPG4" "EPHA"
## [49] "CLDN" "PVR" "ncWNT"
pathIVO<-cco.Ivo@netP$pathways
pathIVO
## [1] "COLLAGEN" "LAMININ" "SPP1" "FN1" "NCAM" "PTN"
## [7] "NRXN" "NRG" "PTPRM" "VISFATIN" "CADM" "CNTN"
## [13] "CDH" "NOTCH" "TENASCIN" "JAM" "MPZ" "SEMA3"
## [19] "NGL" "NEGR" "VEGF" "CD46" "ANGPT" "PECAM1"
## [25] "BMP" "ANGPTL" "APP" "NECTIN" "FGF" "SEMA6"
## [31] "PDGF" "THBS" "PROS" "EPHB" "WNT" "VWF"
## [37] "TGFb" "KIT" "CD226" "CD45" "SEMA7" "CDH5"
## [43] "GRN" "CDH1" "ncWNT" "LIFR" "CD22" "CXCL"
## [49] "CD99" "SEMA4" "IL1" "ACTIVIN" "CLDN" "ESAM"
## [55] "MAG" "PVR" "TRAIL"
pathSOC<-cco.SOC@netP$pathways
pathSOC
## [1] "COLLAGEN" "LAMININ" "SPP1" "PTN" "NCAM" "NRG"
## [7] "NRXN" "FN1" "PTPRM" "VISFATIN" "CNTN" "CDH"
## [13] "NGL" "JAM" "TENASCIN" "CADM" "BMP" "SEMA3"
## [19] "NOTCH" "VEGF" "NEGR" "SEMA6" "PECAM1" "ANGPT"
## [25] "CD46" "ANGPTL" "APP" "THBS" "MPZ" "PDGF"
## [31] "GALECTIN" "FGF" "NECTIN" "VWF" "ncWNT" "TGFb"
## [37] "KIT" "EPHB" "PROS" "CD226" "WNT" "CD45"
## [43] "CDH5" "EPHA" "GRN" "CD22" "LIFR" "SEMA4"
## [49] "CD99" "ACTIVIN" "CSPG4" "EDA" "CLDN" "ESAM"
## [55] "MAG" "TRAIL"
#Finding pathway data in each group
Shared <- intersect(intersect(pathCTRL,pathIVO),pathSOC)
Shared
## [1] "COLLAGEN" "LAMININ" "NCAM" "NRXN" "NRG" "FN1"
## [7] "SPP1" "PTN" "CNTN" "PTPRM" "VISFATIN" "TENASCIN"
## [13] "VEGF" "CADM" "JAM" "NGL" "SEMA3" "BMP"
## [19] "SEMA6" "PECAM1" "PDGF" "NOTCH" "CDH" "ANGPTL"
## [25] "EPHB" "NEGR" "NECTIN" "ANGPT" "THBS" "VWF"
## [31] "CD46" "FGF" "MPZ" "PROS" "ESAM" "KIT"
## [37] "CD226" "WNT" "CD45" "CDH5" "CD99" "LIFR"
## [43] "TGFb" "CLDN" "ncWNT"
Shared= Shared[Shared != c("CD226","CD45","LIFR")] # without elements that are "b"
#Compare CTRL to Ivo
# CompareList
cco.list <- list(Ctrl = cco.Ctrl, Ivo = cco.Ivo)
cellchat <- mergeCellChat(cco.list, add.names = names(cco.list), cell.prefix = T)
## Warning in mergeCellChat(cco.list, add.names = names(cco.list), cell.prefix =
## T): Prefix cell names!
## The cell barcodes in merged 'meta' is AAACCCAAGTGAACAT_1 AAACCCAGTACAATAG_1 AAACCCATCGACTCCT_1 AAACCCATCTAGCCTC_1 AAACGAACATGTTCGA_1 AAACGAAGTGCTATTG_1
## Warning in mergeCellChat(cco.list, add.names = names(cco.list), cell.prefix = T): The cell barcodes in merged 'meta' is different from those in the used data matrix.
## We now simply assign the colnames in the data matrix to the rownames of merged 'mata'!
## Merge the following slots: 'data.signaling','images','net', 'netP','meta', 'idents', 'var.features' , 'DB', and 'LR'.
compareInteractions(cellchat, show.legend = F, group = c(1,2), measure = "count")
compareInteractions(cellchat, show.legend = F, group = c(1,2), measure = "weight")
par(mfrow = c(1,2))
netVisual_diffInteraction(cellchat, weight.scale = T)
netVisual_diffInteraction(cellchat, weight.scale = T, measure = "weight")
par(mfrow = c(1,1))
h1 <- netVisual_heatmap(cellchat)
## Do heatmap based on a merged object
h2 <- netVisual_heatmap(cellchat, measure = "weight")
## Do heatmap based on a merged object
h1 + h2
Shared= Shared[Shared != c("CD226","CD45","LIFR")] # without elements that are "b"
for(i in Shared)
{pathways.show <- i
h1<-netVisual_heatmap(cco.Ctrl, signaling = pathways.show, color.heatmap = "Reds")
h2<-netVisual_heatmap(cco.Ivo, signaling = pathways.show, color.heatmap = "Reds")
h3<-netVisual_heatmap(cco.SOC, signaling = pathways.show, color.heatmap = "Reds")
p=h1+h2+h3
plot(p)
}
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
## Do heatmap based on a single object
##
## Do heatmap based on a single object
##
## Do heatmap based on a single object
pathways.show <- c(“BMP”) h1<-netVisual_heatmap(cco.Ctrl, signaling = pathways.show, color.heatmap = “Reds”) h2<-netVisual_heatmap(cco.Ivo, signaling = pathways.show, color.heatmap = “Reds”) h3<-netVisual_heatmap(cco.SOC, signaling = pathways.show, color.heatmap = “Reds”) h1+h2+h3 ```