2016-12-08 92 views
1

4個數據爲點陣圖我有一個像下面情節中的R

   H520KOR1 H520KOR2 H5202GyPHR1 H5202GyPHR2 
ILMN_1702609 5.916239 6.068699 4.910235 4.983025 
ILMN_1762631 5.490704 5.454779 4.573977 4.628981 
ILMN_2193175 5.730220 5.726268 6.222486 6.273563 
ILMN_3310451 4.955594 5.007212 4.423170 4.333526 

中的R矩陣我想繪製它以下列方式

please check plot here

我畫了這個在powerpoint中的圖片。我嘗試了幾種方法,但我錯過了一些東西。任何幫助將不勝感激。

EDIT

我從矩陣的前10行和dput()

> dput(dat) 
structure(c(5.91623892229345, 5.49070424526676, 5.73021963287428, 
4.9555939015656, 7.34200299329158, 4.49057379554289, 5.17555122512255, 
5.6535332613054, 4.96143970172796, 4.4791600551366, 6.06869857120224, 
5.45477925441301, 5.72626774546258, 5.00721151456707, 7.33658261931523, 
4.36058760303988, 5.13085555870237, 5.77523892720755, 4.96844107374241, 
4.41926414134707, 4.91023457951491, 4.57397741940793, 6.22248596066649, 
4.42317017555403, 7.95776070495557, 5.13499805485839, 4.39694778946656, 
4.80648887200906, 4.44717629932841, 5.25723605338541, 4.98302491117088, 
4.62898140897605, 6.27356272326665, 4.33352596469113, 7.9391551372836, 
5.13491596111887, 4.48130179704286, 4.90950199548828, 4.43674075246716, 
5.13877204607323), .Dim = c(10L, 4L), .Dimnames = list(c("ILMN_1702609", 
"ILMN_1762631", "ILMN_2193175", "ILMN_3310451", "ILMN_1808219", 
"ILMN_1703280", "ILMN_1705466", "ILMN_2135232", "ILMN_1839994", 
"ILMN_3234823"), c("H520KOR1", "H520KOR2", "H5202GyPHR1", "H5202GyPHR2" 
))) 

難道還有可能兩個重複的數據繪製成一條線,給定一個像data.frame以下

H520KOR1 control 
H520KOR2 control 
H5202GyPHR1 treated 
H5202GyPHR2 treated 

這將改變情節跟隨(而不是產生個人情節,以e我認爲將所有行的信息包含在一個情節中會更好,這樣可以進一步簡化解釋)。我只是在用ggplot2學習可能性。這在很大程度上有所幫助。謝謝。

enter image description here

+0

你想爲每行數據創建一個點圖嗎? – figurine

+0

如果我們可以爲每一行創建,那就太好了。最多有60行。 – cat

+0

謝謝你不使用barlotots。 –

回答

0
library(tidyverse) 

read.table(text="expression H520KOR1 H520KOR2 H5202GyPHR1 H5202GyPHR2 
ILMN_1702609 5.916239 6.068699 4.910235 4.983025 
ILMN_1762631 5.490704 5.454779 4.573977 4.628981 
ILMN_2193175 5.730220 5.726268 6.222486 6.273563 
ILMN_3310451 4.955594 5.007212 4.423170 4.333526", 
      stringsAsFactors=FALSE, header=TRUE) -> df 

對於GGPLOT2,這將更好地工作,爲 「長」 數據幀:

df <- gather(df, category, value, -expression) 

您可以繪製全部將它們放在一個(雖然,與他們的60顏色真的不行):

ggplot(df, aes(x=category, y=value, color=expression)) + 
    geom_point(size=3) + 
    scale_color_discrete(name=NULL) + 
    theme(legend.position="top") 

你可以facet他們(再次,我會刪除顏色,如果你確實有他們的60):

ggplot(df, aes(x=category, y=value, color=expression)) + 
    geom_point(size=3) + 
    facet_wrap(~expression) + 
    theme(legend.position="none") 

我們不知道你有什麼樣式或標籤要求,所以這是最好的一個可以用有限的信息做。

如果您確實擁有矩陣與數據框,那麼您需要先將其轉換並確保行名稱使其成爲列。您的數據的dput()將有助於我們說明如何做到這一點(如果需要)。

+0

非常感謝。這真的很棒。在瞭解ggplot2的可能性之後,我想改變劇情的樣子。請檢查原始線程。我用'dput()'添加了更多信息 – cat