Helper functions to manipulate and/or coerce qtl2
objects. Eventually might make sense to submit as pull request?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Create numeric contrast for DESeq2::results() function | |
#' | |
#' @param object a DESeqDataSet object. | |
#' @param group1 logical expression indicating the columns from colData(object) that form part of group1 (numerator). | |
#' @param group2 logical expression indicating the columns from colData(object) that form part of group2 (denominator). | |
#' | |
#' @examples | |
#' # example data for a two-factor design with interaction | |
#' dds <- makeExampleDESeqDataSet() | |
#' dds$timepoint <- factor(rep(1:3, 4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Calculate relative change across time | |
#' | |
#' @param value a vector with the values to calculate the change over. | |
#' @param time a vector with the time points. | |
#' @param ref_time the reference time point to scale the change by. | |
relChange <- function(value, time, ref_time = min(time)){ | |
# check if reference time is contained in the given vector | |
if(any(is.na(value))) stop("Missing values in 'value' not supported. Remove them first.") | |
if(any(is.na(time))) stop("Missing values in 'time' not supported. Remove them first.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Tidying methods for DESeq2 DESeqTransform objects | |
#' | |
#' This reshapes a DESeq2 transform object (output from `rlog()` and | |
#' `varianceStabilizingTransform()` functions) into a tidy format. | |
#' | |
#' @param x DESeqTransform object | |
#' @param colData whether colData should be included in the tidied output | |
#' for those in the DESeqTransform object. | |
#' @param ... extra arguments (not used) | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Perform Principal Components Analysis on a DESeqTransform object | |
#' | |
#' This function is based on the `DESeq2::plotPCA()` function, but returns the | |
#' results of `prcomp` in a tidy list format. This is more flexible for further | |
#' custom plotting and exploring factor loadings of the PCA. | |
#' | |
#' @param x an object of class DESeqTransform | |
#' @ntop number of most-variable genes to select. Igored if "genes" is specified. | |
#' @genes character vector of specific genes to use | |
#' |