[英]Graphs using ggplot2
我在嘗試使用ggplot2軟件包時遇到了麻煩。 我得到的所有圖都是空的
ggplot(data=dataa,aes(x=Description, y=RPKM,fill=Condition)) +
geom_bar(position="dodge",stat="identity")
dataa
是更大的數據框架的一部分,如下所示:
Description Tissue Condition RPKM
re brain obese 34
re1 brain Fit 23
re2 brain Slim 67
知道我在做什么錯嗎?
我有真實數據:
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
腳本:
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()
}
–羅伯托·卡洛斯2天前
感謝您的幫助,現在,我想分享有效的代碼:
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.