|
1 |
| -# This script plots the number of hit reactions and pathways for proteins and proteoforms |
2 |
| - |
3 |
| -############################### |
4 |
| -# Load libraries |
5 |
| - |
6 |
| -library(ggplot2) |
7 |
| -require(cowplot) |
8 |
| -library(stats) |
9 |
| -source("loadHits.R") |
10 |
| - |
11 |
| -############################### |
12 |
| -# First, load data |
13 |
| - |
14 |
| -hitsReactions <- load.hits(fileProteins = "ReactionsPerProtein.csv", fileProteoforms = "ReactionsPerProteoform.csv") |
15 |
| -hitsPathways <- load.hits(fileProteins = "PathwaysPerProtein.csv", fileProteoforms = "PathwaysPerProteoform.csv") |
16 |
| - |
17 |
| -hits <- load.hits.Merged(fileProteins = "HitsPerProtein.csv", fileProteoforms = "HitsPerProteoform.csv") |
18 |
| - |
19 |
| -############################### |
20 |
| -# Second, create plots |
21 |
| - |
22 |
| -cdat <- ddply(hitsPathways, "Type", summarise, Count.mean=mean(Count)) |
23 |
| -cdat |
24 |
| - |
25 |
| -plot.density.ByAccession <- ggplot(hits[which(hits$Type == "Protein" & hits$Hit == "Pathway"),], aes(x=Count)) + |
26 |
| - scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
27 |
| - scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
28 |
| - geom_density(size=1, alpha = 0.4, show.legend = F) + |
29 |
| - scale_x_log10(name = "# mapped pathways") + |
30 |
| - theme_bw() + |
31 |
| - geom_vline(xintercept=mean(hits$Count[which(hits$Type == "Protein" & hits$Hit == "Pathway")]), linetype="dashed", color = "black") |
32 |
| -plot.density.ByAccession |
33 |
| - |
34 |
| -plot.density.ByProteoform <- ggplot(hits[which(hits$Type == "Proteoform" & hits$Hit == "Pathway"),], aes(x=Count)) + |
35 |
| - scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
36 |
| - scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
37 |
| - geom_density(size=1, alpha = 0.4, show.legend = F) + |
38 |
| - scale_x_log10(name = "# mapped pathways") + |
39 |
| - theme_bw() + |
40 |
| - geom_vline(xintercept=mean(hits$Count[which(hits$Type == "Proteoform" & hits$Hit == "Pathway")]), linetype="dashed", color = "black") |
41 |
| -plot.density.ByProteoform |
42 |
| - |
43 |
| -############################### |
44 |
| -# Third, put the plots together in a grid |
45 |
| - |
46 |
| -plot_grid( |
47 |
| - plot.density.ByAccession, |
48 |
| - plot.density.ByProteoform, |
49 |
| - plot.scatter, |
50 |
| - labels = c("A", "B","C")) |
51 |
| - |
52 |
| -############################### |
53 |
| -# Fourth, create facets with densities |
54 |
| - |
55 |
| -plot.density <- ggplot(hits, aes(x=Count, colour = Type, fill = Type)) + |
56 |
| - facet_grid(. ~ Hit) + |
57 |
| - scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
58 |
| - scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
59 |
| - geom_density(size=1, alpha = 0.4, show.legend = T) + |
60 |
| - scale_x_continuous(limits = c(xMin, xMax)) + |
61 |
| - theme_bw() + ggtitle(name = "# mapped pathways") + |
62 |
| - geom_vline(data=cdat, aes(xintercept=Count.mean, color=Type),linetype="dashed", show.legend = T) |
63 |
| - |
64 |
| -plot.density |
| 1 | +# This script plots the number of hit reactions and pathways for proteins and proteoforms |
| 2 | + |
| 3 | +############################### |
| 4 | +# Load libraries |
| 5 | + |
| 6 | +library(ggplot2) |
| 7 | +require(cowplot) |
| 8 | +library(stats) |
| 9 | +library(plyr) |
| 10 | +source("loadHits.R") |
| 11 | + |
| 12 | +############################### |
| 13 | +# First, load data |
| 14 | + |
| 15 | +hitsReactions <- load.hits(fileProteins = "ReactionsPerProtein.csv", fileProteoforms = "ReactionsPerProteoform.csv") |
| 16 | +hitsPathways <- load.hits(fileProteins = "PathwaysPerProtein.csv", fileProteoforms = "PathwaysPerProteoform.csv") |
| 17 | + |
| 18 | +hits <- load.hits.Merged(fileProteins = "HitsPerProtein.csv", fileProteoforms = "HitsPerProteoform.csv") |
| 19 | + |
| 20 | +############################### |
| 21 | +# Second, create plots |
| 22 | + |
| 23 | + |
| 24 | +cdat <- ddply(hitsPathways, "Type", summarise, Count.mean=mean(Count)) |
| 25 | +cdat |
| 26 | + |
| 27 | +plot.density.ByAccession <- ggplot(hits[which(hits$Type == "Protein" & hits$Hit == "Pathway"),], aes(x=Count)) + |
| 28 | + scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 29 | + scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 30 | + geom_density(size=1, alpha = 0.4, show.legend = F) + |
| 31 | + scale_x_log10(name = "# mapped pathways") + |
| 32 | + theme_bw() + |
| 33 | + geom_vline(xintercept=mean(hits$Count[which(hits$Type == "Protein" & hits$Hit == "Pathway")]), linetype="dashed", color = "black") |
| 34 | +plot.density.ByAccession |
| 35 | + |
| 36 | +plot.density.ByProteoform <- ggplot(hits[which(hits$Type == "Proteoform" & hits$Hit == "Pathway"),], aes(x=Count)) + |
| 37 | + scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 38 | + scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 39 | + geom_density(size=1, alpha = 0.4, show.legend = F) + |
| 40 | + scale_x_log10(name = "# mapped pathways") + |
| 41 | + theme_bw() + |
| 42 | + geom_vline(xintercept=mean(hits$Count[which(hits$Type == "Proteoform" & hits$Hit == "Pathway")]), linetype="dashed", color = "black") |
| 43 | +plot.density.ByProteoform |
| 44 | + |
| 45 | +############################### |
| 46 | +# Third, put the plots together in a grid |
| 47 | + |
| 48 | +plot_grid( |
| 49 | + plot.density.ByAccession, |
| 50 | + plot.density.ByProteoform, |
| 51 | + plot.scatter, |
| 52 | + labels = c("A", "B","C")) |
| 53 | + |
| 54 | +############################### |
| 55 | +# Fourth, create facets with densities |
| 56 | + |
| 57 | +plot.density <- ggplot(hits, aes(x=Count, colour = Type, fill = Type)) + |
| 58 | + facet_grid(. ~ Hit) + |
| 59 | + scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 60 | + scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9")) + |
| 61 | + geom_density(size=1, alpha = 0.4, show.legend = T) + |
| 62 | + scale_x_log10() + |
| 63 | + theme_bw() + |
| 64 | + geom_vline(data=cdat, aes(xintercept=Count.mean, color=Type),linetype="dashed", show.legend = T) |
| 65 | + |
| 66 | +plot.density |
0 commit comments