Skip to content

Commit

Permalink
reformatted inline roxygen docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-leary7 committed Oct 11, 2024
1 parent bc239c0 commit f8d3d41
Show file tree
Hide file tree
Showing 83 changed files with 101 additions and 85 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ importFrom(stats,fitted)
importFrom(stats,fitted.values)
importFrom(stats,hclust)
importFrom(stats,kmeans)
importFrom(stats,lm.fit)
importFrom(stats,logLik)
importFrom(stats,offset)
importFrom(stats,p.adjust)
Expand Down
2 changes: 1 addition & 1 deletion R/backward_sel_WIC.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name backward_sel_WIC
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom gamlss gamlss
#' @importFrom geeM geem
#' @importFrom MASS negative.binomial
Expand Down
2 changes: 1 addition & 1 deletion R/biasCorrectGEE.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Bias-correct the GEE sandwich variance-covariance matrix.
#'
#' @name biasCorrectGEE
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This functions implements several bias-correction methods for the GEE sandwich variance-covariance matrix; they are to be used when the number of subjects is small or the numer of timepoints per-subject is very large.
#' @importFrom stats fitted.values cor
#' @importFrom dplyr with_groups summarise
Expand Down
2 changes: 1 addition & 1 deletion R/bootstrapRandomEffects.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Generate bootstrapped confidence intervals for random effects.
#'
#' @name bootstrapRandomEffects
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function leverages the parametric bootstrap to generate empirical confidence intervals for the random effects terms of a fitted model.
#' @importFrom stats simulate update quantile
#' @importFrom dplyr mutate with_groups summarise if_else
Expand Down
2 changes: 1 addition & 1 deletion R/chooseCandidateGenes.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Choose candidate genes for trajectory DE analysis.
#'
#' @name chooseCandidateGenes
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function identifies good gene candidates for trajectory differential expression modeling by ranking genes based on their mean expression, SD of expression, and sparsity across cells.
#' @importFrom purrr map reduce
#' @importFrom Matrix Matrix rowMeans
Expand Down
2 changes: 1 addition & 1 deletion R/createCellOffset.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Create an offset vector before modeling.
#'
#' @name createCellOffset
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom Matrix colSums
#' @description Creates a vector of per-cell size factors to be used as input to \code{\link{testDynamic}} as a model offset given a variety of inputs.
#' @param expr.mat Either a (sparse or dense) matrix of raw integer counts (cells as columns), a \code{Seurat} object, or a \code{SingleCellExperiment} object. Defaults to NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/createSlopeTestData.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' A helper function to create a dataframe of breakpoints and associated \emph{p}-values from a \code{marge} model.
#'
#' @name createSlopeTestData
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Creates a data.frame of \code{marge} model breakpoints, \emph{p}-values, and other info.
#' @importFrom purrr map_dbl
#' @param marge.model A \code{marge} model object, like those returned from \code{\link{marge2}}. Defaults to NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/embedGenes.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Generate PCA & UMAP embeddings of fitted gene dynamics.
#'
#' @name embedGenes
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom purrr map map_dbl
#' @importFrom dplyr bind_cols
Expand Down
2 changes: 1 addition & 1 deletion R/enrichDynamicGenes.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Perform GSEA on dynamic genes identified by \code{scLANE}.
#'
#' @name enrichDynamicGenes
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function uses the \code{gprofiler2} package to perform pathway analysis on a set of genes from one or more lineages that were determined to be dynamic with \code{\link{testDynamic}}.
#' @import magrittr
#' @importFrom dplyr filter arrange desc distinct pull
Expand Down
2 changes: 1 addition & 1 deletion R/extractBreakpoints.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Identify breakpoints in a \code{marge} model.
#'
#' @name extractBreakpoints
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Extracts the breakpoints from a fitted \code{marge} model. Note - this function relies on the name of the pseudotime variable not having any numeric characters in it e.g., "pseudotime" or "PT" would be fine but "pseudotime1" would not. If multiple lineages exist, use letters to denote lineages instead of numbers e.g., "Lineage_A" and "Lineage_B". This is currently handled automatically in \code{\link{testDynamic}}, so don't change anything.
#' @param model The \code{marge} model to analyze. Defaults to NULL.
#' @param directions Should the directions of the hinge functions also be extracted? Defaults to TRUE.
Expand Down
2 changes: 1 addition & 1 deletion R/fitGLMM.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Build an NB GLMM using truncated power basis functions.
#'
#' @name fitGLMM
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Fits a negative binomial generalized linear mixed model using truncated power basis function splines as input. The basis matrix can be created adaptively using subject-specific estimation of optimal knots using \code{\link{marge2}}, or basis functions can be evenly space across quantiles. The resulting model can output subject-specific and population-level fitted values.
#' @importFrom purrr map_dfr pmap_dfc
#' @importFrom dplyr mutate select if_else
Expand Down
2 changes: 1 addition & 1 deletion R/geneProgramDrivers.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Identify driver genes for a given gene program.
#'
#' @name geneProgramDrivers
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom Matrix Matrix
#' @importFrom purrr map reduce
#' @importFrom foreach foreach registerDoSEQ
Expand Down
3 changes: 2 additions & 1 deletion R/geneProgramScoring.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#' Add per-cell module scores for gene programs.
#'
#' @name geneProgramScoring
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom Matrix Matrix
#' @importFrom purrr map reduce
#' @description This function uses \code{\link[UCell]{ScoreSignatures_UCell}} to create a per-cell module score for each of the provided gene clusters. If the input matrix is a \code{Seurat} or \code{SingleCellExperiment} object, then the resulting scores will be added to the \code{meta.data} or the \code{colData} slot, respectively. Otherwise, a data.frame of the per-program scores is returned.
#' @param expr.mat Either a \code{SingleCellExperiment} or \code{Seurat} object from which counts can be extracted, or a matrix of integer-valued counts with genes as rows & cells as columns. Defaults to NULL.
#' @param genes A character vector of gene IDs. Defaults to NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/geneProgramSignificance.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Test significance of gene program enrichment across a trajectory.
#'
#' @name geneProgramSignificance
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom purrr map reduce
#' @importFrom gamlss gamlss LR.test
Expand Down
2 changes: 1 addition & 1 deletion R/getFittedValues.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Generate a table of fitted values and celltype metadata for genes of interest.
#'
#' @name getFittedValues
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom stats qnorm
#' @importFrom purrr map map2 reduce
Expand Down
2 changes: 1 addition & 1 deletion R/getKnotDist.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Pull the set of knots for dynamic genes across each lineage.
#'
#' @name getKnotDist
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom purrr imap reduce
#' @importFrom dplyr filter
Expand Down
2 changes: 1 addition & 1 deletion R/getResultsDE.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Tidy the results of \code{\link{testDynamic}}.
#'
#' @name getResultsDE
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function turns the nested list differential expression results of \code{\link{testDynamic}} and turns them into a tidy data.frame.
#' @import magrittr
#' @importFrom future plan multisession sequential
Expand Down
3 changes: 2 additions & 1 deletion R/marge2.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#' @name marge2
#' @author Jakub Stoklosa
#' @author David I. Warton.
#' @author Jack Leary
#' @author Jack R. Leary
#' @author Rhonda Bacher
#' @description MARS fitting function for negative binomial generalized linear models (GLMs) & generalized estimating equations (GEEs).
#' @import glm2
#' @import magrittr
Expand Down
3 changes: 2 additions & 1 deletion R/max_span.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#' @param alpha See Friedman (1991) equation (45). Defaults to 0.05.
#' @details Note that this equation comes from Friedman (1991) equation (45).
#' @return \code{max_span} returns a vector of truncated predictor variable values.
#' @author Jakub Stoklosa and David I. Warton.
#' @author Jakub Stoklosa
#' @author David I. Warton.
#' @references Friedman, J. (1991). Multivariate adaptive regression splines. \emph{The Annals of Statistics}, \strong{19}, 1--67.
#' @references Stoklosa, J. and Warton, D.I. (2018). A generalized estimating equation approach to multivariate adaptive regression splines. \emph{Journal of Computational and Graphical Statistics}, \strong{27}, 245--253.

Expand Down
3 changes: 2 additions & 1 deletion R/min_span.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#' @param alpha See Friedman (1991) equation (43). Defaults to 0.05.
#' @details This function selects a minimum span between the knots to mitigate runs of correlated noise in the input data and hence avoiding estimation issues, this equation comes from Friedman (1991) equation 43.
#' @return \code{min_span} returns a vector of truncated predictor variable values.
#' @author Jakub Stoklosa and David I. Warton.
#' @author Jakub Stoklosa
#' @author David I. Warton.
#' @references Friedman, J. (1991). Multivariate adaptive regression splines. \emph{The Annals of Statistics}, \strong{19}, 1--67.
#' @references Stoklosa, J. and Warton, D.I. (2018). A generalized estimating equation approach to multivariate adaptive regression splines. \emph{Journal of Computational and Graphical Statistics}, \strong{27}, 245--253.

Expand Down
2 changes: 1 addition & 1 deletion R/modelLRT.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Perform a likelihood ratio test for one model against another.
#'
#' @name modelLRT
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function compares two models using a likelihood ratio test (LRT) under the assumption that the test statistic is asymptotically Chi-squared with degrees freedom equal to the difference in the number of parameters between the larger and smaller model.
#' @importFrom stats logLik pchisq
#' @param mod.1 The model corresponding to the alternative hypothesis. Defaults to NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/nbGAM.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Fit a negative-binomial GAM.
#'
#' @name nbGAM
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Fits a negative-binomial family GAM using a cubic basis spline on pseudotime. If data are multi-subject in nature, a random intercept is included for each subject.
#' @importFrom dplyr mutate
#' @importFrom stats offset
Expand Down
2 changes: 1 addition & 1 deletion R/npConvolve.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Convolution that matches \code{np.convolve}.
#'
#' @name npConvolve
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom stats convolve
#' @description Convolve a vector with a user-specified kernel. Can be useful for heatmap smoothing, weighted moving means, etc.
#' @param x The vector to be convolved. Defaults to NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/plotClusteredGenes.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Generate tidy results from \code{\link{clusterGenes}} to use in plotting.
#'
#' @name plotClusteredGenes
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Generate a table of per-lineage, per-cluster fitted values from \code{scLANE} to be used in visualizations.
#' @import magrittr
#' @importFrom future plan multisession sequential
Expand Down
2 changes: 1 addition & 1 deletion R/plotModelCoefs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Plot gene dynamics with estimated coefficients.
#'
#' @name plotModelCoefs
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom dplyr select mutate lag lead
#' @importFrom tidyr pivot_longer
Expand Down
2 changes: 1 addition & 1 deletion R/plotModels.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Plot results of \code{marge} and other models using \code{ggplot2}.
#'
#' @name plotModels
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @import glm2
#' @importFrom stats qnorm predict as.formula
Expand Down
2 changes: 1 addition & 1 deletion R/score_fun_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name score_fun_gee
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom RcppEigen fastLmPure
#' @importFrom Matrix solve
#' @importFrom MASS ginv
Expand Down
2 changes: 1 addition & 1 deletion R/score_fun_glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name score_fun_glm
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom RcppEigen fastLmPure
#' @importFrom Matrix solve
#' @importFrom MASS ginv
Expand Down
2 changes: 1 addition & 1 deletion R/smoothedCountsMatrix.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Generate a smoothed matrix of gene expression using \code{scLANE} models.
#'
#' @name smoothedCountsMatrix
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function takes as input the output from \code{\link{testDynamic}} and returns the fitted values from each model in a wide format, with one column per-gene and one row-per cell. This matrix can be use as input to cell or gene clustering and / or visualizations such as heatmaps.
#' @import magrittr
#' @importFrom future plan multisession sequential
Expand Down
2 changes: 1 addition & 1 deletion R/sortGenesHeatmap.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Sort genes by where their peak expression occurs across pseudotime.
#'
#' @name sortGenesHeatmap
#' @author Jack Leary
#' @author Jack R. Leary
#' @import magrittr
#' @importFrom purrr map reduce
#' @importFrom dplyr filter distinct select with_groups summarise arrange pull
Expand Down
2 changes: 1 addition & 1 deletion R/sortObservations.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Sort observations by sample ID and pseudotime.
#'
#' @name sortObservations
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom dplyr arrange
#' @description Since the GEE & GLMM modes require data to be sorted by sample ID and pseudotime, this function provides a simple way to do so for a range of inputs.
#' @param expr.mat Either a \code{SingleCellExperiment} or \code{Seurat} object from which counts can be extracted, or a matrix of integer-valued counts with genes as rows & cells as columns. Defaults to NULL.
Expand Down
7 changes: 4 additions & 3 deletions R/stat_out.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#' @name stat_out
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @importFrom stats lm.fit fitted.values
#' @author Jack R. Leary
#' @importFrom RcppEigen fastLmPure
#' @importFrom stats fitted.values
#' @description Calculate the final RSS / GCV for a fitted model.
#' @param Y The response variable. Defaults to NULL.
#' @param B1 The model matrix of predictor variables. Defaults to NULL.
Expand All @@ -28,7 +29,7 @@ stat_out <- function(Y = NULL,
if (is.null(Y) || is.null(B1) || is.null(TSS) || is.null(GCV.null)) { stop("Some of the arguments to stat_out() are missing.") }
if (GCV.null == 0) { stop("GCV.null argument to stat_out() cannot be 0.") }
N <- length(Y)
reg <- try({ stats::lm.fit(B1, Y) }, silent = TRUE)
reg <- try({ RcppEigen::fastLmPure(B1, Y) }, silent = TRUE)
if (inherits(reg, "try-error") || any(is.na(reg$coefficients))) {
RSS1 <- RSSq1 <- GCV1 <- GCVq1 <- NA_real_
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/stat_out_score_gee_null.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name stat_out_score_gee_null
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom geeM geem
#' @importFrom MASS negative.binomial ginv
#' @importFrom stats fitted.values
Expand Down
2 changes: 1 addition & 1 deletion R/stat_out_score_glm_null.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name stat_out_score_glm_null
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom gamlss gamlss
#' @importFrom stats fitted.values
#' @importFrom Matrix diag t
Expand Down
2 changes: 1 addition & 1 deletion R/stripGLM.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Make GLM objects much smaller.
#'
#' @name stripGLM
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function removes a \emph{lot} of components from the default GLM object in order to make it take up less memory. It does however retain enough pieces for \code{predict()} to still work. No promises beyond that.
#' @param glm.obj An object of class GLM from which you'd like to strip out unnecessary components. Defaults to NULL.
#' @return A slimmed-down \code{glm} object.
Expand Down
2 changes: 1 addition & 1 deletion R/summarizeModel.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Represent a \code{marge} model as a series of piecewise equations.
#'
#' @name summarizeModel
#' @author Jack Leary
#' @author Jack R. Leary
#' @author Rhonda Bacher
#' @import magrittr
#' @importFrom stats vcov
Expand Down
2 changes: 1 addition & 1 deletion R/testDynamic.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Test whether a gene is dynamic over pseudotime.
#'
#' @name testDynamic
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function tests whether a NB \code{marge} model is better than a null (intercept-only) model using the Likelihood Ratio Test. In effect, the test tells us whether a gene's expression changes (in any way) over pseudotime.
#' @import glm2
#' @import magrittr
Expand Down
2 changes: 1 addition & 1 deletion R/testSlope.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Test whether a gene is dynamic over a pseudotime interval.
#'
#' @name testSlope
#' @author Jack Leary
#' @author Jack R. Leary
#' @description This function tests whether each gene's estimated \eqn{\beta} for pseudotime differs significantly from 0 over each empirically estimated sets of knots / pseudotime intervals using a Wald test.
#' @import magrittr
#' @importFrom purrr map_dfr
Expand Down
2 changes: 1 addition & 1 deletion R/theme_scLANE.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' A \code{ggplot2} theme for \code{scLANE}.
#'
#' @name theme_scLANE
#' @author Jack Leary
#' @author Jack R. Leary
#' @importFrom ggplot2 theme_classic theme element_rect
#' @description A publication-ready theme for creating gene dynamics plots, embedding plots, etc.
#' @param base.size The base font size. Defaults to 12.
Expand Down
3 changes: 2 additions & 1 deletion R/tp1.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#'
#' @name tp1
#' @param x A predictor variable value. Defaults to NULL.
#' @author Jakub Stoklosa and David I. Warton
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @param t A specified knot value. Defaults to NULL.
#' @param p The \eqn{p^{th}} degree of the polynomial considered. Defaults to 1.
#' @return A vector of values that have been transformed using a truncated \eqn{p^{th}} power function (positive part) for a specified knot value.
Expand Down
3 changes: 2 additions & 1 deletion R/tp2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' Truncated p-th power function (negative part).
#'
#' @name tp2
#' @author Jakub Stoklosa and David I. Warton
#' @author Jakub Stoklosa
#' @author David I. Warton
#' @param x A predictor variable value. Defaults to NULL.
#' @param t A specified knot value. Defaults to NULL.
#' @param p The \eqn{p^{th}} degree of the polynomial considered. Defaults to 1.
Expand Down
2 changes: 1 addition & 1 deletion R/waldTestGEE.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Use a Wald test to compare nested GEE models.
#'
#' @name waldTestGEE
#' @author Jack Leary
#' @author Jack R. Leary
#' @description Performs a basic Wald test to determine whether an alternate model is significantly better than a nested null model. This is the GEE equivalent (kind of) of \code{\link{modelLRT}}. Be careful with small sample sizes.
#' @importFrom MASS ginv
#' @importFrom stats pchisq
Expand Down
Loading

0 comments on commit f8d3d41

Please sign in to comment.