-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added function to pull knot distribution -- closes #130
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#' Pull the set of knots for dynamic genes across each lineage. | ||
#' | ||
#' @name getKnotDist | ||
#' @author Jack Leary | ||
#' @import magrittr | ||
#' @importFrom purrr imap reduce | ||
#' @description Pulls knot locations for dynamic genes across each lineage, allowing comparisons of where transcriptional switches occur between lineages. | ||
#' @param test.dyn.res The output from \code{\link{testDynamic}}. Defaults to NULL. | ||
#' @param dyn.genes The set of genes to pull knots for. If unspecified, pulls knots for all modeled genes. Defaults to NULL. | ||
#' @return A data.frame containing gene name, lineage ID, and knot location in pseudotime. | ||
#' @export | ||
#' @examples | ||
#' \dontrun{ | ||
#' getKnotDist(gene_stats) | ||
#' } | ||
|
||
getKnotDist <- function(test.dyn.res = NULL, dyn.genes = NULL) { | ||
# check inputs | ||
if (is.null(test.dyn.res)) { stop("You forgot one of the arguments to getKnotDist().") } | ||
if (is.null(dyn.genes)) { | ||
dyn.genes <- names(test.dyn.res) | ||
} | ||
# pull knots per-lineage | ||
knot_df <- purrr::imap(test.dyn.res[dyn.genes], \(x, y) { | ||
purrr::imap(x, \(z, w) { | ||
data.frame(gene = y, | ||
lineage = w, | ||
knot = z$MARGE_Slope_Data$Breakpoint) | ||
}) %>% | ||
purrr::reduce(rbind) | ||
}) %>% | ||
purrr::reduce(rbind) | ||
return(knot_df) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.