Skip to content

R and Shiny approach to draw bar plots with indicated data points

License

Notifications You must be signed in to change notification settings

zetp/Bar_plot_NC

Repository files navigation

Bar plot with indicated data points

Aim: make Shiny app to allow for easy creation of bar plots that fulfil requirements of Nature Communications journal: "Please ensure that the corresponding dot plots are overlaid in the bar charts" Using R and Shiny - seems to be nice project for my first shiny app.

PointBar is now available here. UPDATE: as I am not working in this institute anymore, I have no access to this server and consequently I cannot guarantee that app will work under this address

PointBar Read Me

This app will make bar plot with indicated measurements points. It requires data to be in following format:

  • fields are separated by white space characters (that is one or more spaces, tabs, newlines or carriage returns)
  • first row consists of column names
  • first column consists of sample names (repeated names indicate multiple measurements for given sample)
  • row or column names cannot include whitesapce charatcers (space, tab etc.)
sample data is shown below:

samples cond1 cond2 cond3 cond4
sample1 15735 15043 13755 10373
sample1 15795 15249 13537 10484
sample1 16222 15001 13678 11035
sample2 19695 17940 16781 14820
sample2 21084 20716 17762 14149
sample2 21398 20663 18586 15427
sample3 39442 28614 22010 17504
sample3 41434 29442 22688 17990
sample3 40706 28816 21479 17273

Samples are represented as row names and identical row names mark multiple measurements for given sample. In the case of data presented above there are three measurements for each sample. Column names indicate conditions (for example various concentrations). You can take closer look at the data in Data Editing tab. Moreover you can edit the data in this tab with some limitations. For changes to make effect you have to click "Apply changes" button. You can also download the data (with "Dowload data" button).

Plot tab

This tab is where plot is shown. The plot can be resized by dragging bottom-right corner or edges (bottom or right) of the plot. Size of the plot is displayed below the plot. When this tab is active plot customisation options will become available in the sidebar.

Sidebar

Sidebar provides various options for plot customisation depending on selected sidebar tab. However the file selector will always be displayed so you know on which file you are working on. The file selector allows upload of files with data to be plotted. Next to it there is a switch to set decimal separator (dot or comma).

Sidebar: Main tab

In this tab you can select plot style. There are 5 styles to choose from:
  • Basic - data points are displayed as coloured points
  • Bicolour - data points below and above average are coloured differently
  • Greyscale - this produces in grayscale image, use this preset to avoid colour use
  • Divergent - data points are coloured differently for each condition
  • Custom - in this preset you have control over bar and point colours
In Main tab you can also:
  • save the plot by utilising "Download plot" button
  • choose which error to display on the plot (SD or SEM)
  • use sliders to change bar width, point size and transparency

Sidebar: Points tab

In this tab you can rearrange data points on the plot using appropriate button. The vertical positions of data points depends on their value. Horizontal position of data points is random within bar width so that points with similar values would not overlap one another. Constant random seed value ensures reproducible point positions on the plot. Shape of points also can be chosen. N.B. the points selection is tailored to current selected style.

Sidebar: Colour tab

Here you can choose colour(s) for the points and also colour scale for divergent and custom styles. The colour scale can be reversed using checkbox. You will also be informed if particular colour scale is colour blind friendly.

Sidebar: Axis tab

Here you can:
  • add axes labels and adjust their size
  • change Y axis limits and ticks spacing
  • show horizontal lines

Acknowledgements

Paweł Krawczyk and Aleksander Chlebowski

About

R and Shiny approach to draw bar plots with indicated data points

Resources

License

Stars

Watchers

Forks

Packages

No packages published