Showing
1 changed file
with
55 additions
and
0 deletions
scripts/graphics.R
0 → 100644
1 | +setwd("/Users/larisams/Documents/LCG/Sem_4/Bioinformatics/CarlosMendez") | ||
2 | +library(ggplot2) | ||
3 | +# Automated analysis | ||
4 | + | ||
5 | +sent.dat<-as.data.frame(read.table("annotated-sentence-results.txt",header=TRUE)) | ||
6 | +sent.dat$Proportion<-sent.dat$GeneDisease/sent.dat$Total | ||
7 | +sent.dat$constant<-apply(sent.dat,1,function(x){ | ||
8 | + if(x[3]==25){return("4")} | ||
9 | + else if(x[3]==46){return("3")} | ||
10 | + else if(x[3]==17){return("2")} | ||
11 | + else{PConst<-return("0")} | ||
12 | +}) | ||
13 | + | ||
14 | +g1<-ggplot(sent.dat,aes(x=Cluster,y=Proportion,fill=constant))+ | ||
15 | + geom_bar(aes(x=Cluster,y=Proportion),stat="identity")+ | ||
16 | + scale_fill_manual("Constant Partitions", values = c("4" = "#005b7a", "3" = "#DF0664", "2" = "#66CCCC" ,"0" = "#b2afaf"))+ | ||
17 | + facet_wrap(~Partition,ncol=3,nrow=2)+facet_grid(~Partition, labeller = label_context)+theme(legend.position="none") | ||
18 | +ggsave("Figure3.png",g1,width = 7.5, height = 5, dpi = 300, units = "in", device='png') | ||
19 | + | ||
20 | +g2<-ggplot(sent.dat,aes(x=Total,y=GeneDisease,fill=constant))+ | ||
21 | + geom_bar(aes(x=Total,y=GeneDisease),stat="identity")+ | ||
22 | + scale_fill_manual("Constant Partitions", values = c("4" = "#005b7a", "3" = "#DF0664", "2" = "#66CCCC" ,"0" = "#b2afaf"))+ | ||
23 | + facet_wrap(~Partition,ncol=3,nrow=2)+facet_grid(~Partition, labeller = label_context)+ | ||
24 | + xlab("Total sentences")+ylab("Gene disease sentences")+theme(legend.position="none") | ||
25 | +ggsave("Figure2.png",g2,width = 7.5, height = 5, dpi = 300, units = "in", device='png') | ||
26 | + | ||
27 | +# Manual analysis | ||
28 | + | ||
29 | +words.dat<-as.data.frame(read.table("word-counts.txt",header=TRUE)) | ||
30 | +words.dat$Fibrosis<-words.dat$Fibrosis/words.dat$Total | ||
31 | +words.dat$TGF<-words.dat$TGF/words.dat$Total | ||
32 | +words.dat$constant<-sent.dat$constant[c(-1,-2)] | ||
33 | + | ||
34 | +g3<-ggplot(words.dat,aes(x=Cluster,y=Fibrosis,fill=constant))+ | ||
35 | + geom_bar(aes(x=Cluster,y=Fibrosis),stat="identity")+ | ||
36 | + scale_fill_manual("Constant Partitions", values = c("4" = "#005b7a", "3" = "#DF0664", "2" = "#66CCCC" ,"0" = "#b2afaf"))+ | ||
37 | + facet_wrap(~Partition,ncol=3,nrow=2)+facet_grid(~Partition, labeller = label_context)+theme(legend.position="none") | ||
38 | +ggsave("Figure7.png",g3,width = 7.5, height = 5, dpi = 300, units = "in", device='png') | ||
39 | + | ||
40 | +g4<-ggplot(words.dat,aes(x=Cluster,y=TGF,fill=constant))+ | ||
41 | + geom_bar(aes(x=Cluster,y=TGF),stat="identity")+ | ||
42 | + scale_fill_manual("Constant Partitions", values = c("4" = "#005b7a", "3" = "#DF0664", "2" = "#66CCCC" ,"0" = "#b2afaf"))+ | ||
43 | + facet_wrap(~Partition,ncol=3,nrow=2)+facet_grid(~Partition, labeller = label_context)+theme(legend.position="none") | ||
44 | +ggsave("Figure8.png",g4,width = 7.5, height = 5, dpi = 300, units = "in", device='png') | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | + | ||
53 | + | ||
54 | + | ||
55 | + |
-
Please register or login to post a comment