2020 6/3 文章修正
ドットプロットは、異なるサイズと色のドットを用いて2つの定量情報を同時に表示するコンパクトな方法を提供するヒートマップのようなチャートである。この可視化方法は、特にシングルセルRNA-seq研究で人気があるにもかかわらず、ドットプロットを作成するために使用される既存のツールは、機能性と使いやすさの点で制限されている。
著者らは、シングルセルRNA-seqデータを含むあらゆるタイプの多面的なデータからドットプロットを生成するためのRパッケージであるFlexDotPlotを開発した。FlexDotPlotは、汎用性の高い使いやすいソリューションを提供する。FlexDotPlotパッケージには、インタラクティブなR Shinyアプリケーションも用意されており、R以外のユーザーでも、いくつかの調整可能なパラメータを用いて簡単にドットプロットを生成することができる。ソースコードと詳細なマニュアルは https://github.com/Simon-Leonard/FlexDotPlot で入手できる。Shinyアプリは、パッケージ内のスタンドアロンアプリケーションとして利用可能である。
インストール
ubuntu18.04LTSのR3.6.3でテストした。
git clone https://github.com/Simon-Leonard/FlexDotPlot.git
cd FlexDotPlot/
#Rに入る
> install.packages("devtools")
> devtools::install_local("./")
レポジトリにR markdownとhtmlのチュートリアルが含まれている。
テストラン
library(FlexDotPlot)
data("PBMC3K_example_data")
dot_plot(data.to.plot = PBMC3K_example_data, size_var = "pct.exp", shape.scale = 8)
dot_plot(data.to.plot = PBMC3K_example_data, col_var = "pct.exp", shape.scale = 20, color.breaks.number = 3)
final_plot <- grid.arrange(grob(), dotplot12, dotplot13,
dotplot14, ncol = 2, widths = c(1, 8), heights = c(1,8))
実行方法
データを読み込む。シングルセルの例ではないが、excelライクなデータフォーマット(wide data format形式またはスプレッドデータフォーマット)のファイル data.tsvを読み込み、tidy formatに変換して使用する例を示す。
ここでは4ゲノムの8つの遺伝子の有無を示した以下のようなタブ区切りファイルを読み込む。1行目はヘッダ(" "で囲む)、1列目が遺伝子名となる。2列目から5列目が各サンプルの各遺伝子の有無になり、それをamino acid identity (%)の高さで表している。
$ column -t data.tsv
"gene" "sample1" "sample2" "sample3" "sample4"
gene1 100 100 100 0
gene2 100 100 100 100
gene3 70 100 100 80
gene4 100 100 0 100
gene5 95 95 95 80
gene6 80 100 70 100
gene7 80 100 70 100
gene8 0 0 100 0
1、読み込み。
#Rへの読み込み
input=read.table(file="<path>/<to>/data.tsv", header=TRUE, sep="\t")
2、tidy data formatへの変換。ここではtidyrのgather関数を使い縦型のtidy dataに変換(*1)。
#tidyr
library(tidyr) #またはlibrary(tidyverse)
#ヘッダのサンプル名を指定する。sample1-4全て含めたいので順番に指定。
df <- gather(input, `sample1`, `sample2`, `sample3`, `sample4`, key = "sample", value = "a.a_homology")
head(df)
3、視覚化する。
dot_plot(data.to.plot = df, size_var = "a.a_homology", shape.scale = 4)
パラメータが決まったら、作図して保存する。
#pdfに保存
pdf(file="./output.pdf", width=12, height=4)
#作図
dot_plot(data.to.plot = df, col_var = "a.a_homology", shape.scale = 5, color.breaks.values = c(0,0.3,0.6,0.9))
#閉じる
dev.off()
チュートリアルには様々な作図条件が載っています。確認して下さい。
引用
FlexDotPlot: a universal and modular dot plot visualization tool for complex multifaceted data Simon Leonard, Antoine Rolland, Karin Tarte, Frédéric Chalmel, Aurélie Lardenois
bioRxiv, Posted April 04, 2020
参考
*1