#' calc_log2_fold_change_genes
#'
#' Calculates median log2 fold changes for genes (taking as input output from `calc_log2_fold_change_gRNAs`).
#'
#' @param logfc A data frame of log2 fold change data generated by `fgcQC::calc_log2_fold_change_gRNAs`.
#'
#' @return A data frame with a column named `log2FC_gene`.
#' @author Alex T. Kalinka, \email{alex.kalinka@@cancer.org.uk}
#'
#' @importFrom dplyr summarise group_by ungroup
#' @importFrom magrittr %<>%
#' @export
calc_log2_fold_change_genes <- function(logfc){
if(!"log2FC" %in% colnames(logfc))
stop("expecting a column named 'log2FC' in input")
if(!"gene" %in% colnames(logfc))
stop("expecting a column named 'gene' in input")
tryCatch({
logfc %<>%
dplyr::group_by(gene) %>%
dplyr::summarise(log2FC_gene = median(log2FC, na.rm=T)) %>%
dplyr::ungroup()
},
error = function(e) stop(paste("unable to calculate log2 fold changes at the gene level:",e))
)
return(logfc)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.