2013-09-23 46 views
0

大家好,特别是所有R程序员,我都需要你的帮助。我正在尝试使std错误栏散点图![enter image description here] [1]但我无法管理它。到现在为止,我可以制作带有标签和45度角线的散点图(我也需要)。如果有人帮助我,或者在我现有的代码中添加一些对我非常有用的代码。散点图与std错误

我的代码

Dataset <- read.table("AvgDis.csv",header=TRUE, sep="", 
         na.strings="NA", dec=".", 
         strip.white=TRUE) 

plot(Dataset$True,Dataset$False, 
    xlim=c(0,100), ylim=c(0,100), 
    main="Average % of disorder", 
    xlab="True", ylab="False", 
    pch=19,col= "blue") 

text(Dataset$True,Dataset$False, 
    labels=Dataset$MotifId, 
    cex= 0.7, pos=3) 

abline(0,1) 

数据,我使用:

False  True  MotifId 
54.1666675 33.33333 aps 
35.2040825 48.57143 dbox 
44.3055575 94.44444 ken 
70.37037  60   mdm2 
1.6666675  0   met 
72.222225 100   ptk 
46.9212975 68.51852 scftrcp1 
55.5555575 70.83333 siah 
+0

std错误是什么? – dayne

+0

您试图输入图像,但不知何故被删除。平均值(x)或平均值(y)或相关系数或回归线的CI可能存在偏差,但您尚未说明偏差。 –

回答

2

首先,我要创建一个假的数据帧,因为你已经张贴你的数据使得不方便复制和粘贴。

# Make a fake dataset since it is inconvenient to copy & paste the data you show 
set.seed(13) 
False <- rnorm(10, mean=50, sd=10) 
True <- rnorm(10, mean=50, sd=10) 
MotifId <- letters[1:10] 
Dataset <- data.frame(False, True, MotifId) 

您需要以某种方式计算标准错误。让我们想象一下,所有的数据点都具有相同的标准误差:

Dataset$stderr <- 7 # This will recycle to the number of rows of Dataset 

现在创建您的情节,并添加误差线为arrow S,所建议的here

plot(Dataset$True,Dataset$False, 
    xlim=c(0,100), ylim=c(0,100), 
    main="Average % of disorder", 
    xlab="True", ylab="False", 
    pch=19,col= "blue") 
text(Dataset$True,Dataset$False, 
    labels=Dataset$MotifId, 
    cex= 0.7, pos=3) 
abline(0,1) 
arrows(x0=Dataset$True, y0=Dataset$False - Dataset$stderr, 
     x1=Dataset$True, y1=Dataset$False + Dataset$stderr, 
     angle=90, code=3, length=0.05) 

enter image description here

在长期来看,我认为最好是使用ggplot2数据可视化包

require(ggplot2) 
# Build the plot from layers 
p <- ggplot(Dataset, aes(x=True, y=False, label=MotifId)) + 
     geom_point() + 
     geom_text(, vjust=1, hjust=1) + 
     geom_errorbar(aes(ymin=False-stderr, ymax=False+stderr), width=1) + 
     geom_abline(slope=1, intercept=0) + 
     xlim(c(0, 100)) + 
     ylim(c(0, 100)) + 
     ggtitle("Average % of disorder") + 
     theme_bw() 
print(p) 

enter image description here

+0

感谢您的善意帮助:) – Paul85