Skip to content

Commit

Permalink
Added docs for bioconductor submission -- related to #96
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-leary7 committed Nov 12, 2023
1 parent 93a0ed6 commit afe646c
Show file tree
Hide file tree
Showing 56 changed files with 317 additions and 412 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/bioc-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
on:
push:
branches: main
pull_request: main
pull_request:
branches: main

name: bioc-check

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/render-README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: render-README

jobs:
render:
runs-on: ubuntu-latest
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand All @@ -22,9 +22,9 @@ jobs:
- uses: r-lib/actions/setup-pandoc@v2

- name: install CRAN packages
run: Rscript -e 'install.packages(c("rmarkdown","ggplot2", "dplyr", "purrr", "remotes", "devtools", "BiocManager", "Seurat"), dependencies = TRUE)'
run: Rscript -e 'install.packages(c("rmarkdown","ggplot2", "dplyr", "purrr", "remotes", "devtools", "BiocManager", "Seurat"), force = TRUE)'
- name: install BioConductor packages
run: Rscript -e 'BiocManager::install(c("SingleCellExperiment", "scater", "scran", "scuttle", "bluster"))'
run: Rscript -e 'BiocManager::install(c("SingleCellExperiment", "scater", "scran", "scuttle", "bluster"), force = TRUE)'
- name: install GitHub packages
run: Rscript -e 'remotes::install_github("jr-leary7/scLANE")'
- name: render README
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Suggests:
BiocStyle,
slingshot,
gprofiler2,
BiocParallel,
BiocGenerics,
BiocNeighbors,
testthat (>= 3.0.0),
Expand Down
8 changes: 2 additions & 6 deletions R/GetResultsDE.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
#' @seealso \code{\link{testDynamic}}
#' @seealso \code{\link[stats]{p.adjust}}
#' @examples
#' \dontrun{
#' getResultsDE(gene_stats)
#' getResultsDE(gene_stats,
#' p.adj.method = "BH",
#' fdr.cutoff = 5e-3)
#' }
#' data(scLANE_models)
#' scLANE_de_res <- getResultsDE(scLANE_models)

getResultsDE <- function(test.dyn.res = NULL,
p.adj.method = "holm",
Expand Down
19 changes: 6 additions & 13 deletions R/clusterGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@
#' @seealso \code{\link{plotClusteredGenes}}
#' @export
#' @examples
#' \dontrun{
#' clusterGenes(gene_stats, pt = pt_df)
#' clusterGenes(gene_stats,
#' pt = pt_df,
#' size.factor.offset = createCellOffset(sce_obj),
#' clust.algo = "kmeans",
#' use.pca = TRUE,
#' n.PC = 10,
#' lineages = "B")
#' clusterGenes(gene_stats,
#' pt = pt_df,
#' lineages = c("A", "C"))
#' }
#' data(sim_pseudotime)
#' data(scLANE_models)
#' cell_offset <- createCellOffset(sim_counts)
#' gene_clusters <- clusterGenes(scLANE_models,
#' pt = sim_pseudotime,
#' size.factor.offset = cell_offset)

clusterGenes <- function(test.dyn.res = NULL,
pt = NULL,
Expand Down
7 changes: 2 additions & 5 deletions R/createCellOffset.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
#' @seealso \code{\link[scuttle]{computeLibraryFactors}}
#' @export
#' @examples
#' \dontrun{
#' createCellOffset(expr.mat = sce_obj)
#' createCellOffset(expr.mat = counts(sce_obj))
#' createCellOffset(expr.mat = seu_obj, scale.factor = 1e5)
#' }
#' data(sim_counts)
#' cell_offset <- createCellOffset(sim_counts)

createCellOffset <- function(expr.mat = NULL, scale.factor = 1e4) {
# check inputs
Expand Down
7 changes: 0 additions & 7 deletions R/createSlopeTestData.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#' @return A data.frame containing model data.
#' @seealso \code{\link{marge2}}
#' @seealso \code{\link{testSlope}}
#' @examples
#' \dontrun{
#' createSlopeTestData(marge_mod, pt_df)
#' createSlopeTestData(marge_mod,
#' pt = pt_df,
#' is.glmm = TRUE)
#' }

createSlopeTestData <- function(marge.model = NULL,
pt = NULL,
Expand Down
27 changes: 17 additions & 10 deletions R/embedGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
#' @param k.param (Optional) The value of nearest-neighbors used in creating the SNN graph prior to clustering & in running UMAP. Defaults to 20.
#' @param resolution.param (Optional) The value of the resolution parameter for the Leiden algorithm. If unspecified, silhouette scoring is used to select an optimal value. Defaults to NULL.
#' @param random.seed (Optional) The random seed used to control stochasticity in the clustering algorithm. Defaults to 312.
#' @param n.cores (Optional) Integer specifying the number of threads used by \code{\link[uwot]{umap}} and in \code{\link[bluster]{makeSNNGraph}}. Defaults to 2.
#' @return A data.frame containing embedding coordinates, cluster IDs, and metadata for each gene.
#' @export
#' @examples
#' \dontrun{
#' embedGenes(smoothed_counts$Lineage_A,
#' pcs.return = 3,
#' cluster.genes = TRUE)
#' }
#' data(sim_pseudotime)
#' data(scLANE_models)
#' smoothed_dynamics <- smoothedCountsMatrix(scLANE_models,
#' pt = sim_pseudotime,
#' n.cores = 1L)
#' gene_embed <- embedGenes(smoothed_dynamics$Lineage_A, n.cores = 1L)

embedGenes <- function(smoothed.counts = NULL,
genes = NULL,
Expand All @@ -35,7 +37,8 @@ embedGenes <- function(smoothed.counts = NULL,
gene.meta.data = NULL,
k.param = 20,
resolution.param = NULL,
random.seed = 312) {
random.seed = 312,
n.cores = 2L) {
# check inputs
if (is.null(smoothed.counts)) { stop("You forgot to provide a smoothed counts matrix to embedGenes().") }
genes <- colnames(smoothed.counts)
Expand All @@ -52,28 +55,32 @@ embedGenes <- function(smoothed.counts = NULL,
n_neighbors = k.param,
init = "spectral",
nn_method = "annoy",
seed = random.seed)
seed = random.seed,
n_threads = n.cores)
} else {
smoothed_counts_umap <- uwot::umap(smoothed.counts,
n_components = 2,
metric = "cosine",
n_neighbors = k.param,
init = "spectral",
nn_method = "annoy",
seed = random.seed)
seed = random.seed,
n_threads = n.cores)
}
# clustering w/ silhouette score parameter tuning
if (cluster.genes) {
if (pca.init) {
smoothed_counts_snn <- bluster::makeSNNGraph(smoothed_counts_pca$x,
k = k.param,
type = "jaccard",
BNPARAM = BiocNeighbors::AnnoyParam(distance = "Cosine"))
BNPARAM = BiocNeighbors::AnnoyParam(distance = "Cosine"),
BPPARAM = BiocParallel::SnowParam(workers = n.cores))
} else {
smoothed_counts_snn <- bluster::makeSNNGraph(smoothed.counts,
k = k.param,
type = "jaccard",
BNPARAM = BiocNeighbors::AnnoyParam(distance = "Cosine"))
BNPARAM = BiocNeighbors::AnnoyParam(distance = "Cosine"),
BPPARAM = BiocParallel::SnowParam(workers = n.cores))
}
if (is.null(resolution.param)) {
if (pca.init) {
Expand Down
9 changes: 3 additions & 6 deletions R/enrichDynamicGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
#' @seealso \code{\link[gprofiler2]{gost}}
#' @export
#' @examples
#' \dontrun{
#' enrichDynamicGenes(scLANE.de.res = de_stats)
#' enrichDynamicGenes(scLANE.de.res = de_stats,
#' lineage = "B",
#' species = "mmusculus")
#' }
#' data(scLANE_models)
#' scLANE_de_res <- getResultsDE(scLANE_models)
#' enr_res <- enrichDynamicGenes(scLANE_de_res)

enrichDynamicGenes <- function(scLANE.de.res = NULL,
lineage = NULL,
Expand Down
10 changes: 7 additions & 3 deletions R/extractBreakpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
#' @return A data.frame of breakpoints & their directions.
#' @export
#' @examples
#' \dontrun{
#' extractBreakpoints(model = marge_mod)
#' }
#' data(sim_counts)
#' data(sim_pseudotime)
#' cell_offset <- createCellOffset(sim_counts)
#' marge_model <- marge2(sim_pseudotime,
#' Y = BiocGenerics::counts(sim_counts)[4, ],
#' Y.offset = cell_offset)
#' breakpoint_df <- extractBreakpoints(model = marge_model)

extractBreakpoints <- function(model = NULL, directions = TRUE) {
# check inputs
Expand Down
13 changes: 7 additions & 6 deletions R/fitGLMM.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
#' @seealso \code{\link{modelLRT}}
#' @export
#' @examples
#' \dontrun{
#' fitGLMM(X_pred = pt_df,
#' Y = raw_counts,
#' Y.offset = size_factor_vec,
#' id.vec = subject_vec)
#' }
#' data(sim_counts)
#' data(sim_pseudotime)
#' cell_offset <- createCellOffset(sim_counts)
#' glmm_mod <- fitGLMM(X_pred = sim_pseudotime,
#' Y = BiocGenerics::counts(sim_counts)[4, ],
#' Y.offset = cell_offset,
#' id.vec = sim_counts$subject)

fitGLMM <- function(X_pred = NULL,
Y = NULL,
Expand Down
18 changes: 11 additions & 7 deletions R/geneProgramScoring.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@
#' @return Either a \code{Seurat} or \code{SingleCellExperiment} object if \code{expr.mat} is in either form, or a data.frame containing per-cell program scores if \code{expr.mat} is a matrix.
#' @export
#' @examples
#' \dontrun{
#' geneProgramScoring(seu_obj,
#' genes = gene_embed$gene,
#' gene.clusters = gene_embed$leiden,
#' program.labels = c("cell cycle", "organogenesis"))
#' }
#' data(sim_pseudotime)
#' data(scLANE_models)
#' smoothed_dynamics <- smoothedCountsMatrix(scLANE_models,
#' pt = sim_pseudotime,
#' n.cores = 1L)
#' gene_embed <- embedGenes(smoothed_dynamics$Lineage_A, n.cores = 1L)
#' sim_counts <- geneProgramScoring(sim_counts,
#' genes = gene_embed$gene,
#' gene.clusters = gene_embed$leiden,
#' n.cores = 1L)

geneProgramScoring <- function(expr.mat = NULL,
genes = NULL,
gene.clusters = NULL,
program.labels = NULL,
n.cores = 2) {
n.cores = 2L) {
# check inputs
if (is.null(expr.mat) || is.null(genes) || is.null(gene.clusters)) { stop("Arguments to geneProgramScoring() are missing.") }
if (!is.factor(gene.clusters)) {
Expand Down
15 changes: 7 additions & 8 deletions R/getFittedValues.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#' @return A data.frame containing depth- and log1p-normalized expression, model predictions, and cell-level metadata.
#' @export
#' @examples
#' \dontrun{
#' getFittedValues(gene_stats,
#' genes = c("Neurog3", "Epcam", "Krt19"),
#' pt = pt_df,
#' expr.mat = seu_obj,
#' cell.meta.data = [email protected],
#' ci.alpha = 0.05)
#' }
#' data(sim_counts)
#' data(sim_pseudotime)
#' data(scLANE_models)
#' fitted_vals <- getFittedValues(scLANE_models,
#' genes = sample(names(scLANE_models), 5),
#' pt = sim_pseudotime,
#' expr.mat = sim_counts)

getFittedValues <- function(test.dyn.res = NULL,
genes = NULL,
Expand Down
5 changes: 2 additions & 3 deletions R/getKnotDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
#' @return A data.frame containing gene name, lineage ID, and knot location in pseudotime.
#' @export
#' @examples
#' \dontrun{
#' getKnotDist(gene_stats)
#' }
#' data(scLANE_models)
#' knot_dist <- getKnotDist(scLANE_models)

getKnotDist <- function(test.dyn.res = NULL, dyn.genes = NULL) {
# check inputs
Expand Down
24 changes: 6 additions & 18 deletions R/marge2.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,12 @@
#' @seealso \code{\link[geeM]{geem}}
#' @export
#' @examples
#' \dontrun{
#' marge2(pseudotime_df,
#' Y = expr_vec,
#' M = 3)
#' marge2(pseudotime_df,
#' Y = expr_vec,
#' Y.offset = size_factor_vec,
#' is.gee = TRUE,
#' id.vec = subject_vec,
#' cor.structure = "exchangeable")
#' marge2(pseudotime_df,
#' Y = expr_vec,
#' is.gee = TRUE,
#' id.vec = subject_vec,
#' cor.structure = "ar1",
#' n.knot.max = 10,
#' return.basis = TRUE)
#' }
#' data(sim_counts)
#' data(sim_pseudotime)
#' cell_offset <- createCellOffset(sim_counts)
#' marge_model <- marge2(sim_pseudotime,
#' Y = BiocGenerics::counts(sim_counts)[4, ],
#' Y.offset = cell_offset)

marge2 <- function(X_pred = NULL,
Y = NULL,
Expand Down
20 changes: 8 additions & 12 deletions R/nbGAM.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@
#' @seealso \code{\link[gamlss.dist]{NBI}}
#' @export
#' @examples
#' \dontrun{
#' nbGAM(expr_vec, pt_df)
#' nbGAM(expr_vec,
#' pt = pt_df,
#' id.vec = subject_ids,
#' random.slopes = TRUE)
#' nbGAM(expr_vec,
#' pt = pt_df,
#' Y.offset = size_factor_vec,
#' penalize.spline = TRUE,
#' spline.df = 10)
#' }
#' data(sim_counts)
#' data(sim_pseudotime)
#' cell_offset <- createCellOffset(sim_counts)
#' gam_mod <- nbGAM(BiocGenerics::counts(sim_counts)[4, ],
#' pt = sim_pseudotime,
#' Y.offset = cell_offset,
#' penalize.spline = TRUE,
#' spline.df = 10)

nbGAM <- function(expr = NULL,
pt = NULL,
Expand Down
4 changes: 2 additions & 2 deletions R/npConvolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#' @return A convolution with same length as the input vector.
#' @details
#' \itemize{
#' \item The convolution here uses \code{\link[stats]{convolve}}, but creates the kernel and padding in such a way that it matches the output from `np.convolve` in Python's \code{numpy} matrix algebra package.
#' \item The convolution here uses \code{\link[stats]{convolve}}, but creates the kernel and padding in such a way that it matches the output from \code{np.convolve} in Python's \code{numpy} matrix algebra package.
#' }
#' @seealso \code{\link[stats]{convolve}}
#' @export
#' @examples
#' npConvolve(x = rnorm(20), conv.kernel = rep(1/5, 5))
#' convolved_vec <- npConvolve(x = rnorm(20), conv.kernel = rep(1/5, 5))
#'

npConvolve <- function(x = NULL, conv.kernel = NULL) {
Expand Down
2 changes: 1 addition & 1 deletion R/plotClusteredGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ plotClusteredGenes <- function(test.dyn.res = NULL,
pt = NULL,
size.factor.offset = NULL,
parallel.exec = TRUE,
n.cores = 2) {
n.cores = 2L) {
# check inputs
if (is.null(test.dyn.res) || is.null(gene.clusters) || is.null(pt)) { stop("Arguments to plotClusteredGenes() are missing.") }
colnames(pt) <- paste0("Lineage_", LETTERS[seq_len(ncol(pt))])
Expand Down
15 changes: 9 additions & 6 deletions R/plotModelCoefs.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
#' @return A \code{ggplot2} object displaying a gene dynamics plot & a table of coefficients across pseudotime intervals.
#' @export
#' @examples
#' \dontrun{
#' plotModelCoefs(gene_stats,
#' gene = "BRCA2",
#' pt = pt_df,
#' expr.mat = seu_obj,
#' data(sim_counts)
#' data(sim_pseudotime)
#' data(scLANE_models)
#' cell_offset <- createCellOffset(sim_counts)
#' scLANE_de_res <- getResultsDE(scLANE_models)
#' plotModelCoefs(scLANE_models,
#' gene = scLANE_de_res$Gene[1],
#' pt = sim_pseudotime,
#' expr.mat = sim_counts,
#' size.factor.offset = cell_offset)
#' }

plotModelCoefs <- function(test.dyn.res = NULL,
gene = NULL,
Expand Down
Loading

0 comments on commit afe646c

Please sign in to comment.