CellChatは空間イメージングデータから細胞間コミュニケーションのための空間情報を推定・解析します
Suoqin Jin および Jingren Niu
2022 年 11 月 12 日
必要なライブラリのロード
パート 1: CellChat オブジェクトのデータ入力と処理および初期化
データのロード
CellChat
オブジェクトの作成 リガンド-受容
体相互作用データベースのセットアップ 前処理 細胞間通信解析 発現データ
パート II:細胞間通信ネットワークの
推論 通信確率の計算と
セルラー通信ネットワークの推論 シグナル伝達経路レベルでの細胞間通信の
推論 集約された細胞
間通信ネットワークの計算 パート III: 細胞間通信ネットワークの視覚化 パート
V: CellChat オブジェクトの保存
このビネットでは、CellChat を使用して次のことを行う手順の概要を説明します。単一の空間イメージング データ セットで細胞間通信ネットワークを推論、分析、視覚化します。CellChat をマウスの脳 10X visium データセット ( https://www.10xgenomics.com/resources/datasets/mouse-brain-serial-section-1-sagittal-anterior-1-standard ) に適用することで、その威力を実証します。空間イメージングデータへの応用-1-0-0)。スポットの生物学的注釈 (つまり、細胞集団情報) は、Seurat (https://satijalab.org/seurat/articles/spatial_vignette.html) を使用して予測されました。
CellChat は、ユーザー入力として遺伝子発現およびスポット/細胞の空間位置データを必要とし、遺伝子発現と空間距離、およびシグナル伝達リガンド、受容体およびそれらの補因子間の相互作用の事前知識とコミュニケーション確率を組み合わせて細胞をモデル化します。
細胞間通信ネットワークを推測した後、CellChat のさまざまな機能を使用して、さらなるデータ探索、分析、視覚化を行うことができます。
必要なライブラリをロードする
library(CellChat)
library(patchwork)
options(stringsAsFactors = FALSE)
パート 1: CellChat オブジェクトのデータ入力と処理と初期化
CellChat には 4 つのユーザー入力が必要です。
スポット/セルの遺伝子発現データ: 遺伝子は行、行名、セルは列、列名に存在する必要があります。CellChat 分析への入力として、正規化されたデータ (たとえば、正規化されたライブラリ サイズ、擬似カウント 1 を使用して対数変換されたデータ) が必要です。ユーザーがカウント データを提供する場合は、ライブラリ サイズを計算して対数変換を実行するためのnormalizeData 関数を提供します。
ユーザー割り当てのセル ラベル: セルのグループを定義するために使用されるセル情報 (行は行名を持つセル) で構成されるデータ フレーム。
スポット/セルの空間的位置: 各行が各セル/スポットの空間的位置/座標を示すデータ マトリックス。10X Visium の場合、この情報は Tissue_positions.csv にあります。
フル解像度画像のスケール係数とスポット直径: フル解像度画像のスケール係数とスポット直径のリストが含まれています。scale.factors には、理論的なスポット サイズ (たとえば、10x Visium (spot.size = 65 ミクロン)) である Spot.diameter と呼ばれる要素と、元のフル解像度画像である Spot と呼ばれる別の要素が含まれている必要があります。理論上のスポット径。10X Visium の場合、scale.factors はファイルscalefactors_json.json にあります。スポットはspot.size.fullresです。
データのダウンロード
# Here we load a Seurat object of 10X Visium mouse cortex data and its associated cell meta data
load("/Users/jinsuoqin/Mirror/CellChat/tutorial/visium_mouse_cortex_annotated.RData")
library(Seurat)
#> Attaching SeuratObject
visium.brain
#> An object of class Seurat
#> 1298 features across 1073 samples within 3 assays
#> Active assay: SCT (648 features, 260 variable features)
#> 2 other assays present: Spatial, predictions
#> 2 dimensional reductions calculated: pca, umap
# show the image and annotated spots
SpatialDimPlot(visium.brain, label = T, label.size = 3, cols = scPalette(nlevels(visium.brain)))
#> Scale for 'fill' is already present. Adding another scale for 'fill', which
#> will replace the existing scale.
# Prepare input data for CelChat analysis
data.input = GetAssayData(visium.brain, slot = "data", assay = "SCT") # normalized data matrix
meta = data.frame(labels = Idents(visium.brain), row.names = names(Idents(visium.brain))) # manually create a dataframe consisting of the cell labels
unique(meta$labels) # check the cell labels
#> [1] L2/3 IT Astro L6b L5 IT L6 IT L6 CT L4 Oligo
#> Levels: Astro L2/3 IT L4 L5 IT L6 IT L6 CT L6b Oligo
# load spatial imaging information
# Spatial locations of spots from full (NOT high/low) resolution images are required
spatial.locs = GetTissueCoordinates(visium.brain, scale = NULL, cols = c("imagerow", "imagecol"))
# Scale factors and spot diameters of the full resolution images
scale.factors = jsonlite::fromJSON(txt = file.path("/Users/jinsuoqin/Mirror/CellChat/tutorial/spatial_imaging_data_visium-brain", 'scalefactors_json.json'))
scale.factors = list(spot.diameter = 65, spot = scale.factors$spot_diameter_fullres, # these two information are required
fiducial = scale.factors$fiducial_diameter_fullres, hires = scale.factors$tissue_hires_scalef, lowres = scale.factors$tissue_lowres_scalef # these three information are not required
)
# USER can also extract scale factors from a Seurat object, but the `spot` value here is different from the one in Seurat. Thus, USER still needs to get the `spot` value from the json file.
###### Applying to different types of spatial imaging data ######
# `spot.diameter` is dependent on spatial imaging technologies and `spot` is dependent on specific datasets
CellChatオブジェクトを作成する
ユーザーは、データ マトリックスまたは Seurat から新しい CellChat オブジェクトを作成できます。入力が Seurat オブジェクトの場合、オブジェクトからのメタデータがデフォルトで使用され、USER はセル グループを定義するために group.by を提供する必要があります。たとえば、Seurat オブジェクトのデフォルトのセル ID の場合、group.by = "ident" となります。
注: ユーザーが以前に計算された CellChat オブジェクト (バージョン < 1.6.0) をロードする場合は、updateCellChat を介してオブジェクトを更新してください。
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels",
datatype = "spatial", coordinates = spatial.locs, scale.factors = scale.factors)
#> [1] "Create a CellChat object from a data matrix"
#> Create a CellChat object from spatial imaging data...
#> Set cell identities for the new CellChat object
#> The cell groups used for CellChat analysis are Astro L2/3 IT L4 L5 IT L6 IT L6 CT L6b Oligo
cellchat
#> An object of class CellChat created from a single dataset
#> 648 genes.
#> 1073 cells.
#> CellChat analysis of spatial data! The input spatial locations are
#> imagerow imagecol
#> AAACAGAGCGACTCCT-1 3164 7950
#> AAACCGGGTAGGTACC-1 6517 3407
#> AAACCGTTCGTCCAGG-1 7715 4371
#> AAACTCGTGATATAAG-1 4242 9258
#> AAAGGGATGTAGCAAG-1 4362 5747
#> AAATAACCATACGGGA-1 3164 7537
リガンド-受容体相互作用データベースのセットアップ
当社のデータベース CellChatDB は、文献に裏付けられたヒトおよびマウスのリガンド-受容体相互作用を含む手動で精選されたデータベースです。マウスの CellChatDB には、60% の分泌自己分泌/傍分泌シグナル伝達相互作用、21% の細胞外マトリックス (ECM) 受容体相互作用、19% の細胞間接触相互作用を含む 2,021 の検証済み分子相互作用が含まれています。CellChatDB には、パラクリン/オートクリンシグナル伝達相互作用の 61.8%、細胞外マトリックス (ECM) 受容体相互作用の 21.7%、細胞間接触相互作用効果の 16.5% を含む、ヒトにおける検証された 1,939 の分子相互作用が含まれています。
ユーザーは、独自に厳選されたリガンドと受容体のペアを追加することで CellChatDB を更新できます。その方法については、チュートリアルをご覧ください。
CellChatDB <- CellChatDB.mouse # use CellChatDB.human if running on human data
# use a subset of CellChatDB for cell-cell communication analysis
CellChatDB.use <- subsetDB(CellChatDB, search = "Secreted Signaling") # use Secreted Signaling
# use all CellChatDB for cell-cell communication analysis
# CellChatDB.use <- CellChatDB # simply use the default CellChatDB
# set the used database in the object
cellchat@DB <- CellChatDB.use
細胞間コミュニケーション解析のための発現データの前処理
細胞状態特異的なコミュニケーションを推測するために、細胞集団内の過剰発現リガンドまたは受容体を同定し、次にリガンドまたは受容体が過剰発現した場合の過剰発現リガンド-受容体相互作用を同定しました。
また、遺伝子発現データをタンパク質間相互作用 (PPI) ネットワークに投影する機能も提供します。具体的には、拡散手順を使用して、信頼性の高い実験的に検証されたタンパク質間ネットワークで定義された隣接する遺伝子の発現値に対して遺伝子の発現値を平滑化します。この機能は、特にリガンド/受容体サブユニットのゼロ発現の可能性について、投影によってシグナル伝達遺伝子の損失の影響が軽減されるため、シーケンシングの深さが浅い単一細胞データを分析する場合に役立ちます。この拡散プロセスによって生じるアーティファクトを心配する人もいるかもしれませんが、それは非常に弱い通信をもたらすだけです。ユーザーは、この手順をスキップして、関数 computeCommunProb() で raw.use = TRUE を設定することもできます。
# subset the expression data of signaling genes for saving computation cost
cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
future::plan("multiprocess", workers = 4) # do parallel
#> Warning: Strategy 'multiprocess' is deprecated in future (>= 1.20.0). Instead,
#> explicitly specify either 'multisession' or 'multicore'. In the current R
#> session, 'multiprocess' equals 'multisession'.
#> Warning in supportsMulticoreAndRStudio(...): [ONE-TIME WARNING] Forked
#> processing ('multicore') is not supported when running R from RStudio
#> because it is considered unstable. For more details, how to control forked
#> processing or not, and how to silence this warning in future R sessions, see ?
#> parallelly::supportsMulticore
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
# project gene expression data onto PPI (Optional: when running it, USER should set `raw.use = FALSE` in the function `computeCommunProb()` in order to use the projected data)
# cellchat <- projectData(cellchat, PPI.mouse)
パート II: 細胞間通信ネットワークの推論
CellChat は、各相互作用に確率値を割り当て、順列テストを実行することにより、生物学的に意味のある細胞間通信を推測します。CellChat は、質量作用の法則を使用して、遺伝子発現と空間的位置、およびシグナル伝達リガンド、受容体、およびそれらの補因子間の既知の相互作用を組み合わせることにより、細胞間コミュニケーションの可能性をモデル化します。
推定されるリガンドと受容体のペアの数は、明らかに、各細胞集団の平均遺伝子発現を計算するために使用される方法に依存します。現在の空間イメージング技術の感度が低いため、平均遺伝子発現を計算するには 10% 切り捨て平均を使用することをお勧めします。デフォルトの「三平均法」法では生成される相互作用が少なく、低発現シグナルを見逃す可能性があります。computeCommunProb では、さまざまな方法を使用して平均遺伝子発現を計算するオプションが提供されます。「三平均値」がカットオフ平均の 25% に近いことは注目に値します。これは、グループ内の発現細胞の割合が 25% 未満の場合、平均遺伝子発現はゼロであることを意味します。10% 切り捨て平均を使用するには、type = "truncatedMean" および trim = 0.1 を設定します。関数 computeAveExpr は、目的のシグナル伝達遺伝子の平均発現を調べるのに役立ちます。たとえば、computeAveExpr(cellchat, features = c("CXCL12", "CXCR4"), type = "truncatedMean", trim = 0.1) です。
通信確率を計算し、セルラー通信ネットワークを推測する
推論結果をすばやく確認するには、computeCommunProb で nboot=20 を設定します。「pvalue < 0.05」は、どの順列結果も観測された通信確率より大きくないことを意味します。
研究中の生物学的プロセスにおける既知のシグナル伝達経路が予測できない場合、ユーザーは、trim の値を低くして truncatedMean を試し、各細胞グループの平均遺伝子発現の計算方法を変更できます。
スケール.ディスタンス 他の空間イメージング技術からのデータを処理する場合、ユーザーはパラメーターを調整する必要がある場合があります。?computeCommunProb からドキュメントの詳細を参照してください。
cellchat <- computeCommunProb(cellchat, type = "truncatedMean", trim = 0.1,
distance.use = TRUE, interaction.length = 200, scale.distance = 0.01)
#> truncatedMean is used for calculating the average gene expression per cell group.
#> [1] ">>> Run CellChat on spatial imaging data using distances as constraints <<< [2022-11-12 07:49:23]"
#> The suggested minimum value of scaled distances is in [1,2], and the calculated value here is 1.30553
#> [1] ">>> CellChat inference is done. Parameter values are stored in `object@options$parameter` <<< [2022-11-12 08:10:42]"
# Filter out the cell-cell communication if there are only few number of cells in certain cell groups
cellchat <- filterCommunication(cellchat, min.cells = 10)
シグナル伝達経路レベルでの細胞間コミュニケーションの推測
CellChat は、各シグナル伝達経路に関連するすべてのリガンド-受容体相互作用の通信確率を要約することにより、シグナル伝達経路レベルでのコミュニケーション確率を計算します。
注: 各リガンドと受容体のペアおよび各シグナル伝達経路の推定細胞間通信ネットワークは、それぞれスロット "net" と "netP" に保存されます。
cellchat <- computeCommunProbPathway(cellchat)
計算によって集約された細胞間通信ネットワーク
リンクの数を数えたり、通信確率を集計したりすることで、集合的な細胞間通信ネットワークを計算できます。sources.useUSER は、合計を設定することにより、セル グループのサブセット間の集約ネットワーク target.use を計算するためにも使用できます。
cellchat <- aggregateNet(cellchat)
集合した細胞間通信ネットワークを視覚化することもできます。たとえば、円グラフを使用して、任意の 2 つのセル グループ間の相互作用の数または合計の相互作用強度 (重み) を表示します。
groupSize <- as.numeric(table(cellchat@idents))
par(mfrow = c(1,2), xpd=TRUE)
netVisual_circle(cellchat@net$count, vertex.weight = rowSums(cellchat@net$count), weight.scale = T, label.edge= F, title.name = "Number of interactions")
netVisual_circle(cellchat@net$weight, vertex.weight = rowSums(cellchat@net$weight), weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")
パート III: 細胞間通信ネットワークの可視化
CellChat は、細胞間通信ネットワークを推測した後、さらなるデータ探索、分析、視覚化のためのさまざまな機能を提供します。ここでは、円プロットと新しい空間プロットのみを示します。
さまざまなレベルでの細胞間通信の可視化: シグナル伝達経路の推定通信ネットワークは netVisual_aggregate を使用して視覚化でき、そのシグナル伝達経路に関連付けられた個々の LR ペアの推定通信ネットワークは netVisual_individual を使用して視覚化できます。
ここでは信号パスの入力を例に挙げます。重要な通信を示すすべての信号経路には、cellchat@netP$pathways からアクセスできます。
pathways.show <- c("CXCL")
# Circle plot
par(mfrow=c(1,1))
netVisual_aggregate(cellchat, signaling = pathways.show, layout = "circle")
# Spatial plot
par(mfrow=c(1,1))
netVisual_aggregate(cellchat, signaling = pathways.show, layout = "spatial", edge.width.max = 2, vertex.size.max = 1, alpha.image = 0.2, vertex.label.cex = 3.5)
ネットワーク中心性スコアを計算して視覚化します。
# Compute the network centrality scores
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
# Visualize the computed centrality scores using heatmap, allowing ready identification of major signaling roles of cell groups
par(mfrow=c(1,1))
netAnalysis_signalingRole_network(cellchat, signaling = pathways.show, width = 8, height = 2.5, font.size = 10)
# USER can visualize this information on the spatial imaging, e.g., bigger circle indicates larger incoming signaling
par(mfrow=c(1,1))
netVisual_aggregate(cellchat, signaling = pathways.show, layout = "spatial", edge.width.max = 2, alpha.image = 0.2, vertex.weight = "incoming", vertex.size.max = 3, vertex.label.cex = 3.5)
注: CellChat のさまざまな機能は、空間イメージング データから細胞間通信ネットワークを推測することにより、さらなるデータ探索、分析、視覚化に使用できます。CellChat-vignette.html という名前の基本チュートリアルで他の機能を確認してください。
パート 5: CellChat オブジェクトの保存
saveRDS(cellchat, file = "cellchat_visium_mouse_cortex.rds")
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] SeuratObject_4.0.4 Seurat_4.0.6 patchwork_1.1.1
#> [4] CellChat_1.6.0 Biobase_2.54.0 BiocGenerics_0.40.0
#> [7] ggplot2_3.3.5 igraph_1.3.4 dplyr_1.0.7
#>
#> loaded via a namespace (and not attached):
#> [1] backports_1.4.1 circlize_0.4.13 systemfonts_1.0.2
#> [4] NMF_0.23.0 plyr_1.8.6 lazyeval_0.2.2
#> [7] splines_4.1.2 BiocParallel_1.28.3 listenv_0.8.0
#> [10] scattermore_0.7 ggnetwork_0.5.10 gridBase_0.4-7
#> [13] digest_0.6.29 foreach_1.5.1 htmltools_0.5.2
#> [16] magick_2.7.3 ggalluvial_0.12.3 fansi_0.5.0
#> [19] magrittr_2.0.1 tensor_1.5 cluster_2.1.2
#> [22] doParallel_1.0.16 ROCR_1.0-11 sna_2.6
#> [25] ComplexHeatmap_2.10.0 globals_0.14.0 matrixStats_0.61.0
#> [28] svglite_2.0.0 spatstat.sparse_2.1-0 colorspace_2.0-2
#> [31] ggrepel_0.9.1 xfun_0.33 crayon_1.4.2
#> [34] jsonlite_1.7.2 spatstat.data_2.1-2 survival_3.2-13
#> [37] zoo_1.8-9 iterators_1.0.13 glue_1.6.0
#> [40] polyclip_1.10-0 registry_0.5-1 gtable_0.3.0
#> [43] leiden_0.3.9 GetoptLong_1.0.5 car_3.0-12
#> [46] future.apply_1.8.1 shape_1.4.6 abind_1.4-5
#> [49] scales_1.1.1 DBI_1.1.2 rngtools_1.5.2
#> [52] rstatix_0.7.0 miniUI_0.1.1.1 Rcpp_1.0.7
#> [55] viridisLite_0.4.0 xtable_1.8-4 clue_0.3-60
#> [58] spatstat.core_2.3-2 reticulate_1.22 stats4_4.1.2
#> [61] htmlwidgets_1.5.4 httr_1.4.2 FNN_1.1.3
#> [64] RColorBrewer_1.1-2 ellipsis_0.3.2 ica_1.0-2
#> [67] farver_2.1.0 pkgconfig_2.0.3 uwot_0.1.11
#> [70] deldir_1.0-6 sass_0.4.0 utf8_1.2.2
#> [73] labeling_0.4.2 later_1.3.0 tidyselect_1.1.1
#> [76] rlang_0.4.12 reshape2_1.4.4 munsell_0.5.0
#> [79] tools_4.1.2 generics_0.1.1 statnet.common_4.5.0
#> [82] broom_0.7.10 ggridges_0.5.3 evaluate_0.17
#> [85] stringr_1.4.0 fastmap_1.1.0 goftest_1.2-3
#> [88] yaml_2.2.1 knitr_1.40 fitdistrplus_1.1-6
#> [91] purrr_0.3.4 RANN_2.6.1 nlme_3.1-153
#> [94] pbapply_1.5-0 future_1.23.0 mime_0.12
#> [97] compiler_4.1.2 plotly_4.10.0 png_0.1-7
#> [100] ggsignif_0.6.3 spatstat.utils_2.3-0 tibble_3.1.6
#> [103] bslib_0.3.1 stringi_1.7.6 highr_0.9
#> [106] RSpectra_0.16-0 lattice_0.20-45 Matrix_1.3-4
#> [109] vctrs_0.3.8 pillar_1.6.4 lifecycle_1.0.1
#> [112] spatstat.geom_2.3-1 lmtest_0.9-39 jquerylib_0.1.4
#> [115] GlobalOptions_0.1.2 RcppAnnoy_0.0.19 BiocNeighbors_1.12.0
#> [118] data.table_1.14.2 cowplot_1.1.1 irlba_2.3.5
#> [121] httpuv_1.6.4 R6_2.5.1 promises_1.2.0.1
#> [124] network_1.17.1 gridExtra_2.3 KernSmooth_2.23-20
#> [127] IRanges_2.28.0 parallelly_1.30.0 codetools_0.2-18
#> [130] MASS_7.3-54 assertthat_0.2.1 pkgmaker_0.32.2
#> [133] rjson_0.2.20 withr_2.4.3 sctransform_0.3.2
#> [136] S4Vectors_0.32.3 mgcv_1.8-38 parallel_4.1.2
#> [139] rpart_4.1-15 grid_4.1.2 tidyr_1.1.4
#> [142] coda_0.19-4 rmarkdown_2.17 carData_3.0-4
#> [145] Rtsne_0.15 ggpubr_0.4.0 shiny_1.7.1