-
Notifications
You must be signed in to change notification settings - Fork 1
/
cellchat.R
25 lines (24 loc) · 1.41 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
sunye <- readRDS("G://Sun_Ye/Processed/P13_0.5_3.RDS") #read the preprocessed file
sunye_normal <- subset(sunye, subset = group == 'Normal') #subset by conditions
head(sunye_normal)
DimPlot(sunye_normal, label = TRUE, label.box = TRUE)
sunye_normal$labels <- [email protected]
sunye_OIRKO <- subset(sunye, subset = group == 'OIR_KO')
sunye_OIRKO$labels <- [email protected]
sunye_OIRWT <- subset(sunye, subset = group == 'OIR_WT')
sunye_OIRWT$labels <- [email protected] #save labels in a separated column
library(CellChat) #perform CellChat analysis
cellchat <- createCellChat(object = sunye_normal, group.by = "labels") #grouped by cell populations
CellChatDB <- CellChatDB.mouse
CellChatDB.use <- CellChatDB
cellchat@DB <- CellChatDB.use
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
cellchat <- projectData(cellchat, PPI.human)
cellchat <- computeCommunProb(cellchat, type = "truncatedMean", trim = 0.1, raw.use = FALSE, population.size = TRUE)
cellchat <- filterCommunication(cellchat, min.cells = 3)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP")
netVisual_aggregate(cellchat, signaling = c('SPP1'), layout = "chord") #SPP1 as example, can dig into L-R pairs, contribution and specific L-R pair chord diagram