0

ggplot2 で作成されたヒートマップの y 軸の並べ替えに関する Q&A をたくさん読んだので、さらに別の書き込みをするのは気分が悪くなりますが、私が望むものを達成できないようです。(これはおそらく、私が R に不慣れで、用語や仕組みを理解し始めたばかりだからです。) 事前に助けてくれてありがとう!

遺伝子濃縮分析用のヒートマップを生成しようとしています。データは次の形式の .csv ファイルとしてインポートされます: Gene Category Description Variable1 Variable2 Variable3. したがって、各行には遺伝子、遺伝子が属するカテゴリ (各カテゴリには複数の遺伝子があります)、遺伝子カテゴリの説明、各サンプルに関連付けられた数値 (3 列、各サンプルの値) がリストされます。

私がやりたいのは、遺伝子ごとに値をプロットしながら、y 軸をカテゴリごとに並べることです。(そして、これにラベルを付ける方法は素晴らしいでしょう!) 以下は、これまでのコードです.... Y軸をアルファベット順に並べているようです。

library(ggplot2)
library(reshape2)
GO_sum <- read.csv("~/R/FuncEnr/GO_sum.csv", header=T)
GO_sum.m <- melt(GO_sum, id = c("Gene", "Category", "Description"), na.rm = FALSE)


(GOplot <- ggplot(GO_sum.m, aes(variable, Gene)) + 
    geom_tile(aes(fill = value), colour = "white") + 
    scale_fill_gradient2(low = "darkred", high = "darkblue", guide="colorbar"))

ありがとうございました!

データの例を次に示します (コピーして貼り付け、.csv として保存)。

Gene    Category    Description s1  s2  s3
G0001   GO:0000036  acyl carrier activity   -1.357472549    -1.357472549    -0.703587499
G0002   GO:0000103  sulfate assimilation    0   -0.761925294    -1.772268589
G0003   GO:0000104  succiNAte dehydrogeNAse activity    -1.192800096    -1.192800096    -1.192800096
G0014   GO:0000160  two-component sigNAl transduction system (phosphorelay) 0   -1.772268589    -1.192800096
G0005   GO:0000287  magnesium ion binding   -1.772268589    -1.772268589    -1.192800096
G0006   GO:0000287  magnesium ion binding   -1.192800096    -1.192800096    -1.164082367
G0007   GO:0000287  magnesium ion binding   -1.132072566    -1.772268589    -1.772268589
G0008   GO:0000287  magnesium ion binding   -1.452170577    0   -1.192800096
G0009   GO:0000287  magnesium ion binding   0   -1.772268589    -1.192800096
G0083   GO:0003676  nucleic acid binding    -1.192800096    -1.192800096    -1.772268589
G0044   GO:0003676  nucleic acid binding    -0.587905946    -0.363837338    -0.843984355
G0045   GO:0003676  nucleic acid binding    0.212339083 0.212339083 0.276358685
G0046   GO:0003676  nucleic acid binding    -0.374137972    -0.761925294    -0.761925294
G0147   GO:0003677  DNA binding 0   0   0
G0048   GO:0003677  DNA binding -1.192800096    0   -1.192800096
G0049   GO:0003677  DNA binding 0.530699113 -0.340270054    -0.485584696
G0050   GO:0003677  DNA binding -1.192800096    -0.374137972    -0.374137972
4

1 に答える 1