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 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| library(CellChat) library(ggplot2) library(patchwork) library(igraph)
future::plan("sequential")
f_CC_Inference_CC_C_network <- function(cellchat){ cellchat <- computeCommunProb(cellchat, type = "truncatedMean", trim = 0.1, population.size = TRUE) cellchat <- filterCommunication(cellchat, min.cells = 10) cellchat <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet(cellchat) cellchat }
MP_H = readRDS(file = 'SS_H.rds') MP_C = readRDS(file = 'SS_C.rds')
MP_H = readRDS(file = 'ER_H.rds') MP_C = readRDS(file = 'ER_C.rds')
MP_H = readRDS(file = 'CC_H.rds') MP_C = readRDS(file = 'CC_C.rds')
MP_H <- f_CC_Inference_CC_C_network(MP_H) MP_C <- f_CC_Inference_CC_C_network(MP_C)
require(NMF) require(ggalluvial) MP_H <- netAnalysis_computeCentrality(MP_H, slot.name = "netP") MP_C <- netAnalysis_computeCentrality(MP_C, slot.name = "netP")
selectK(MP_H, pattern = "outgoing") MP_H <- identifyCommunicationPatterns(MP_H, pattern = "outgoing", k = 3) selectK(MP_H, pattern = "incoming") MP_H <- identifyCommunicationPatterns(MP_H, pattern = "incoming", k = 4) selectK(MP_C, pattern = "outgoing") MP_C <- identifyCommunicationPatterns(MP_C, pattern = "outgoing", k = 3) selectK(MP_C, pattern = "incoming") MP_C <- identifyCommunicationPatterns(MP_C, pattern = "incoming", k = 4)
f_CC_ISG_F = function(cellchat){ cellchat <- computeNetSimilarity(cellchat, type = "functional") cellchat <- netEmbedding(cellchat, type = "functional") cellchat <- netClustering(cellchat, type = "functional") cellchat }
MP_H <- f_CC_ISG_F(MP_H) MP_C <- f_CC_ISG_F(MP_C)
f_CC_ISG_S = function(cellchat){ cellchat <- computeNetSimilarity(cellchat, type = "structural") cellchat <- netEmbedding(cellchat, type = "structural") cellchat <- netClustering(cellchat, type = "structural") cellchat }
MP_H <- f_CC_ISG_S(MP_H) MP_C <- f_CC_ISG_S(MP_C)
saveRDS(MP_H,file = 'CC_H.rds') saveRDS(MP_C,file = 'CC_C.rds')
saveRDS(MP_H,file = 'ER_H.rds') saveRDS(MP_C,file = 'ER_C.rds')
saveRDS(MP_H,file = 'SS_H.rds') saveRDS(MP_C,file = 'SS_C.rds')
|