forked from yfzon/MassSpecTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.R
More file actions
37 lines (36 loc) · 1.33 KB
/
graph.R
File metadata and controls
37 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(reshape2)
library(ggplot2)
setwd("D:/BaiduYunDownload/01_¿ÆÑй¤×÷/03_Machine learning in proteomics/Metabolism")
rm(list=ls())
table=read.csv("786-QE-GLN-pos-final.csv",header=T,sep=";")
compoundlist=colnames(table)
compound=table[,"Compound"]
for(i in 1:length(compound)){
compoundname=as.character(compound[i])
A=strsplit(compoundname, "\\*")
formula=unlist(A)[2]
B=unlist(strsplit(formula,""))[1]
com=NULL
if(B!='m') #It is the first in such chemical
{
com=unlist(A)[1]
j=i
kn=NULL
nc=NULL
labeling=NULL
while(unlist(strsplit(as.character(compound[j]),"\\*"))[1]==com)
{
labeling=append(labeling,unlist(strsplit(as.character(compound[j]),"\\*"))[2],after=length(labeling))
kn=append(kn,table[,"avrage.kn"][j],after=length(kn))
nc=append(nc,table[,"avrage.nc"][j],after=length(nc))
j=j+1
}
labeling[1]='m0'
picdata=data.frame(com=labeling,HSP60.NC=nc,HSP60.KN=kn)
picdata=melt(picdata,id.vars = "com",varible.name="type",value.name = "abundance")
pic=ggplot(picdata,aes(com,abundance,fill=variable))+geom_bar(stat="identity",position="dodge")+labs(y='Intensity',title=com)
savename=gsub("/", "_", com, fixed = TRUE)
file=paste(savename,".jpg",sep='')
ggsave(sprintf(file),pic,dpi=1200)
}
}