-
Notifications
You must be signed in to change notification settings - Fork 1
/
cellchat.R
62 lines (50 loc) · 2.39 KB
/
cellchat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
library(CellChat)
library(ggplot2)
library(patchwork)
library(igraph)
library(ComplexHeatmap)
options(stringsAsFactors = FALSE)
CellC <- function(cellchat){
CellChatDB <- CellChatDB.mouse
cellchat@DB <- CellChatDB.use
cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
future::plan("multiprocess", workers = 4)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
cellchat <- computeCommunProb(cellchat)
# Filter out the cell-cell communication if there are only few number of cells in certain cell groups #add the parameters for ProjectPPI and computeCommun
cellchat <- filterCommunication(cellchat, min.cells = 10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
selectK(cellchat, pattern = "outgoing")
nPatterns = 5
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
ht1 <- netAnalysis_signalingRole_heatmap(cellchat, pattern = "outgoing")
ht1
cellchat <- identifyCommunicationPatterns(cellchat, pattern = "outgoing", k = nPatterns)
netAnalysis_river(cellchat, pattern = "outgoing")
dev.off()
selectK(cellchat, pattern = "incoming")
nPatterns = 5
cellchat <- identifyCommunicationPatterns(cellchat, pattern = "incoming", k = nPatterns)
netAnalysis_river(cellchat, pattern = "incoming")
ht2 <- netAnalysis_signalingRole_heatmap(cellchat, pattern = "incoming")
ht2
return (cellchat)
}
CellChatDB <- CellChatDB.mouse # use CellChatDB.mouse if running on mouse data
showDatabaseCategory(CellChatDB)
CellChatDB <- CellChatDB.mouse # set CellChatDB <- CellChatDB.human if working on the human dataset
library(NMF)
library(ggalluvial)
data.input <- GetAssayData(tmpGH, assay = "RNA", slot = "data") # normalized data matrix
levels(tmp)
new.cluster.ids <- c("epSC/5", "epSC/1", "CC/4", "CC/6", "CC/2", "PMC/3",
"PMC/7", "HC/8", "PHC/0")
names(new.cluster.ids) <- levels(tmp)
tmp <- RenameIdents(tmp, new.cluster.ids)
labels <- Idents(tmpGH)
meta <- data.frame(group = labels, row.names = names(labels)) # create a dataframe of the cell labels
cellchat.GH <- createCellChat(object = data.input, meta = meta, group.by = "group")
#> Create a CellChat object from a data matrix
cellchat.GH <- CellC(cellchat.GH)