10X單細胞和空間聯(lián)合分析的方法---cell2location

10X空間轉(zhuǎn)錄組和單細胞轉(zhuǎn)錄組都在如火如荼的進行當中,單細胞提供了單個細胞的精度來研究組織,而空間轉(zhuǎn)錄組則是提供了細胞類型在組織中的具體位置,精度和空間位置幾乎具有同等的研究價值,而兩種技術(shù)上的聯(lián)合分析正是優(yōu)勢互補的選擇,而且也是一種挑戰(zhàn)。目前聯(lián)合分析的方法已經(jīng)有了好幾個,包括Seurat、scanpy等,但目前而言,利用的情況很少,今天我們來分享一下一種新的聯(lián)合分析方法----cell2location。文獻在這里Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics,今天我們的任務(wù)就是來參透這個方法,首先我們來分享文獻。

Abstract

組織中細胞類型的空間位置從根本上塑造了細胞之間的相互作用和功能,but the high-throughput spatial mapping of complex tissues remains a challenge。We present сell2location, a principled and versatile Bayesian model(貝葉斯模型) that integrates single-cell and spatial transcriptomics to map cell types in situ in a comprehensive manner。在準確性和全面性的方面,cell2location的表現(xiàn)優(yōu)異,In the mouse brain, we use a new paired single nucleus and spatial RNA-sequencing dataset to map dozens of cell types and identify tissue regions in an automated manner。We discover novel regional astrocyte subtypes including fine subpopulations in the thalamus and hypothalamus(新的發(fā)現(xiàn))。In the human lymph node, we resolve spatially interlaced immune cell states and identify co-located groups of cells underlying tissue organisation.(細胞共定位)。我們在空間上繪制罕見的萌發(fā)前中心B細胞種群,并預(yù)測與干擾素反應(yīng)相關(guān)的推定細胞相互作用。總之方法很好用。
這里我們需要注意的一點就是,貝葉斯模型,這個模型在建模的時候很常用,這里就不多介紹了,推薦大家看一本書《機器學(xué)習(xí)原理、算法與應(yīng)用》,書中講述了很多有關(guān)機器學(xué)習(xí)的算法和基礎(chǔ)知識,有利于我們加深生信分析的算法原理。

Introduction

The cellular architecture of tissues, where distinct cell types are organized in space, underlies cell-cell communication, organ function and pathology.(組織是一個復(fù)雜的統(tǒng)一體)。Emerging spatial genomics technologies hold considerable promise for characterising tissue architecture, providing key opportunities to map resident cell types and cell signalling in situ, thereby helping guide in vitro tissue engineering efforts.(空間轉(zhuǎn)錄組的主要應(yīng)用價值)。但是空間轉(zhuǎn)錄組仍然存在挑戰(zhàn),One reason is the enormous variation in tissue architecture across organs, ranging from the brain with hundreds of cell types found across discrete anatomical regions to immune organs with continuous cellular gradients and dynamically modified microenvironments。To create and map comprehensive tissue atlases, experimental and computational methods need to be aligned to cope with this variation and in particular, enable mapping numerous resident cell types across diverse and complex tissues in situ.(技術(shù)挑戰(zhàn))。
coupled single-cell and spatially resolved transcriptomics offer a scalable approach to address these challenges(單細胞和空間轉(zhuǎn)錄組的技術(shù)互補)。首先第一步要從解離的組織中識別各種細胞類型(單細胞轉(zhuǎn)錄組),然后匹配各個細胞類型的空間位置分布。目前的挑戰(zhàn)是First, spatial RNA-seq measurements (i.e. locations) combine multiple cell types as array-based mRNA capture currently do not match cellular boundaries in tissues. Thus, each spatial position corresponds to either several cell types (Visium, Tomo-Seq) or fractions of multiple cell types (Slide-Seq, HDST). Second, spatial RNA-seq measurements are confounded by different sources of variation as 1) cell numbers vary across tissue positions, 2) different cells and cell types differ in total mRNA content, and 3) thin tissue sectioning captures variable fractions of each cell’s volume. Computational approaches need to appropriately model and account for all of these factors。
Here, we present cell2location, a principled and versatile Bayesian model for comprehensive mapping of cell types in spatial transcriptomic data.(我們關(guān)注的重點)Cell2location uses reference gene expression signatures of cell types derived from scRNA-seq to decompose multi-cell spatial transcriptomic data into cell type abundance maps(簡單的原理與其他方法相同,算法有差異)。The model accurately maps complex tissues, including rare cell types and fine subtypes, and it identifies tissue regions and co-located cell types downstream in an automated manner(能夠識別共定位的細胞類型,這個很重要)。下面是兩個應(yīng)用案例,證明這個方法好。

Result

(1)Cell2location: a Bayesian model for spatial mapping of cell types

Cell2location maps the spatial distribution of cell types by integrating single-cell RNAseq (scRNA-seq) and multi-cell spatial transcriptomic data from a given tissue。

圖片.png

從原理圖上來看,單細胞作為參考,匹配細胞類型的空間位置,這個方向無可改變。
首先第一步:利用模型估計單細胞數(shù)據(jù)的細胞類型的表達特征。例如,通過使用常規(guī)聚類來識別細胞類型和亞群,然后估算平均聚類基因表達譜而獲得的結(jié)果(如下圖)
圖片.png
,我們需要逐步分析。Cell2location基于負二項式回歸實現(xiàn)此估算步驟,從而可以跨技術(shù)和批次可靠地組合數(shù)據(jù)。(又是數(shù)學(xué))。
第二步:cell2location decomposes mRNA counts in spatial transcriptomic data using these reference signatures, thereby estimating the relative and absolute abundance of each cell type at each spatial location。(分解數(shù)據(jù))。
Cell2location被實現(xiàn)為可解釋的分層貝葉斯模型,thereby (1) providing principled means to account for model uncertainty, (2) accounting for linear dependencies in cell type abundances, (3) modelling differences in measurement sensitivity across technologies, and (4) accounting for unexplained/residual variation by employing a flexible count-based error model. Finally, (5) cell2location is computationally efficient, owing to variational approximate inference and GPU acceleration。(這些方法我們下一篇分享解析)。
To validate cell2location, we initially used simulated data that reflects diverse cell abundance and spatial patterns。(作者模擬了空間轉(zhuǎn)錄組數(shù)據(jù))。
圖片.png

這里我們需要注意的是Jensen–Shannon divergence,也就是J-S散度,數(shù)學(xué)的內(nèi)容我們下面講解。
Briefly, we simulated a spatial transcriptomics dataset with 2,000 locations, based on reference cell-type annotations obtained from a mouse brain snRNA-seq reference dataset including 46 cell types,Multi-cell gene expression profiles at each location were derived by combining cells drawn from different reference cell types, using one of four cell abundance patterns with variable density and sparsity distribution that mimics the patterns observed in real data。然后運用cell2location進行分析,得到圖中的結(jié)果?;旧嫌泻芨叩南嚓P(guān)性,但是這里有一個問題,那就是模擬的空間轉(zhuǎn)錄組數(shù)據(jù)是依據(jù)單細胞數(shù)據(jù)合并而來,一旦真正的空間轉(zhuǎn)錄組數(shù)據(jù)含有某些單細胞不存在的細胞類型(比如說技術(shù)壁壘,10X單細胞捕獲中性粒細胞結(jié)果很差),那么預(yù)測的結(jié)果很可能出現(xiàn)錯誤,我們往后看看,是否作者提到這個問題。
Next, we compared cell2location to recently proposed alternative methods for the inference of relative cell-type abundance from spatial transcriptomics。一樣的文獻結(jié)果,自己的軟件表現(xiàn)最好。并且該模型還產(chǎn)生了相對細胞類型豐度的更準確估計。
圖片.png

圖片.png

這里我們需要注意的是,PR曲線,這些數(shù)學(xué)上的問題我們下面講解。
cell2location not only provides estimates of relative cell type fractions but additionally estimates absolute cell type abundance, which can be interpreted as the number of cells that express a reference cell type signature at a given location, which again were highly concordant with the simulated ground truth(估計細胞數(shù)量,這個也很重要)。
圖片.png

圖片.png

總之,these results support that cell2location can accurately estimate cell abundance across diverse cell types.
然后文章用了兩個例子,運用該軟見解決我們的聯(lián)合分析問題。具體案例我們這里就不多說了,我們需要更多的是算法的原理。

我們首先解決一下J-S散度和PR曲線。

Jensen-Shannon divergence(J-S散度) is a method of measuring the similarity between two probability distributions。這個我們需要先知道一下KL散度。

KL散度又稱為相對熵,信息散度,信息增益。KL散度是是兩個概率分布P和Q 差別的非對稱性的度量。 KL
散度是用來 度量使用基于Q的編碼來編碼來自P的樣本平均所需的額外的位元數(shù)。 典型情況下,P表示數(shù)據(jù)的真實分布,Q表示數(shù)據(jù)的理論分布,模型分布,或P的近似分布。
定義如下:


圖片.png

因為對數(shù)函數(shù)是凸函數(shù),所以 KL散度的值為非負數(shù)。

  1. JS散度(Jensen-Shannon)
    JS散度度量了兩個概率分布的相似度,基于KL散度的變體,解決了KL散度非對稱的問題。一般地,JS散度是對稱的,其取值是0到1之間。定義如下:


    圖片.png

    也就是圖B 的結(jié)果。

PR曲線

相對于PR曲線,ROC曲線了解的更多一些,大家可以參考我關(guān)于ROC曲線的講解深入理解R包AUcell對于分析單細胞的作用.
而PR曲線

PR曲線實則是以precision(精準率)和recall(召回率)這兩個為變量而做出的曲線,其中recall為橫坐標,precision為縱坐標。
那么問題來了,什么是精準率?什么是召回率?這里先做一個解釋。
在二分類問題中,分類器將一個實例的分類標記為是或否,可以用一個混淆矩陣來表示,如下圖所示。

image

注:把正例正確地分類為正例,表示為TP(true positive),把正例錯誤地分類為負例,表示為FN(false negative)。
把負例正確地分類為負例,表示為TN(true negative), 把負例錯誤地分類為正例,表示為FP(false positive)。

【舉個栗子:A是只貓(正例),B是只倉鼠(負例),A在二分類中被劃分為貓則為TP,被劃分為倉鼠則為FN。B在二分類中被劃分為倉鼠則為TN,被劃分為貓則為。】
從混淆矩陣可以得出精準率與召回率:precision = TP/(TP + FP), recall = TP/(TP +FN)(注意:分子相同。)

接下來補充一個重點:
一條PR曲線要對應(yīng)一個閾值。通過選擇合適的閾值,比如50%,對樣本進行劃分,概率大于50%的就認為是正例,小于50%的就是負例,從而計算相應(yīng)的精準率和召回率。

舉個例子如下:(true這列表示正例或者負例,hyp這列表示閾值0.5的情況下,概率是否大于0.5)

image

那么根據(jù)這個表格我們可以計算:TP=6,F(xiàn)N=0,F(xiàn)P=2,TN=2。故recall=6/(6+0)=1,precison=6/(6+2)=0.75,那么得出坐標(1,0.75)。同理得到不同閾下的坐標,即可繪制出曲線。
PR曲線如下:

image

如果一個學(xué)習(xí)器的P-R曲線被另一個學(xué)習(xí)器的P-R曲線完全包住,則可斷言后者的性能優(yōu)于前者,例如上面的A和B優(yōu)于學(xué)習(xí)器C。但是A和B的性能無法直接判斷,我們可以根據(jù)曲線下方的面積大小來進行比較,但更常用的是平衡點或者是F1值。平衡點(BEP)是P=R時的取值,如果這個值較大,則說明學(xué)習(xí)器的性能較好。而F1 = 2 * P * R /( P + R ),同樣,F(xiàn)1值越大,我們可以認為該學(xué)習(xí)器的性能較好。
部分資料參考:二戰(zhàn)周志華《機器學(xué)習(xí)》-PR曲線和ROC曲線
P-R曲線深入理解
兩種曲線我們都需要了解一下,以免以后遇到不知道就尷尬了~~~

接下來我們來看cell2location的模型。

模型的簡單介紹
For a complete derivation of the cell2location model, please see supplementary computational methods. Briefly, cell2location is a Bayesian model, which estimates absolute cell density of cell types by decomposing mRNA counts ??s,g of each gene ?? = {1, . . , ??} at locations ?? = {1, . . , ??} into a set of predefined reference signatures of cell types gf g.For 10X Visium data, this matrix can be directly obtained from the 10X SpaceRanger software and imported into data format used in a popular python package Scanpy(利用scanpy來讀取10X分析數(shù)據(jù),也可以聯(lián)合Suerat進行分析)。ds,g should be fltered to a set of genes expressed in the single cell reference g f g.這個地方的處理在于單細胞與空間轉(zhuǎn)錄組映射的時候,表達基因的相同。cell2location的圖表模型如下圖:

圖片.png

Let G = {gf,g}, denote an F X G matrix of reference cell type signatures, which consist of F = {1,..., F} gene expression profiles Gf,: for g = {1,...,G} genes, representing average expression of each gene in each cell type in linear mRNA counts space (not log-space).This matrix needs to be provided to cell2location and can be estimated from scRNA-seq profles.這個地方我們可以看到,對各個細胞類型的基因表達求平均值來代表這個細胞類型。Cell2location models the elements of D as Negative Binomial distributed,這個地方稍微說一下負二項分布,
負二項分布是統(tǒng)計學(xué)上一種離散概率分布。滿足以下條件的稱為負二項分布:實驗包含一系列獨立的實驗, 每個實驗都有成功、失敗兩種結(jié)果,成功的概率是恒定的,實驗持續(xù)到r次不成功,r為[正整數(shù)]。可以參考百度百科負二項分布,不過從這里開始,開始涉及到很深的數(shù)學(xué)只是背景,本人數(shù)學(xué)不會,但沒有因此而驕傲過,所以希望有數(shù)學(xué)的大牛來分享一下內(nèi)容。
最后展示一下分析的結(jié)果,
圖片.png

看起來相當不錯。大家可以嘗試。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容