library(ephys2)
rm(CURSORS)
tree <- get_treeinfo(examplefile("NaV"))
hergDRC <- get_treeinfo(examplefile("hergDRC"))
hergDRC<-get_treeinfo(examplefile("hergDRC"))
init_cursor('hERG-drc','peak',curMax_,c(2.3212703220623,2.4618657208954))
init_cursor('hERG-drc','base',curMean_,c(0.18221175410099,0.22238186805331))
set_resultmethod("hERG-drc","corr", function(x) {x$corr<-x$peak-x$base;x})
s<-getSeries(hergDRC, 1,1,2)
#s$plot() #slow
# do the same with ggplot:
library(tidyverse)
library(cowplot)
theme_set(theme_cowplot())
s %>% ggsweeps()
s %>% ggsweeps(sweeps=1:12)
s %>% ggsweeps(sweeps=1)
s %>% ggsweeps("labeled")
s %>% gg_itplot("corr")
########## erstmal bis hier
stop()
geom_cursorrange<-function(s, cursor, style = xbar_style("skyblue", "top", hline.lwd = 18)){
cursor = ephys2:::getAnadef(s$sweeps)$cursors[[cursor]]
gg_xbar(cursor$range[1],
cursor$range[2],
0,0,
style=style,
label = cursor$name)
}
# wir könnten an s Funktionen haben die bereits fertige ggpLot Layer mit guten defaults erzeugen:
s$ggplot <- s %>% tidytraces %>% ggplot(aes(x=seconds, y=current, group=swp))
s$gg_cursors<- list(peak = function(s_=s, cursor="peak",...) geom_cursorrange(s=s_,cursor=cursor,...))
s$gg_results<-list(peak = function(color="skyblue",...) geom_point(aes(peak.x,peak), data=sres, color=color, ...))
# dann könnte man sich den ggpPlot so zusammenbauen und auch anpassen:
s$ggplot +
s$gg_cursors$peak(style = xbar_style("orange", "top", hline.lwd = 18)) +
geom_line(aes(color=swp)) +
s$gg_results$peak( size=5, alpha=.7) -> p;p
# Idee wie man die cursorresults farbig nach sweeps macht.
# dazu muss man in results den gleichen namen und format für die sweeps haben wie in tidytraces.
sres<-s$results() %>% mutate(swp=as_factor(paste0("s", swp, ":")))
p + geom_point(aes(peak.x,peak, colour=swp), data=sres, size=3)
# oder von Hand
s$ggplot + geom_line()
s$ggplot + geom_cursorrange(s, 1) + geom_line()
s$ggplot + geom_line() + geom_cursorrange(s, 1)
# wahrscheinlich so (ähnl ggDRC):
# s$ggplot("all", cursors="all") <==> s$ggplot()
# s$ggplot("traces")
# s$ggplot("results", cursors="peak")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.