[英]Graphs using ggplot2
I have troubles trying to use ggplot2 package. 我在尝试使用ggplot2软件包时遇到了麻烦。 All the graphs I got are empty 我得到的所有图都是空的
ggplot(data=dataa,aes(x=Description, y=RPKM,fill=Condition)) +
geom_bar(position="dodge",stat="identity")
dataa
is a piece of a bigger data frame like this: dataa
是更大的数据框架的一部分,如下所示:
Description Tissue Condition RPKM
re brain obese 34
re1 brain Fit 23
re2 brain Slim 67
any idea what I'm doing wrong? 知道我在做什么错吗?
real data i have : 我有真实数据:
Description Tissue Condition RPKM
peptidase Brain Obese 0.5
protein Brain Obese 1.4
Glucagon Brain Fit 0.06
kinase Brain Fit 0.9
transporter Brain Obese 4.8
Secretogran Brain Slim 87.2
Script: 脚本:
tissues<-factor(unique(RPKMl123upslim$Tissue))
for (n in 1:6) {
i=c(0,108,216,324,432,540)
#datos<-data.frame(RPKMl123upslim[(i[n]+1):(i[n]+108),])
View(datos)
ggplot(data=datos,aes(x=Description, y=Expression,fill=Condition)) +
geom_bar(position="dodge",stat="identity", colour="black",las=2)
path100<-file.path("pajarito",paste("Lupslimrpkm_",tissues[n],".jpg", sep=" "))
jpeg(file=path100)
dev.off()
}
– Roberto Carlos 2 days ago –罗伯托·卡洛斯2天前
Thanks for you help, now I want to share the code that worked: 感谢您的帮助,现在,我想分享有效的代码:
dev.set(dev.prev())
#dev.new(width=10, height=12)
path100<-file.path("D:","final.results",paste("skin005",".png", sep=" "))
png(file=path100, width=1000, height=10000, res=100)
plot(1:100)
attach(skin005RPKMS) #previous data frame with all information
q<-skin005RPKMS[(Skin.Obese > Skin.Fit) & (Skin.Obese > Skin.Slim),]
colnames(q)<-c("Description","Skin.Slim","Skin.Fit","Skin.Obese")
q1<-melt(q,id.vars="Description") #variable contain the different condition of the experiment and value the data.
p <- ggplot(q1, aes(y=Description,x=variable))+ geom_tile(aes(fill=value)) + scale_fill_gradientn(colours=c("white","azure2","yellow","blue","orchid","orange red","red","black"), values=rescale(c(0,1,10,50,100,500,1000,4500)), guide="colorbar") + xlab("Condition") + ylab("Genes")
print(p)
dev.off()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.