MEA_single_electrode_barchart

Creating a barchart to display MEA burst data recorded by single electrodes

The following vignette describes the workflow used to create a barchart visualisation of MEA burst duration data recorded by single electrodes. Similar visualisations can be created for other burst parameters using different functions within the MEAanalysis package; these include the number of bursts, number of spikes per burst, and mean inter-spike interval within a burst for a given time interval of a recording. These visualisations enable the user to explore and compare extracellular field potentials detected by individual electrodes.

Further examples and information on the arguments of each function can be found on the individual function help pages. To access these pages, please run the following code:

help(package = "MEAanalysis")

Workflow

There are 4 steps to create this visualisation:

  1. Load electrode burst datasets.
  2. Merge electrode burst datasets.
  3. Calculate MEA parameters for specific time intervals of a recording.
  4. Create barchart of single electrode burst data for a specific parameter.

1. Load electrode burst datasets

First, electrode burst csv files need to be processed and loaded into the R environment. This can be done using the MEAanalysis:: create_electrode_dataset function, which reads in, filters, and reformats the data for use in analysis. This function is compatible with electrode burst csv files produced by the axis navigator tool (Axion Biosystems). As demonstrated in the below example, the user should assign the data table to an object name so that it is accessible from the R environment. The user should update the data path with respect to their current working directory. The user should also provide a unique identifier for the loaded recording; this will be used by other MEAanalysis functions to filter the data and calculate burst parameters. This step should be done for all MEA recordings the user wishes to include in the analysis.

burst_recording_1 <- create_electrode_dataset(
  data_path = system.file("extdata", "input_electrode_burst.csv", package = "MEAanalysis"), 
  recording_identifier = "burst_recording_1")

# view first 10 lines of dataset

head(burst_recording_1, 10)
#>     Electrode   Time_s Size_spikes Duration_s Recording_identifier   well
#>        <char>    <num>       <num>      <num>               <char> <char>
#>  1:     A1_21  0.14248          27    0.17600    burst_recording_1     A1
#>  2:     A1_21  8.32536          41    0.22584    burst_recording_1     A1
#>  3:     A1_21 68.18416          44    0.21480    burst_recording_1     A1
#>  4:     A1_23  0.32824          10    0.12456    burst_recording_1     A1
#>  5:     A1_23 38.79848           6    0.05592    burst_recording_1     A1
#>  6:     A1_23 68.33040           7    0.16360    burst_recording_1     A1
#>  7:     A2_21 24.87752           6    0.04824    burst_recording_1     A2
#>  8:     A2_21 70.39144           7    0.09264    burst_recording_1     A2
#>  9:     A2_21 82.13224           5    0.05680    burst_recording_1     A2
#> 10:     A2_33  6.17064           5    0.02208    burst_recording_1     A2
burst_recording_2 <- create_electrode_dataset(
  data_path = system.file("extdata", "comparison_agonist_challenge_electrode_burst_list.csv", package = "MEAanalysis"), 
  recording_identifier = "burst_recording_2")

# view first 10 lines of dataset

head(burst_recording_2, 10)
#>     Electrode   Time_s Size_spikes Duration_s Recording_identifier   well
#>        <char>    <num>       <num>      <num>               <char> <char>
#>  1:     A1_11  2.52936           7    0.06488    burst_recording_2     A1
#>  2:     A1_11  2.97080          26    0.43128    burst_recording_2     A1
#>  3:     A1_11 24.99960          11    0.08080    burst_recording_2     A1
#>  4:     A1_11 25.23640          20    0.37600    burst_recording_2     A1
#>  5:     A1_11 89.33472          33    0.38000    burst_recording_2     A1
#>  6:     A1_11 89.82216          21    0.42312    burst_recording_2     A1
#>  7:     A1_11 90.34880           5    0.01528    burst_recording_2     A1
#>  8:     A1_11 90.62712           5    0.01024    burst_recording_2     A1
#>  9:     A1_11 90.77560           6    0.01704    burst_recording_2     A1
#> 10:     A1_11 90.98640           6    0.01736    burst_recording_2     A1

2. Merge electrode burst datasets

The electrode burst data tables for each individual MEA recording should then be merged vertically. This can be done using the rbind() function, as demonstrated below. The user should update this function to include the data table object names assigned when loading the electrode burst data into the R environment. As shown in the below example, the MEA recording which the burst data belongs too can still be identified using the ‘Recording_identifier’ column.

output_table <- rbind(burst_recording_1, burst_recording_2)

# view first 10 lines of dataset

head(output_table, 10)
#>     Electrode   Time_s Size_spikes Duration_s Recording_identifier   well
#>        <char>    <num>       <num>      <num>               <char> <char>
#>  1:     A1_21  0.14248          27    0.17600    burst_recording_1     A1
#>  2:     A1_21  8.32536          41    0.22584    burst_recording_1     A1
#>  3:     A1_21 68.18416          44    0.21480    burst_recording_1     A1
#>  4:     A1_23  0.32824          10    0.12456    burst_recording_1     A1
#>  5:     A1_23 38.79848           6    0.05592    burst_recording_1     A1
#>  6:     A1_23 68.33040           7    0.16360    burst_recording_1     A1
#>  7:     A2_21 24.87752           6    0.04824    burst_recording_1     A2
#>  8:     A2_21 70.39144           7    0.09264    burst_recording_1     A2
#>  9:     A2_21 82.13224           5    0.05680    burst_recording_1     A2
#> 10:     A2_33  6.17064           5    0.02208    burst_recording_1     A2

3. Calculate MEA parameters for specific time intervals of a recording

Columns containing information regarding the mean, standard deviation (SD), and standard error of the mean (SEM) for a specific MEA burst parameter should then be calculated and added to the merged electrode burst data table. This should be done for defined time intervals of specified MEA recordings. These calculated columns can then be plotted in the barchart visualisation, grouped by individual electrodes. The MEAanalysis package contains functions which calculate these measures for burst duration, number of bursts, number of spikes per burst, and mean inter-spike interval within a burst.

In the below example, the merged electrode burst data table (‘output_table’) is assigned as a new object in the R environment (‘analysis_dataset’); this enables the user to refresh and remove any calculated columns from the analysis_dataset by rerunning this line of code. Using the MEAanalysis::electrode_burst_duration function, the mean, SD, and SEM burst duration for individual electrodes are then calculated for defined time intervals of an MEA recording. Additional columns are added to the analysis_dataset each time this function is run. Alternatively, the electrode_mean_burst_ISI, electrode_number_of_bursts, and electrode_spikes_per_burst functions from the MEAanalysis package can be used to respectively calculate these measures for mean inter-spike interval within a burst, number of bursts, and number of spikes per burst.

# assign the 'output_table' data table object created above to a different object name 'analysis_dataset'
# this means that when columns are added to the 'analysis_dataset' the data table can be refreshed by rerunning this line of code
analysis_dataset <- output_table

# add burst duration calculated columns for defined time intervals to the 'analysis_dataset' 
analysis_dataset <- electrode_burst_duration(data = analysis_dataset, 0, 60, recording_identifier = "burst_recording_1")
analysis_dataset <- electrode_burst_duration(data = analysis_dataset, 0, 60, recording_identifier = "burst_recording_2")
analysis_dataset <- electrode_burst_duration(data = analysis_dataset, 60, 120, recording_identifier = "burst_recording_1")
analysis_dataset <- electrode_burst_duration(data = analysis_dataset, 60, 120, recording_identifier = "burst_recording_2")
Electrode Recording_identifier Time_s Size_spikes Duration_s well electrode_duration_raw: burst_recording_1 0-60 (s) electrode_duration_mean: burst_recording_1 0-60 (s) electrode_duration_sd: burst_recording_1 0-60 (s) electrode_duration_se: burst_recording_1 0-60 (s) electrode_duration_raw: burst_recording_2 0-60 (s) electrode_duration_mean: burst_recording_2 0-60 (s) electrode_duration_sd: burst_recording_2 0-60 (s) electrode_duration_se: burst_recording_2 0-60 (s) electrode_duration_raw: burst_recording_1 60-120 (s) electrode_duration_mean: burst_recording_1 60-120 (s) electrode_duration_sd: burst_recording_1 60-120 (s) electrode_duration_se: burst_recording_1 60-120 (s) electrode_duration_raw: burst_recording_2 60-120 (s) electrode_duration_mean: burst_recording_2 60-120 (s) electrode_duration_sd: burst_recording_2 60-120 (s) electrode_duration_se: burst_recording_2 60-120 (s)
A1_11 burst_recording_2 2.52936 7 0.06488 A1 NA NA NA NA 0.06488 0.23824 0.192426 0.096213 NA NA NA NA NA NA NA NA
A1_11 burst_recording_2 2.97080 26 0.43128 A1 NA NA NA NA 0.43128 0.23824 0.192426 0.096213 NA NA NA NA NA NA NA NA
A1_11 burst_recording_2 24.99960 11 0.08080 A1 NA NA NA NA 0.08080 0.23824 0.192426 0.096213 NA NA NA NA NA NA NA NA
A1_11 burst_recording_2 25.23640 20 0.37600 A1 NA NA NA NA 0.37600 0.23824 0.192426 0.096213 NA NA NA NA NA NA NA NA
A1_11 burst_recording_2 89.33472 33 0.38000 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.38000 0.1148509 0.1471701 0.0443735
A1_11 burst_recording_2 89.82216 21 0.42312 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.42312 0.1148509 0.1471701 0.0443735
A1_11 burst_recording_2 90.34880 5 0.01528 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.01528 0.1148509 0.1471701 0.0443735
A1_11 burst_recording_2 90.62712 5 0.01024 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.01024 0.1148509 0.1471701 0.0443735
A1_11 burst_recording_2 90.77560 6 0.01704 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.01704 0.1148509 0.1471701 0.0443735
A1_11 burst_recording_2 90.98640 6 0.01736 A1 NA NA NA NA NA NA NA NA NA NA NA NA 0.01736 0.1148509 0.1471701 0.0443735

4. Create barchart of single electrode burst data for a specific parameter

The analysis dataset created above can then be used as an input for the MEAanalysis: single_electrode_barchart function. This function will create a barchart of a specified MEA parameter for individual electrodes, grouped by time interval of a recording. The user should define which burst parameter they wish to visualise using the electrode_parameter argument. The user may also filter for specific electrodes using the electrode_filter argument and decide whether the error bars represent SD or SEM using the statistic argument.

p <- single_electrode_barchart(data = analysis_dataset, 
                               electrode_parameter = "burst_duration", 
                               electrode_filter = "A1_1|A1_2", 
                               statistic = se)
print(p)

As the underlying code for the single_electrode_barchart function utilises ggplot2, the user can add layers of code to personalise the output further.

p <- p + 
  scale_fill_grey() +
  ggtitle("A barchart to show the average burst duration detected by 
          single electrodes within a given time period")

print(p)