#
# Authors: Florent Chuffart, INSERM and Magali Richard, CNRS
# florent.chuffart@univ-grenoble-alpes.fr
# mag.richardt@ens-lyon.fr
#
#---------------------------------------------
#' Plot the time course distributions accoording to color codes.
#'
#' This function works on FL1H, FSC and SSC data acquired on 96-well plates
#' @param data The gated data generated by gate_facs_yeast_HTS_data
#' @param idx_data The index of the data that will be ploted
#' @param colors The colors to use to construct the ramp, default is c("white", "darkblue")
#' @return A plot of distribution according to time
#' @export
plot_tc <- function(data, idx_data, colors = c("white", "darkblue"),...){
idx = which(idx_data)
strain = data$anno$strain[idx[1]]
bg = data$anno$bg[idx[1]]
gal = data$anno$gal[idx[1]]
date = data$anno$date[idx[1]]
ld = list()
nc = NULL
tc = NULL
xpos = NULL
for (i in 1:length(idx)){
ld[[i]] <- density(data$ngdat[[idx[i]]]$FL1.H)
xpos[i] <- data$anno$time[idx[i]]
nc[i] = length(data$ngdat[[idx[i]]]$FL1.H)
tc[i] = length(data$alldat[[idx[i]]]$FL1.H)
}
# ncell = dim(data$gdat[[idx[1]]])[1]
dyn.profile(ld, xpos = xpos, xlab = "minutes", ylab = "FL1.H", main = paste(strain, " (", bg, "), [GAL]=", gal, ", ", date, sep = ""), colors = colors, ...)
text(x=xpos, y=50, labels=nc)
text(x=xpos, y=0, labels=tc)
}
#---------------------------------------------
#' Plot the time course distributions accoording to color codes.
#'
#' This function works on FL1H, FSC and SSC data acquired on 96-well plates
#' @param data The gated data generated by gate_facs_yeast_HTS_data
#' @param idx_data The index of the data that will be ploted
#' @param col The color index
#' @return A plot of distribution according to time
#' @export
#'
plot_tc_mean <- function(data, idx_data, colors = c("white", "darkblue"),col=1, lty=1){
idx = which(idx_data)
strain = data$anno$strain[idx[1]]
bg = data$anno$bg[idx[1]]
gal = data$anno$gal[idx[1]]
date = data$anno$date[idx[1]]
ld = list()
nc = NULL
tc = NULL
m = sd = xpos = NULL
for (i in 1:length(idx)){
m[i] <- mean(data$gdat[[idx[i]]]$FL1.H)
sd[i] <- sd(data$gdat[[idx[i]]]$FL1.H)
xpos[i] <- data$anno$time[idx[i]]
nc[i] = length(data$gdat[[idx[i]]]$FL1.H)
tc[i] = length(data$alldat[[idx[i]]]$FL1.H)
}
idx2 = order(xpos)
lines(xpos[idx2], m[idx2], col=col, lty=lty)
points(xpos[idx2], m[idx2], col=adjustcolor(col, alpha.f=0.5), pch=16)
arrows(x0=xpos[idx2], x1=xpos[idx2], y0=m[idx2]+sd[idx2], y1=m[idx2]-sd[idx2], length=0, col=adjustcolor(col, alpha.f=0.5))
}
#---------------------------------------------
#' Plot the time course distributions accoording to the fraction of cell ON.
#'
#' This function works on FL1H, FSC and SSC data acquired on 96-well plates
#' @param data The gated data generated by gate_facs_yeast_HTS_data
#' @param idx_data The index of the data that will be ploted
#' @param type The type of data to be used, has to be either "norm" (by default) or "not_norm"
#' @param col The color index
#' @param lty The lty index, 1 by default
#' @return A plot of On frqction according to time
#' @export
#'
#plot_on_fraction = function(data, type="norm", idx_data, col, lty = 1) {
# idx = which(idx_data)
# x_order = (rank(data$anno[idx, ]$time))
# o_idx = sapply(1:length(idx), function(i){idx[which(x_order == i)]})
# if (type=="norm") {
#m = data$anno[ o_idx, ]$ngon_frac
# } else if (type=="not_norm") {
# m = data$anno[ o_idx, ]$gon_frac
# }
# points(data$anno[ o_idx, ]$time, m, col=adjustcolor(col, alpha.f=0.5), pch=18)
# lines(data$anno[ o_idx, ]$time, m, col=col, lty=lty)
#}
plot_on_fraction = function(data, idx_data, col, lty = 1) {
idx = which(idx_data)
x_order = (rank(data$anno[idx, ]$time))
o_idx = sapply(1:length(idx), function(i){idx[which(x_order == i)]})
m = data$anno[ o_idx, ]$on_frac
points(data$anno[ o_idx, ]$time, m, col=adjustcolor(col, alpha.f=0.5), pch=18)
lines(data$anno[ o_idx, ]$time, m, col=col, lty=lty)
}
#---------------------------------------------
#' Plot the time course distributions accoording to mean FL1.
#'
#' This function works on FL1H, FSC and SSC data acquired on 96-well plates
#' @param data The gated data generated by gate_facs_yeast_HTS_data
#' @param idx_data The index of the data that will be ploted
#' @param type The type of data to be used, has to be either "norm" (by default) or "not_norm"
#' @param col The color index
#' @param lty The lty index, 1 by default
#' @return A plot of mean FL1 according to time
#' @export
#'
plot_mean_fl1 = function(data, idx_data, type="norm", col, lty = 1) {
idx = which(idx_data)
x_order = (rank(data$anno[idx, ]$time))
o_idx = sapply(1:length(idx), function(i){idx[which(x_order == i)]})
if (type=="norm") {
m = data$anno[ o_idx, ]$median_ngfl1
sd = data$anno[ o_idx, ]$sd_ngfl1
} else if (type=="not_norm") {
m = data$anno[ o_idx, ]$median_gfl1
sd = data$anno[ o_idx, ]$sd_gfl1
}
x = data$anno[ o_idx, ]$time
points(x, m,col=adjustcolor(col, alpha.f=0.5), pch=18)
lines(x, m ,col=col, lty=lty)
arrows(x0=x, x1=x, y0=m+sd, y1=m-sd, length=0, col=adjustcolor(col, alpha.f=0.5))
}
#---------------------------------------------
#' Plot the time course distributions accoording to mean FL1 after et before normalisation.
#'
#' This function works on FL1H, FSC and SSC data acquired on 96-well plates
#' @param data The gated data generated by gate_facs_yeast_HTS_data
#' @param idx_data The index of the data that will be ploted
#' @param col The color index
#' @return A plot of mean FL1 according to time
#' @export
#'
plot_ctrl_norm = function(data, idx_data,col) {
idx = which(idx_data)
x_order = (rank(data$anno[idx, ]$time))
o_idx = sapply(1:length(idx), function(i){idx[which(x_order == i)]})
m1 = data$anno[ o_idx, ]$median_ngfl1
sd1 = data$anno[ o_idx, ]$sd_ngfl1
m2 = data$anno[ o_idx, ]$median_gfl1
sd2 = data$anno[ o_idx, ]$sd_gfl1
x = data$anno[ o_idx, ]$time
points(x, m1,col=adjustcolor(col, alpha.f=0.5), pch=18)
lines(x, m1 ,col=col, lty =1)
points(x, m2,col=adjustcolor(col, alpha.f=0.5), pch=18)
lines(x, m2 ,col=col, lty =2)
#arrows(x0=x, x1=x, y0=m+sd, y1=m-sd, length=0, col=adjustcolor(col, alpha.f=0.5))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.