三元圖總結(jié)

簡(jiǎn)介

三元圖(Ternary plot)1是描述三個(gè)變量之和為常數(shù)的質(zhì)心圖,其核心原理是:

  1. 等邊三角形內(nèi)任意一點(diǎn)到三角形三邊的距離之和等于其中一邊上的高(常數(shù));

  2. 過等邊三角形內(nèi)任意一點(diǎn)分別向三條邊作平行線,按順時(shí)針方向或逆時(shí)針方向讀取平行線在各邊所截取之三條線段,三條線段之和等于該等邊三角形任一邊之長(常數(shù))。

在微生物組組領(lǐng)域,我們主要利用的是基于相位網(wǎng)格的三元圖,其特點(diǎn)是每一種成分在相應(yīng)等邊三角形的頂點(diǎn)的比例為100%,在其對(duì)面的線為0%,將零點(diǎn)線和頂點(diǎn)按比例劃分,用以估計(jì)各成分的含量。如圖1:y對(duì)面的底線代表落在底線上的所有點(diǎn)在y中占比為0,隨著平行線逐漸靠近頂點(diǎn),落在相應(yīng)平行線上的點(diǎn)在y中的占比越來越高。

圖1. 在y組中的占比逐漸增長

在解讀三元圖時(shí),我們可以通過點(diǎn)的位置快速獲得其在三個(gè)分組中的相對(duì)比例信息:目標(biāo)點(diǎn)越靠近一角的頂點(diǎn),說明他在相應(yīng)的分組中比例越高;反之其相對(duì)比例就越低。根據(jù)圖1,經(jīng)過點(diǎn)的平行線在等邊三角形兩邊的截距代表該點(diǎn)在對(duì)應(yīng)頂點(diǎn)分組的占比,因此可以得出該點(diǎn)的在三個(gè)分組中的占比情況。如圖2:過綠色點(diǎn)分別向三條邊做平行線,然后按逆時(shí)針方向依次讀取平行線在三條邊的截距約為(0.33, 0.33, 0.33),因此該點(diǎn)在x, y, z 三個(gè)組分中的占比為0.33, 0.33, 0.33;依此原則可得出,紅點(diǎn)占比為0.1,0.2,0.7;藍(lán)點(diǎn)占比為0.2,0.7,0.1;該結(jié)果跟我們的作圖代碼是相符的。

data <- data.frame( x = c(0.33, 1, 2),
                    y = c(0.33, 2, 7),
                    z = c(0.33, 7, 1))

ggtern(data, aes(x = x, y = y, z = z)) + 
  geom_point(size = 3, alpha = 0.5, color = c("green", "red", 'navy')) + 
  geom_mask() +
  annotate(geom  = 'text',
           x     = c(0.33, 1, 2),
           y     = c(0.33, 2, 7),
           z     = c(0.33, 7, 1),
           vjust = c(1.5, 1.5, 1.5),
           angle = c(0, 30, 60),
           label = c("(0.33, 0.33, 0.33)", "(0.1, 0.2, 0.7)", "(0.2, 0.7, 0.1)" ),
           color = c("green", "red", 'navy')) + 
  theme_rgbw() + geom_crosshair_tern(size = 1) 

圖2. 各點(diǎn)在x, y , z 中的占比

在微生物多樣性實(shí)際分析中,由于OUTs數(shù)目繁多,我們并不需要獲得如此精確的占比情況。一般來說,三元圖不同的點(diǎn)代表不同的OTUs(其他分類水平),點(diǎn)的大小代表該OTUs的平均豐度(一般需要log2, log10等轉(zhuǎn)換)。不僅如此,還可以對(duì)OTUs在各微環(huán)境中的豐度數(shù)據(jù)進(jìn)行統(tǒng)計(jì)檢驗(yàn)后,得出各OTU分別在哪種微環(huán)境中顯著富集,此時(shí)三元圖不僅表現(xiàn)出OTUs或者物種在微環(huán)境中的相對(duì)比例,還包含顯著性統(tǒng)計(jì)結(jié)果,它打破了火山圖或韋恩圖兩兩比較的結(jié)果,總共展示了6次兩兩比較的結(jié)果,即每個(gè)組的富集的情況是相對(duì)于其他兩組的。

實(shí)例解讀

例1. 不同區(qū)域的分布差異2

圖3. 三元圖展示OTUs的k空間特異性(Kumar, Manoj et al., 2017)

圖片描述:

三元圖展示不同區(qū)域(Bulk soil, Rhizosphere soil, Endosphere)的樣本的群落結(jié)構(gòu)在門水平上的差異情況,每個(gè)圓點(diǎn)代表一個(gè)OTU,OTU的大小、顏色和位置分別代表其相對(duì)豐度、菌門水平名稱和分組情況。

Distribution of OTUs and phyla across different compartments. (A) Ternary plot of all OTUs plotted based on the compartment specificity. Each circle represents one OTU. The size, color and position of each OTU represents it relative abundance, bacterial phyla and affiliation of the OTU with different compartments, respectively.

圖注描述注意事項(xiàng):

  1. 總述圖表展示的信息:三元圖展示OTUs的空間特異性;

  2. 分條敘述圖片中各元素代表什么:每個(gè)圓點(diǎn)代表一個(gè)OTU,OTU的大小、顏色和位置分別代表其相對(duì)豐度、菌門水平名稱和分組情況。

文中的圖片解讀:

Bacterial community structures were clearly different in the different compartments at the phylum level.These differences were mainly driven by strong relative enrichment of Firmicutes in the endosphere-derived sequence data sets, compared to their very low abundances in the bulk and rhizosphere soils. The relative abundances of Proteobacteria and Bacteroidetes increased progressively from bulk to rhizosphere soil to the endosphere, with a concomitant decrease in those of candidate division AD3, Gemmatimonadetes and Chloroflexi, which collectively constituted <4% of endosphere communities.

主要描述了比較突出的情況,如豐度較高、規(guī)律性變化或明顯聚集在某區(qū)域的屬。

例2. 不同區(qū)域的分布差異3

圖4. 三元圖展示不同取樣區(qū)域中特異富集的OTUs Rafal Zgadzaj et al., 2016)

圖片描述:

  1. 最上方的“Wild-type”和“Mutants”指明材料類型
  2. 三個(gè)頂點(diǎn)分別為三個(gè)區(qū)域,并在括號(hào)中指出顯著富集的OUT數(shù)量
  3. 點(diǎn)的大小代表三組樣品的平均相對(duì)豐度
  4. 通過顏色指示顯著富集情況:Soil = 土色, rhizosphere = 橘黃色,Root = 綠色,灰色 = 兩兩比較中未全部顯著富集的(均未富集,只相對(duì)其中一個(gè)分組富集)。

Ternary plots depicting compartment RA of all OTUs (>5 ‰) for WT samples (A; WT; n = 73) and mutant samples (B; nfr5-2, nfr5-3, nin-2, and lhk1-1; n = 118) across three soil batches (CAS8–CAS10). Each point corresponds to an OTU. Its position represents its RA with respect to each compartment, and its size represents the average across all three compartments. Colored circles represent OTUs enriched in one compartment compared with the others (green in root, orange in rhizosphere, and brown in root samples). Aggregated RAs of each group of enriched OTUs (root-, rhizosphere- and soil-enriched OTUs) in each compartment for the WT samples (C; WT; n = 73) and mutant samples (D; nfr5-2, nfr5-3, nin-2, lhk1-1; n = 118) are shown. In each compartment, the difference from 100% RA is explained by OTUs that are not significantly enriched in a specific compartment.

總結(jié):

該圖在例1的基礎(chǔ)上添加的顯著性差異比較的結(jié)果,包含了6次兩兩比較和三次韋恩圖比較的結(jié)果,信息高度概括。同時(shí),作者還加入了相對(duì)豐度的箱式圖強(qiáng)化視覺信息輸出;此外,通過與B圖的橫向比較相同的色系,明顯的分布差異,一目了然。

繪圖實(shí)戰(zhàn)

由于前期數(shù)據(jù)處理是三元圖主要的難點(diǎn),所以在這里將數(shù)據(jù)處理和可視化分開,使用時(shí)可以隨時(shí)檢查bug位置,便于使用。

環(huán)境設(shè)置

本教程需要在R語言環(huán)境下運(yùn)行,推薦在RStudio界面中學(xué)習(xí)。目前測(cè)試版本為:Windows 7環(huán)境,R 3.6.3和 RStudio 1.2.5033。理論上Mac、Linux系統(tǒng),以及R或RStudio的更新版本是兼容的,但并沒有廣泛測(cè)試,有問題歡迎自行解決并在群在與同行分享經(jīng)驗(yàn)。

按需求安裝,沒必要每次都運(yùn)行該安裝代碼。

if (!requireNamespace("tidyverse", quietly = TRUE))
  install.packages("tidyverse")

if (!requireNamespace("ggtern", quietly = TRUE))
  install.packages("ggtern")

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

if (!requireNamespace("edgeR", quietly = TRUE))
  BiocManager::install("edgeR")

數(shù)據(jù)處理

otu_table數(shù)據(jù)源:MicrobiomeStatPlot項(xiàng)目中的示例數(shù)據(jù)。

函數(shù)data_clean參數(shù)介紹:

  • otu: otu_table
  • design: 實(shí)驗(yàn)設(shè)計(jì)信息,樣品信息的列名設(shè)置為samples,分組信息列名設(shè)置為group
  • type: otu_table 類型;如果是絕對(duì)豐度,一定要注明。
  • threshold: 相對(duì)豐度閾值,希望丟棄(獲取)的相對(duì)豐度大小
  • times: 點(diǎn)的倍數(shù)變化,主要跟可視化有關(guān),如果結(jié)果圖中的legend全是小數(shù),可以通過倍數(shù)變化將其轉(zhuǎn)變?yōu)檎龜?shù),也可以在可視化時(shí)自己調(diào)整,不影響其傳輸?shù)呢S度相對(duì)大小信息。
otu <- read.delim("otutab.txt", header = T, row.names = 1)
design <- data.frame(
  samples = colnames(otu),
  group = rep(c("KO", "WT", "OE" ),each = 6))

otu_tern <- data_clean(otu, "absolute", times = 100, design = design)

ggtern可視化

ggtern 是Nicholas Hamilton開發(fā)的,用于創(chuàng)建三元圖的ggplot2的擴(kuò)展包,詳細(xì)參數(shù)和用法見官方說明文檔

library(ggtern)
p <- ggtern(data = otu_tern, 
            aes(x = KO, y = OE, z = WT)) + 
  geom_mask() + 
  geom_point(aes(size = size), 
             alpha = 0.8, show.legend = TRUE) +
  scale_size(range = c(0, 6)) +
  # set legend
  guides(colour = "none") +
  theme_bw() +
  theme(axis.text = element_blank(), 
        axis.ticks = element_blank())
p

圖5. 三元圖展示OTUs的實(shí)驗(yàn)分組特異性

圖片描述:

三元圖展示不同處理組(KO, OE, WT)的樣本的群落結(jié)構(gòu)在OTUs上的豐度差異情況,每個(gè)圓點(diǎn)代表一個(gè)OTU,OTU的大小和位置分別代表其相對(duì)豐度和分組情況。

圖注描述注意事項(xiàng):

由于該圖中并未全部展示所有OTUs,所以在描述的時(shí)候,最好對(duì)數(shù)據(jù)篩選的參數(shù)進(jìn)行描述:

  1. 相對(duì)豐度閾值
  2. 點(diǎn)大小對(duì)應(yīng)的平均相對(duì)豐度的倍數(shù)變化

從圖中可以看到KO(基因敲除,knock-out)組與OE(過表達(dá),over-expression)和WT(野生型,wild-type)組存在豐度差異,即基因的有無可對(duì)微生物群落的豐富度引起變化。

對(duì)部分OTUs著色

圖5能夠展示的信息和按top豐度著色后的可視化方案是一致的,但敘述時(shí)可以像圖3一樣著重介紹突出情況,比如豐度較高的OTUs有那些,富集情況很特殊的有哪些。

函數(shù)sub_OTU參數(shù)介紹:

  • data: otu_table
  • rank: 希望進(jìn)行著色的豐度排名,推薦10個(gè)。如果超過10個(gè),則需要自己制定配色方案。
plot_data <- top_OTUs(otu_tern, rank = 10)

# 配色方案
platte <- c('#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99',
            '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a')

p <- ggtern(data = otu_tern, 
            aes(x = KO, y = OE, z = WT)) + 
  geom_mask() + # 可將超出邊界的點(diǎn)正常顯示出來
  geom_point(data = plot_data[[2]], aes(size = size), color = "grey",
             alpha = 0.8, show.legend = FALSE) +
  geom_point(data = plot_data[[1]], aes(size = size, color = OTUs), 
             show.legend = TRUE) +
  scale_colour_manual(values = platte) +
  scale_size(range = c(0, 6)) +
  # legend
  guides(size = "none") +
  theme_bw() +
  theme(axis.text = element_blank(), 
        axis.ticks = element_blank())
p

圖6. 三元圖展示OTUs的實(shí)驗(yàn)分組特異性

圖片描述:

三元圖展示不同處理組(KO, OE, WT)的樣本的群落結(jié)構(gòu)在OTUs上的豐度差異情況,每個(gè)圓點(diǎn)代表一個(gè)OTU,OTU的大小、顏色和位置分別代表其相對(duì)豐度、OUTs名稱和分組情況。 值得注意的是,紅色原點(diǎn)所代表的ASV_5在KO組中豐度幾乎為0,但在WT和OE均有相對(duì)較高的豐度。

富集顯著性分析

除了上面直接展示OTUs在不同分組中的豐度富集情況,還可以通過顯著性富集分析,獲得在不同分組中顯著富集的OTUs,最后進(jìn)行可視化(例2)。

enrich_index <- enrich_data(otu, design, group, p.value = 0.5)

plot_data <- merge(otu_tern, enrich_index, by = "OTUs", all.x = TRUE)
p <- ggtern(data = plot_data, 
       aes(x = KO, y = OE, z = WT)) + 
  geom_mask() + # 可將超出邊界的點(diǎn)正常顯示出來
  geom_point(aes(size = size, color = enrich),
             alpha = 0.8) + 
  guides(size = "none") +
  theme_bw() +
  theme(axis.text = element_blank(), 
        axis.ticks = element_blank())
p

圖7. 三元圖展示富集OTUs

圖片描述:

除了圖6中的信息外,該圖還展示了在KO, OE, WT三個(gè)分組中,分別相對(duì)于另外兩個(gè)分組顯著性富集的OTUs。

圖注描述注意事項(xiàng):

由于該圖中并未全部展示所有OTUs,所以在描述的時(shí)候,最好對(duì)數(shù)據(jù)統(tǒng)計(jì)分析過程的參數(shù)進(jìn)行描述:

  1. 相對(duì)豐度閾值
  2. 點(diǎn)大小對(duì)應(yīng)的平均相對(duì)豐度的倍數(shù)變化
  3. adjust.method
  4. p.value

Reference

1. wikipedia. wikipedia (2020).

2. Kumar, M. et al. Plants assemble species specific bacterial communities from common core taxa in three arcto-alpine climate zones. Frontiers in Microbiology 8, (2017).

3. Zgadzaj, R. et al. Root nodule symbiosis in lotus japonicus drives the establishment of distinctive rhizosphere, root, and nodule bacterial communities. Proc Natl Acad Sci U S A 113, E7996–E8005 (2016).

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

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