#' @title Remove all listeners from a mutaframe
#' @param mf mutaframe
#' @export
#' @author Marie Vendettuoli \email{marie@@mariev.net}
#' @seealso \code{\link[plumbr]{add_listener}}, \code{\link[plumbr]{remove_listener}}
#' @examples
#' test <- qdata(data.frame(x = 1:10, y = 1:10))
#' add_listener(test, function(i, j){print(i)})
#' add_listener(test, function(i, j){print(j)})
#' attr(test, 'changed')$.listeners
#' remove_all_listeners(test)
#' attr(test, 'changed')$.listeners
remove_all_listeners <- function(mf){
sapply(names(attr(mf, 'changed')$.listeners), FUN = function(i){remove_listener(mf, i)})
return(NULL)
}
#' @title Strip qdata mutaframe of augmented data and coerce to data.frame
#' @param mf mutaframe with qdata columns c('.brushed', '.visible', '.color', '.border', '.size', '.visible')
#' @return a data.frame
#' @export
#' @author Marie Vendettuoli \email{marie@@mariev.net}
strip_mf_df <- function(mf){
temp <- as.data.frame(mf)
return(temp[,!names(temp) %in% c('.brushed', '.visible', '.color', '.border', '.size', '.visible')])
}
#' @title Retrieve the profile from an xcmsRaw or cpSample object
#' @param object the xcmsRaw or cpSample object
#' @param mz filter value. default is minumum
#' @return a data.frame
#' @export
#' @author Marie Vendettuoli \email{mariev@@marev.net}
getProfile <- function(object, mz){
prof <- object@env$profile
if(missing(mz)){
mz <- ifelse(min(prof)>=0, min(prof), 0)
}
df <- data.frame( time = rep(object@scantime, each = nrow(prof)),
mz = rep(profMz(object), ncol(prof)),
intensity = as.vector(prof))
return(df[df$intensity > mz,])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.