Mirroring data on a bar chart x-axis using ggplot

head(plot_case)

   Variant_Classification Exon
1:      Nonsense_Mutation   22
2:        Frame_Shift_Del   28
3:      Nonsense_Mutation    7
4:      Missense_Mutation   27
5:      Missense_Mutation   28
6:      Missense_Mutation   18

full: 
dput(plot_case)
    structure(list(Variant_Classification = structure(c(5L, 1L, 5L, 
    4L, 4L, 4L, 5L, 2L, 5L, 2L, 5L, 4L, 1L, 2L, 1L, 4L, 5L, 5L, 5L, 
    5L, 6L, 5L, 3L, 2L, 3L, 4L, 4L), .Label = c("Frame_Shift_Del", 
    "Frame_Shift_Ins", "In_Frame_Del", "Missense_Mutation", "Nonsense_Mutation", 
    "Splice_Site"), class = "factor"), Exon = structure(c(22L, 28L, 
    7L, 27L, 28L, 18L, 12L, 18L, 20L, 26L, 21L, 11L, 12L, 7L, 14L, 
    13L, 22L, 20L, 15L, 20L, 20L, 21L, 19L, 7L, 3L, 11L, 4L), .Label = c("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"), class = "factor")), row.names = c(NA, 
    -27L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x5642b661b980>)

head(plot_control)

head(dt1)

   Variant_Classification Exon
1:      Nonsense_Mutation   22
2:        Frame_Shift_Del   28
3:      Nonsense_Mutation    7
4:      Missense_Mutation   27
5:      Missense_Mutation   28
6:      Missense_Mutation   18

full: 
dput(plot_case)
    structure(list(Variant_Classification = structure(c(5L, 1L, 5L, 
    4L, 4L, 4L, 5L, 2L, 5L, 2L, 5L, 4L, 1L, 2L, 1L, 4L, 5L, 5L, 5L, 
    5L, 6L, 5L, 3L, 2L, 3L, 4L, 4L), .Label = c("Frame_Shift_Del", 
    "Frame_Shift_Ins", "In_Frame_Del", "Missense_Mutation", "Nonsense_Mutation", 
    "Splice_Site"), class = "factor"), Exon = structure(c(22L, 28L, 
    7L, 27L, 28L, 18L, 12L, 18L, 20L, 26L, 21L, 11L, 12L, 7L, 14L, 
    13L, 22L, 20L, 15L, 20L, 20L, 21L, 19L, 7L, 3L, 11L, 4L), .Label = c("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"), class = "factor")), row.names = c(NA, 
    -27L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x5642b661b980>)

I have another dataset which is the same but much larger:

  Variant_Classification Exon
    1:      Nonsense_Mutation   23
    2:        Frame_Shift_Del   22
    3:      Nonsense_Mutation    3
    4:      Missense_Mutation   27
    5:      Nonsense_Mutation   23
    6:      Frame_Shift_Del   1

I have done:
#first two give me simple enough graphs
ggplot(data = plot_case) + geom_bar(mapping = aes(x= Exon, fill = Variant_Classification))
ggplot(data = plot_control) + geom_bar(mapping = aes(x= Exon, fill = Variant_Classification))

I tried to then create a negative set in the control group

plot_control$Exon <- as.numeric(plot_control$Exon) * -1
plot_all <- rbind(plot_case, plot_control)
#plotting it gives me this
ggplot(data = plot_all) + geom_col(mapping = aes(x= Exon, y=stat_count(Exon), fill = Variant_Classification))

I want the negative numbers to come below the positive ones for each exon. How would I go about that?

Many thanks

Full dput for second table:

dput(plot_control)
structure(list(Variant_Classification = structure(c(4L, 4L, 4L, 
4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L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L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 17L, 17L, 
17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 
19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 
21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 
23L, 23L, 23L, 23L, 23L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 
25L, 25L, 25L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 
26L, 26L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 
28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 
29L, 29L, 29L, 29L, 29L, 29L, 29L), .Label = c("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"), class = "factor")), row.names = c(NA, 
-456L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x5642b661b980>)
> 

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.