hello everyone I hope everything is fine.
I'm trying to order my ggplot bars by group but it won't work. I've tried several things as described in the post bellow but I'm still not able to see the bars ordered. Ggplot is ordering by Sample order instead of Cell.Type order.
Can you please help?
My df:
Cell.Type Sample Counts
SRR10162433 hiPSC SRR10162433 27794703
SRR10162434 hiPSC SRR10162434 27077486
SRR10162435 hiPSC SRR10162435 28423798
SRR10162436 hiPSC SRR10162436 26941632
SRR10162445 hiPSC SRR10162445 27393854
SRR10162446 hiPSC SRR10162446 26964857
SRR10162430 TFB SRR10162430 23063031
SRR10162432 TFB SRR10162432 27106366
SRR10162438 TFB SRR10162438 25882727
SRR10162440 TFB SRR10162440 25535387
SRR10162442 TFB SRR10162442 30059135
SRR10162444 TFB SRR10162444 28329032
ggplot(data = libSizes, aes(x = Sample, y = Counts/1e6, fill = Cell.Type)) +
labs(fill = "CellType", x = "Sample", y = "Counts (CPM)") +
geom_bar(stat = "identity", position = 'dodge') +
scale_fill_brewer(palette = "Set2") +
theme_minimal()
I tried suggestions in this post:
Order Bars in ggplot2 bar graph
I was expecting to order my ggplot bars by group (hiPSC, TFB), I wish to see the green bars first, then the orange ones.
Thanks in advance.