10X空間轉(zhuǎn)錄組軌跡分析之SPATA

大家好紊搪,這一次我們來分享一下有關(guān)做10X空間轉(zhuǎn)錄組的分析軟件SPATA,其實(shí)關(guān)于10X空間轉(zhuǎn)錄組做軌跡分析的文章之前分享過一個(gè)全景,文章在10X空間轉(zhuǎn)錄組的軌跡分析耀石,其中用到的軟件是stlearn,我們放一張stlearn分析出來的圖

圖片.png

今天我們來分享另外一個(gè)軟件爸黄,SPATA滞伟,文章在Inferring spatially transient gene expression pattern from spatial transcriptomic studies揭鳞,我們還是先分享文獻(xiàn),最后分享示例代碼诗良。

Abstract

Spatial transcriptomic is a technology to provide deep transcriptomic profiling by preserving the spatial organization.(這個(gè)老生常談了)汹桦。Here, we present a framework for SPAtial Transcriptomic Analysis (SPATA, https://themilolab.github.io/SPATA), to provide a comprehensive characterization of spatially resolved gene expression, regional adaptation of transcriptional programs and transient dynamics along spatial trajectories.(運(yùn)用這個(gè)軟件來做空間軌跡分析鲁驶,講道理鉴裹,我很好奇!钥弯!)径荔。

Brief Communication(這個(gè)地方我們總結(jié)一下)

Deep transcriptional profiling of single cells by RNA-sequencing maps the cellular composition of tissue specimens regarding cellular origin, developmental trajectories and transcriptional programs(這是單細(xì)胞的優(yōu)勢),However, information determining the spatial arrangement of specific cell types or transcriptional programs are lacking and thus can only be predicted indirectly(空間信息的缺失)脆霎,which is a considerable drawback of this method.(也是眾所周知的缺點(diǎn))总处。空間組織結(jié)構(gòu)傳統(tǒng)的方式是用成像技術(shù)提供高精度的信息,但是同時(shí)檢測的基因和蛋白的數(shù)量非常少睛蛛,當(dāng)然鹦马,已經(jīng)有了一些新的空間組織檢測技術(shù),但受到空間分布細(xì)胞精度和深度的制約忆肾,Further, data integration, visualization and analysis of transcriptomic and spatial information remains challenging. Here, we present a software tool to provide a framework for integration of high-dimensional transcriptional data within a spatial context.這個(gè)軟件集友好的可視化界面荸频,分割或軌跡分析,提供了廣泛了不同分析方法客冈,In particular, we focus on transient changes of gene expression and aim to infer transcriptional programs that are dynamically regulated as a function of spatial organization.(這個(gè)軟件就是專門為10X空間轉(zhuǎn)錄組做準(zhǔn)備的)旭从。

In order to present an overview of possible analytic capabilities of the SPATA workflow,

圖片.png

generated spatial transcriptomic datasets from human cortex and human glioblastoma samples using the Visium technology (10X Genomics). The human cortex is separated into defined layers containing different types of neurons and cellular architecture(空間轉(zhuǎn)錄組數(shù)據(jù)是事先注釋好的),

  • In a first step, we combine shared-nearest neighbor clustering and spatial pattern recognition by an external tool(SPARK)in order to determine genes with a defined spatially resolved expression pattern.(這個(gè)地方類似于Seurat計(jì)算空間差異基因)场仲。We found that the cortical layering is accurately reflected by our clustering approach(這個(gè)很自然)和悦。In order to gain insights into the spatial organization we provided a tool to compute the spatial distance within the defined layers or correspondent clusters. An increasing distance within individual clusters allows to differentiate between narrowly related or a widespread dispersion of spots within the cluster.(計(jì)算空間距離,這個(gè)在我分享的文章空間轉(zhuǎn)錄組細(xì)胞類型的距離分析之二---代碼實(shí)現(xiàn)渠缕,提到過,只不過注意鸽素,這里計(jì)算的是cluster內(nèi)部的距離)。
  • Next, the spatial overlap of transcriptional programs or gene expression was analyzed using a Bayesian approach有關(guān)貝葉斯的知識大家可以參考我的文章貝葉斯分類器(10X單細(xì)胞和10X空間轉(zhuǎn)錄組的基礎(chǔ)算法)),resulting in an estimated correlation which quantifies the identical arrangement of expression in space.
  • In a further step, we aimed to analyze dynamic changes, which were annotated using pseudotime estimation or RNA-velocity.(軌跡推斷)亦鳞。We directly implemented the pseudotime inference from the monocle3 package, but also allow the integration of any other tool such as “l(fā)atent-time” extracted from RNA-velocity (scVelo). (看來這個(gè)軟件的軌跡推斷需要借助單細(xì)胞的軌跡分析軟件)馍忽。Another option for dynamic gene expression analysis is the detection of defined transcriptional programs along a defined trajectory.(基因的動態(tài)表達(dá))。我們在方法中重點(diǎn)關(guān)注一下這個(gè)蚜迅。
  • Moreover, we provide the opportunity to screen for gene expression or transcriptional programs which transiently change along predefined trajectories by modelling gene expression changes in accordance to various biologically relevant behaviors.軌跡分析的轉(zhuǎn)變基因)舵匾。
    圖片.png

    圖片.png

    這個(gè)地方我們稍微討論一下
  • 第一步,SPARK識別空間pattern谁不,這個(gè)pattern需要人為指定坐梯,看來這個(gè)劃分了3個(gè)pattern
  • 第二步,各個(gè)pattern在空間上的映射刹帕,這個(gè)地方主要對各個(gè)pattern做一下富集吵血,看看區(qū)域分布
  • 第三步谎替,Copy-number analysis of the sample and cluster annotation(空間注釋)
  • 第四步,Comparison of recognized pattern with known gene expression classification (識別模式與已知基因表達(dá)分類的比較 蹋辅,看看是否一致)
  • 第五步钱贯,模式中顯著表達(dá)的途徑的表達(dá)(就是顯著富集的通路)
  • 第六步,腫瘤區(qū)域的空間軌跡分析侦另。
  • 第七步秩命,也是最為重要的一步,Change of z-scored geneset expression along the trajectory (i) and marker genes of microenvironmental alterations and inflammation關(guān)鍵基因的變化)褒傅。

看來對空間上的動態(tài)變化基因還是要引起重視弃锐。不過這里空間SPOT做inferCNV有待商榷。

還有一個(gè)很有意思的地方殿托,Thus, we were able to show 116 that immune related genes from myeloid cells and reactive astrocytes were localized in a “glial-scars” resembling structure, sharply separating normal brain from tumor regions Figure 2h. We observed a transient increase of macrophage and microglia activation directed towards the tumor boarder,這個(gè)方法是不是值得一試呢霹菊?

Methods支竹,我們關(guān)注一下其中的重點(diǎn)

Modeling of transient gene expression along spatial trajectories

圖片.png

Spatial distance measurement

圖片.png

Spatial overlap and correlation analysis

圖片.png

我們來分享一下示例代碼

這里的示例代碼很多旋廷,我們關(guān)注一下軌跡部分的代碼

Vsiualization
Spatial trajectories
Segmentation
DE - Analysis

空間軌跡推斷

With spatial trajectory analysis SPATA introduces a new approach to find, analyze and visualize differently expressed genes and gene-sets in a spatial context. While the classic differential gene expression analyzes this differences between experimental groups as a whole it neglects changes of expression levels that can only be seen while maintaining the spatial dimensions. Spatial trajectories allow to answer questions that include such a spatial component. E.g.:

  1. In how far do expression levels change the more we move towards a region of interest?
  2. Which genes follow the same pattern along these paths?

The spatial trajectory tools provided in SPATA enable new ways of visualization as well as new possibilities to screen for genes, gene-sets and patterns of interest.

load package

[library](https://rdrr.io/r/base/library.html)(SPATA)
[library](https://rdrr.io/r/base/library.html)(magrittr)
[library](https://rdrr.io/r/base/library.html)(ggplot2)
[library](https://rdrr.io/r/base/library.html)(patchwork)

load spata-object

spata_obj <- [loadSpataObject](https://themilolab.github.io/SPATA/reference/loadSpataObject.html)(input_path = "data/spata-obj-trajectory-analysis-tumor-example.RDS")

Draw trajectories

Spatial trajectories of a sample in a given spata-object can be drawn interactively using the function createTrajectories() as shown in the example below. createTrajectories() opens a mini-shiny application. This app allows one the one hand to investigate the sample with regards to spatial gene expression like plotSurfaceInteractive() does and on the other hand to draw trajectories through the areas of interest in four easy steps.

library(SPATA)
# open interactive application
spata_obj <- [createTrajectories](https://themilolab.github.io/SPATA/reference/createTrajectories.html)(object = spata_obj)
1. Drawing

Draw the trajectory interactively by clicking on the locations where you want the start and endpoints to be. If you click more than two times the trajectory is divided into sub-trajectory parts which will be displayed by subsequent plotting functions. Hence, it makes sense to stop everytime where you would expect a change as this will be highlighted by the transition from part to the subsequent one.

Figure 1.1. Interactive trajectory drawing

Figure 1.1. Interactive trajectory drawing

2. Highlighting

If start- and end-points are set adjust the trajectory width to and click on ‘Highlight’.

Figure 1.2. Highlight the trajectory

Figure 1.2. Highlight the trajectory

3. Naming

If you are satisfied with your trajectory enter a valid trajectory name and - if you want - a comment.

4. Saving

Click on ‘Save’ and on ‘Close application’ in order to return the updated spata-object.

Trajectories are stored inside the object itself. Therefore createTrajectories() returns an updated version of the object that was specified as the function’s input now containing the additional trajectories.

To obtain all trajectory names that have been drawn and saved in your spata-object use getTrajectoryNames(). Depending on the number of samples specified it returns a character vector or a list of such.

get trajectory names

getTrajectoryNames(object = spata_obj)
## [1] "tumor-layers"

Visualize trajectories

In order to visualize specific trajectories make use of plotTrajectory().

plotTrajectory(object = spata_obj,
               trajectory_name = "tumor-layers",
               color_to = "seurat_clusters",
               pt_size = 1.7,
               pt_clrp = "npg",
               display_image = FALSE) +
               theme(legend.position = "top") +

plotTrajectory(object = spata_obj,
               trajectory_name = "tumor-layers",
               color_to = "pseudotime",
               pt_size = 1.7,
               smooth = TRUE,
               smooth_span = 0.0125,
               display_image = FALSE) +
               theme(legend.position = "top")
Figure 2.1. Surface related visualization of the trajectory

Figure 2.1. Surface related visualization of the trajectory

Visualize trajectory trends

Trajectory trends via lineplots

To display the trend of certain variables along a trajectory via lineplots use one of the following three functions:

A call to one of those three functions will return a smoothed lineplot where the direction of the trajectory is mapped onto the x-axis and the values of the chosen aspects are mapped onto the y-axis. All functions follow the same concept and share the majority of their arguments. Still, they feature slight differences given the nature of their aspects to display.

The following three arguments have to be set in order to specify the trajectory that is to be analyzed:

  • object
  • trajectory_name
  • of_sample (if more than one sample exists in the object, else it can be neglected)

The way values are smoothed and displayed can be manipulated via:

  • smooth_method
  • smooth_span
  • smooth_se

Features along trajectories

Specify the features of interest via the argument features. Note that the function will compute the mean of all points on the axis orthogonal to the trajectory’s direction. As only numeric variables allow for such computation displaying the trend of categorical variables (e.g. cluster) is not possible via lineplots.

plotTrajectoryFeatures(object = spata_obj,
                       trajectory_name = "tumor-layers",
                       features = "pseudotime",
                       smooth_method = "loess",
                       smooth_span = 0.2,
                       smooth_se = TRUE)</pre>
圖片.png

Figure 3.1. Visualization of ontinuous features along a trajectory

In order to plot discrete features use `plotTrajectoryFeaturesDiscrete().

plotTrajectoryFeaturesDiscrete(object = spata_obj,
                               trajectory_name = "tumor-layers",
                               discrete_feature = "seurat_clusters",
                               clrp = "npg",
                               display_trajectory_parts = FALSE)
Figure 3.2. Visualization of discrete features along a trajectory

Figure 3.2. Visualization of discrete features along a trajectory

Genes and gene-sets along trajectories

Specify the genes or gene-sets of interest by using the respective functions and arguments.

# gene-set names
genes_of_interest <- [c](https://rdrr.io/r/base/c.html)("CALM1", "VIM", "GFAP")

# plot lineplot
plotTrajectoryGenes(object = spata_obj,
                    trajectory_name = "tumor-layers",
                    genes = genes_of_interest,
                    smooth_span = 0.2,
                    smooth_se = TRUE)
Figure 3.3. Visualization of gene expression along a trajectory

Figure 3.3. Visualization of gene expression along a trajectory

plotTrajectoryGeneSets(
  object = spata_obj,
  trajectory_name = "tumor-layers",
  gene_sets = "HM_HYPOXIA",
  display_trajectory_parts = FALSE) + # results in missing vertical lines 
  ggplot2::theme(legend.position = "top")
image

Analyze & model trajectories

To find variables that follow a certain trend along the trajectory of interest use assessTrajectoryTrends(). It fits the trajectory-trends of all specified variables to a variety of patterns and assesses their fit by calculating the area under the curve of the residuals.

all_genes <- getGenes(spata_obj)
all_gene_sets <- getGeneSets(spata_obj)

# obtain an assessed trajectory data.frame for all genes
atdf_gs <- assessTrajectoryTrends(object = spata_obj,
                                  trajectory_name = "tumor-layers",
                                  variables = all_genes)

# obtain an assessed trajectory data.frame for all gene-sets
atdf_gene_sets <- assessTrajectoryTrends(object = spata_obj,
                                         trajectory_name = "tumor-layers",
                                         variables = all_gene-sets)

# output example
atdf_gs
圖片.png

The resulting data.frame contains the evaluation of all fits for all provided variables. plotTrajectoryFit() visualizes the fitting results for a particular variable.

# compare the trend of a variable to different models
plotTrajectoryFit(object = spata_obj,
                  trajectory_name = "tumor-layers",
                  variable = "GFAP",
                  display_residuals = TRUE) +
  ggplot2::theme(legend.position = "top")
Figure 4.1. Visulization of the fitting results

Figure 4.1. Visulization of the fitting results

To get a summary of your trajectory assessment use examineTrajectoryAssessment() which displays the distribution of all areas under the curve measured. Use filterTrend() or a combination of dplyr::filter() and dplyr::pull() on your assessed trajectory data.frame in order to extract the variables following a specific trend to a certain quality-degree.

# example 1: extract all variables that follow the linear descending trend while moving towards the hypoxic area (See Figure 2.1)
# with an auc-evaluation equal to or lower than 2
descending_gene_sets <-
  filterTrends(atdf = atdf_gene_sets,
               limit = 2,
               trends = [c](https://rdrr.io/r/base/c.html)("Linear descending"),
               variables_only = FALSE) # return a data.frame

descending_gene_sets
圖片.png
# example 2: extract variables that featured a peak along the trajectory 
# with auc-evaluation equal to or lower than 4
peaking_genes <- filterTrends(atdf = atdf_gs,
                              limit = 4,
                              trends = c("Early peak", "Late peak", "One peak"),
                              variables_only = TRUE) # return a vector of variables

head(peaking_genes)
## [1] "CKB"    "METRN"  "TMSB4X" "LPL"    "CALM1"  "ITGA3"

Trajectory trends via heatmaps

Displaying the expression trends of too many variables in a lineplot gets unclear quite rapidly. In order to deal with several variables use plotTrajectoryHeatmap(). While the trajectory’s directory is still displayed from left to right the dynamic of the gene-sets’ expression values is now displayed by the gradual change of a row’s color instead of a line’s slope in a lineplot. The advantage of using heatmaps to display dynamic expression changes along trajectories becomes obvious when the number of variables to display rises.

descending_gene_sets <- dplyr::pull(descending_gene_sets, variables)

plotTrajectoryHeatmap(object = spata_obj,
                      trajectory_name = "tumor-layers",
                      variables = descending_gene_sets,
                      arrange_rows = "maxima",
                      show_row_names = FALSE, # gene set names are long...
                      split_columns = TRUE,
                      smooth_span = 0.5)
Figure 4.2) A heatmap displaying linear descending trends

Figure 4.2) A heatmap displaying linear descending trends

plotTrajectoryHeatmap(object = spata_obj,
                      trajectory_name = "tumor-layers",
                      variables = peaking_genes,
                      arrange_rows = "maxima",
                      show_row_names = FALSE, # gene set names are long...
                      split_columns = TRUE, # splits the heatmap 
                      smooth_span = 0.5)
Figure 4.3. A heatmap displaying the gradual change of peaking genes

Figure 4.3. A heatmap displaying the gradual change of peaking genes

這個(gè)方法光看示例好像沒什么優(yōu)勢,需要在實(shí)際中檢驗(yàn)一下了礼搁,感覺整體效果不如stlearn

圖片.png

生活很好饶碘,有你更好

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者叹坦。
  • 序言:七十年代末熊镣,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子募书,更是在濱河造成了極大的恐慌绪囱,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,324評論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件莹捡,死亡現(xiàn)場離奇詭異鬼吵,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)篮赢,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,356評論 3 392
  • 文/潘曉璐 我一進(jìn)店門齿椅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人启泣,你說我怎么就攤上這事涣脚。” “怎么了寥茫?”我有些...
    開封第一講書人閱讀 162,328評論 0 353
  • 文/不壞的土叔 我叫張陵遣蚀,是天一觀的道長。 經(jīng)常有香客問我,道長芭梯,這世上最難降的妖魔是什么险耀? 我笑而不...
    開封第一講書人閱讀 58,147評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮玖喘,結(jié)果婚禮上甩牺,老公的妹妹穿的比我還像新娘。我一直安慰自己累奈,他們只是感情好贬派,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,160評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著费尽,像睡著了一般赠群。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上旱幼,一...
    開封第一講書人閱讀 51,115評論 1 296
  • 那天,我揣著相機(jī)與錄音突委,去河邊找鬼柏卤。 笑死,一個(gè)胖子當(dāng)著我的面吹牛匀油,可吹牛的內(nèi)容都是我干的缘缚。 我是一名探鬼主播,決...
    沈念sama閱讀 40,025評論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼敌蚜,長吁一口氣:“原來是場噩夢啊……” “哼桥滨!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起弛车,我...
    開封第一講書人閱讀 38,867評論 0 274
  • 序言:老撾萬榮一對情侶失蹤齐媒,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后纷跛,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體喻括,經(jīng)...
    沈念sama閱讀 45,307評論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,528評論 2 332
  • 正文 我和宋清朗相戀三年贫奠,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了唬血。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,688評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡唤崭,死狀恐怖拷恨,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情谢肾,我是刑警寧澤腕侄,帶...
    沈念sama閱讀 35,409評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響兜挨,放射性物質(zhì)發(fā)生泄漏膏孟。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,001評論 3 325
  • 文/蒙蒙 一拌汇、第九天 我趴在偏房一處隱蔽的房頂上張望柒桑。 院中可真熱鬧,春花似錦噪舀、人聲如沸魁淳。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,657評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽界逛。三九已至,卻和暖如春纺座,著一層夾襖步出監(jiān)牢的瞬間息拜,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,811評論 1 268
  • 我被黑心中介騙來泰國打工净响, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留少欺,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,685評論 2 368
  • 正文 我出身青樓馋贤,卻偏偏與公主長得像赞别,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子配乓,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,573評論 2 353

推薦閱讀更多精彩內(nèi)容