knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "figs" ) library(nphys)
In this vignette we will be importing the data associated with the field
data set whose raw data is nested in the exa
directory. This data set is an example of an experiment that assesed long-term depression at medial perforant path synpses. We are importing the data from files of the .abf
format.
# Import the abf files. field = importABF(x ="field", dir = "exa/field", ret = TRUE, sv = FALSE)
If ret = TRUE
, a list will return and you can name this as you like. The default return name is nnest. This basic ID is meant to serve as a way to forward data into analysis functions. The nnest contains a working dirctory wd
that points to where data set is stored relative to the project directory. It also contains the metadata
associated with the experimental protocol, and lists the files associated with the abf data.
print(field$wd) print(field$files)
The abf data is processed by a sorting function to name the data based upon the protocol being used.
names(field$ABF)
The experimental paradigm is centered around the conditioning stimulus or beginning of the drug wash in.
field$md$StimFile
Finally we are going to add some traces to our nnest for viewing simplicity using the built in functions pullSweeps()
and avgSweeps()
# We can utilize the dfs_ABF() function to extract the sampling interval sampleInt.ms <- unique(dfs_ABF(field$ABF, int = "samplingIntervalInSec", returnList = FALSE))*1000 # convert to ms if(length(sampleInt.ms)>1)stop("Different sample frequencies") # Ajustments can be made to the points before and after the stimArtifact identifier as to the range to be isolated. adjNeg = -100 adjPos = 1400 field$traces <- list( ms = seq(sampleInt.ms, length.out = sum(abs(adjNeg), abs(adjPos),1), by =sampleInt.ms), Bl_Avg <- pullSweeps(field$ABF, pull = "PreC-Bl", adjNeg = adjNeg, adjPos = adjPos) %>% avgSweeps(), Decay_Avg <- pullSweeps(field$ABF, pull = "Decay", adjNeg = adjNeg, adjPos = adjPos) %>% avgSweeps(), Cond_Avg <- pullSweeps(field$ABF, pull = "Cond", adjNeg = adjNeg, adjPos = adjPos) %>% avgSweeps() )
xA = list( title = "Time (ms)" ) yA = list( range = c(-1.2,0.1), title = "mV" ) plot <- plotly::plot_ly(data = data.frame(field$traces), x = ~ms, y = ~Bl_Avg, type = "scatter", mode = "markers") plot = plotly::add_trace(p = plot,x = ~ms, y = ~Decay_Avg) plot = plotly::add_trace(p = plot,x = ~ms, y = ~Cond_Avg) plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.