diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..77fae88 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,33 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + - dev-am + pull_request: + branches: + - main + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/setup-r@v1 + - name: Install dependencies + run: | + install.packages(c("remotes", "rcmdcheck")) + remotes::install_deps(dependencies = TRUE) + shell: Rscript {0} + - name: Check + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error") + shell: Rscript {0} diff --git a/NAMESPACE b/NAMESPACE index 719652b..d68078d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -52,6 +52,7 @@ export(report_impacted_pathway) export(report_integrated_sce) export(report_merged_sce) export(report_qc_sce) +export(volcano_plot) export(write_celltype_mappings) export(write_sce) export(write_sparse_matrix) diff --git a/R/cluster_sce.R b/R/cluster_sce.R index c1b6347..6436b8e 100644 --- a/R/cluster_sce.R +++ b/R/cluster_sce.R @@ -2,9 +2,8 @@ #' Cluster SingleCellExperiment with monocle3::cluster_cells #' #' @param sce a SingleCellExperiment object -#' @param reduction_methods one or more of "PCA", "tSNE", "UMAP", "UMAP3D" -#' @param pca_dims the number of pca dimensions used -#' @param ... see uwot::umap for umap options +#' @param ... see uwot::umap for umap options. Includes reduction_methods one +#' or more of "PCA", "tSNE", "UMAP", "UMAP3D" #' #' @return sce a SingleCellExperiment object annotated with reducedDims #' diff --git a/R/diffexp_models.R b/R/diffexp_models.R index 1a185c7..23d3bc1 100644 --- a/R/diffexp_models.R +++ b/R/diffexp_models.R @@ -664,15 +664,23 @@ perform_de <- function(sce, } -#' volcano plot +#' Plot volcano plot for differential expression analysis #' +#' @param dt Differential expression result table from perform_de() function. +#' @param fc_threshold Fold change threshold for the volcano plot. This will be adjusted and plotted as the log2 fold change. Default is 1.05. +#' @param pval_cutoff The adjusted p-value cut-off for the volcano plot. Default is 0.05. +#' @param n_label The number of top up & down differentially expressed genes to be labeled. Default is 10. +#' +#' @return No return. The plot is printed out. +#' +#' @family differential gene expression +#' #' @importFrom ggplot2 ggplot geom_point aes coord_cartesian #' @importFrom ggrepel geom_text_repel #' @importFrom dplyr %>% filter top_n #' -#' @keywords internal - -.volcano_plot <- function(dt, +#' @export +volcano_plot <- function(dt, fc_threshold = 1.05, pval_cutoff = 0.05, n_label = 10) { diff --git a/R/find_cells_sce.R b/R/find_cells_sce.R index 0aac580..f30938a 100644 --- a/R/find_cells_sce.R +++ b/R/find_cells_sce.R @@ -8,7 +8,7 @@ #' @param lower see [DropletUtils::emptyDrops()] #' @param retain see [DropletUtils::emptyDrops()]. Use "auto" to calculate #' the parameter from the top `expect_cells` cells (cellranger method). -#' @param alpha minimum FDR for [DropletUtils::emptyDrops()] +# #' @param alpha minimum FDR for [DropletUtils::emptyDrops()] #' @param niters the number of Monte Carlo iterations #' @param expect_cells the number of cells expected for auto retain #' @param alpha_cutoff The alpha cutoff used for Monte Carlo signficance. diff --git a/R/integrate_sce.R b/R/integrate_sce.R index 265ce83..ad06362 100644 --- a/R/integrate_sce.R +++ b/R/integrate_sce.R @@ -5,9 +5,9 @@ #' #' @param sce a SingleCellExperiment object or merged sce objects #' @param method the integration method to use -#' @param k Inner dimension of factorization (number of factors). #' Set to k=30 as default. -#' @param ... Additional arguments +#' @param ... Additional arguments. Such as k Inner dimension of factorization +#' (number of factors). #' #' @return sce SingleCellExperiment object annotated with reducedDims #' diff --git a/R/liger_preprocess.R b/R/liger_preprocess.R index f77bf9d..778c393 100644 --- a/R/liger_preprocess.R +++ b/R/liger_preprocess.R @@ -4,9 +4,11 @@ #' Split merged object into multiple sce objects and extract sparse matrices: #' @param sce SingleCellExperiment object or merged objects #' @param k Inner dimension of factorization (number of factors). +#' @param unique_id_var the colData variable identifying unique samples. +#' Default is "manifest". #' #' Make a Liger object: -#' @param take.gene.union Whether to fill out raw.data matrices with union +#' @param take_gene_union Whether to fill out raw.data matrices with union #' of genes across all datasets (filling in 0 for missing data) #' (requires make.sparse=T) (default FALSE). #' @param remove.missing Whether to remove cells not expressing any @@ -15,7 +17,7 @@ #' not expressed in any dataset) (default TRUE). #' #' Select informative genes: -#' @param num.genes Number of genes to find for each dataset. +#' @param num_genes Number of genes to find for each dataset. #' Set to 3000 as default. #' @param combine How to combine variable genes across experiments. #' Either "union" or "intersect". @@ -26,7 +28,10 @@ #' Scale genes by root-mean-square across cells: #' #' Remove cells/genes with no expression across any genes/cells: -#' @param use.cols Treat each column as a cell (default TRUE) +#' @param use_cols Treat each column as a cell (default TRUE) +#' @param num_cores Number of cores used on user's machine to run function. +#' Default fouynd by `future::availableCores()` +#' @param ... Additional arguments. #' #' @return liger preprocessed object. #' diff --git a/R/liger_reduce_dims.R b/R/liger_reduce_dims.R index 7a763f1..654067b 100644 --- a/R/liger_reduce_dims.R +++ b/R/liger_reduce_dims.R @@ -19,9 +19,9 @@ #' this increments the random seed by 1 for each consecutive restart, #' so future factorizations of the same dataset can be run with #' one rep if necessary. (default 1) -#' @param H.init Initial values to use for H matrices. (default NULL) -#' @param W.init Initial values to use for W matrix (default NULL) -#' @param V.init Initial values to use for V matrices (default NULL) +#' @param h_init Initial values to use for H matrices. (default NULL) +#' @param w_init Initial values to use for W matrix (default NULL) +#' @param v_init Initial values to use for V matrices (default NULL) #' @param rand_seed Random seed to allow reproducible results (default 1). #' @param print_obj Print objective function values after convergence #' (default FALSE). @@ -40,6 +40,7 @@ #' sparse modalities like methylation data). (default FALSE) #' @param resolution Controls the number of communities detected. #' Higher resolution -> more communities. (default 1) +#' @param ... Additional arguments. #' #' @return liger object with H, H.norm, W, and V slots sets. #' diff --git a/R/model_celltype_freqs.R b/R/model_celltype_freqs.R index f58a9d0..2a5851a 100644 --- a/R/model_celltype_freqs.R +++ b/R/model_celltype_freqs.R @@ -6,6 +6,8 @@ #' @param celltype_var the colData variable specifying celltype or subtype #' @param dependent_var the name of the colData variable for contrasts #' @param ref_class the class of dependent_var used as reference +#' @param var_order Optional re-ordering of subset_group factor levels. Default +#' NULL. #' @param ... Additional arguments #' #' @return results_l a list of results diff --git a/R/plot_expr_by_numeric_var.r b/R/plot_expr_by_numeric_var.r index b2ab4d9..0191830 100644 --- a/R/plot_expr_by_numeric_var.r +++ b/R/plot_expr_by_numeric_var.r @@ -9,7 +9,7 @@ #' #' #' @param sce a SingleCellExperiment object -#' @param group_var The colData variable for x-axis groups +#' @param numeric_var The colData variable for x-axis groups. Default is p_tau #' @param subset_var The colData variable to subset on #' @param subset_group The specific subset_var group to subset #' @param gene The gene of interest diff --git a/R/report_de.R b/R/report_de.R index 56a2e8f..b81c0e6 100644 --- a/R/report_de.R +++ b/R/report_de.R @@ -27,7 +27,7 @@ report_de <- function(res, cli::cli_h2("Generating report for differential expression analysis") - p <- .volcano_plot( + p <- volcano_plot( dt = res, fc_threshold = fc_threshold, pval_cutoff = pval_cutoff, diff --git a/README.Rmd b/README.Rmd index dfb6753..0d59493 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,6 +28,7 @@ knitr::opts_chunk$set( [![Manual](https://img.shields.io/badge/manual-passing-brightgreen.svg?style=flat)](https://combiz.github.io/scflow-manual/) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/combiz/scFlow/issues) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0) +[![R-CMD-check](https://github.com/combiz/scFlow/workflows/R-CMD-check/badge.svg)](https://github.com/combiz/scFlow/actions) The goal of scFlow is to provide tools in R to build a complete analysis workflow for single-cell/nuclei RNA sequencing data. diff --git a/man/cluster_sce.Rd b/man/cluster_sce.Rd index b7bab05..bf72cb8 100644 --- a/man/cluster_sce.Rd +++ b/man/cluster_sce.Rd @@ -9,11 +9,8 @@ cluster_sce(sce, ...) \arguments{ \item{sce}{a SingleCellExperiment object} -\item{...}{see uwot::umap for umap options} - -\item{reduction_methods}{one or more of "PCA", "tSNE", "UMAP", "UMAP3D"} - -\item{pca_dims}{the number of pca dimensions used} +\item{...}{see uwot::umap for umap options. Includes reduction_methods one +or more of "PCA", "tSNE", "UMAP", "UMAP3D"} } \value{ sce a SingleCellExperiment object annotated with reducedDims diff --git a/man/dot-filter_sce_genes_for_de.Rd b/man/dot-filter_sce_genes_for_de.Rd index 7bf1d59..00c0838 100644 --- a/man/dot-filter_sce_genes_for_de.Rd +++ b/man/dot-filter_sce_genes_for_de.Rd @@ -23,7 +23,8 @@ Other differential gene expression: \code{\link{.preprocess_sce_for_de}()}, \code{\link{perform_de}()}, \code{\link{pseudobulk_sce}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} \keyword{internal} diff --git a/man/dot-generate_model_from_vars.Rd b/man/dot-generate_model_from_vars.Rd index c7b6d89..3daff08 100644 --- a/man/dot-generate_model_from_vars.Rd +++ b/man/dot-generate_model_from_vars.Rd @@ -39,7 +39,8 @@ Other differential gene expression: \code{\link{.preprocess_sce_for_de}()}, \code{\link{perform_de}()}, \code{\link{pseudobulk_sce}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} \keyword{internal} diff --git a/man/dot-perform_de_with_mast.Rd b/man/dot-perform_de_with_mast.Rd index 05a78d7..025b872 100644 --- a/man/dot-perform_de_with_mast.Rd +++ b/man/dot-perform_de_with_mast.Rd @@ -22,7 +22,8 @@ Other differential gene expression: \code{\link{.preprocess_sce_for_de}()}, \code{\link{perform_de}()}, \code{\link{pseudobulk_sce}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} \keyword{internal} diff --git a/man/dot-preprocess_sce_for_de.Rd b/man/dot-preprocess_sce_for_de.Rd index 1e70cd7..321102d 100644 --- a/man/dot-preprocess_sce_for_de.Rd +++ b/man/dot-preprocess_sce_for_de.Rd @@ -22,7 +22,8 @@ Other differential gene expression: \code{\link{.perform_de_with_mast}()}, \code{\link{perform_de}()}, \code{\link{pseudobulk_sce}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} \keyword{internal} diff --git a/man/dot-volcano_plot.Rd b/man/dot-volcano_plot.Rd deleted file mode 100644 index 61f6c37..0000000 --- a/man/dot-volcano_plot.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/diffexp_models.R -\name{.volcano_plot} -\alias{.volcano_plot} -\title{volcano plot} -\usage{ -.volcano_plot(dt, fc_threshold = 1.05, pval_cutoff = 0.05, n_label = 10) -} -\description{ -volcano plot -} -\keyword{internal} diff --git a/man/find_cells.Rd b/man/find_cells.Rd index 7c371bc..cec2c56 100644 --- a/man/find_cells.Rd +++ b/man/find_cells.Rd @@ -29,8 +29,6 @@ the parameter from the top \code{expect_cells} cells (cellranger method).} \item{expect_cells}{the number of cells expected for auto retain} \item{...}{additional arguments for uniformity testing} - -\item{alpha}{minimum FDR for \code{\link[DropletUtils:emptyDrops]{DropletUtils::emptyDrops()}}} } \value{ sce a SingleCellExperiment object annotated with emptyDrops metrics diff --git a/man/integrate_sce.Rd b/man/integrate_sce.Rd index 839e924..f81e198 100644 --- a/man/integrate_sce.Rd +++ b/man/integrate_sce.Rd @@ -9,12 +9,11 @@ integrate_sce(sce, method = "Liger", ...) \arguments{ \item{sce}{a SingleCellExperiment object or merged sce objects} -\item{method}{the integration method to use} - -\item{...}{Additional arguments} - -\item{k}{Inner dimension of factorization (number of factors). +\item{method}{the integration method to use Set to k=30 as default.} + +\item{...}{Additional arguments. Such as k Inner dimension of factorization +(number of factors).} } \value{ sce SingleCellExperiment object annotated with reducedDims diff --git a/man/liger_preprocess.Rd b/man/liger_preprocess.Rd index ff5e590..6afc823 100644 --- a/man/liger_preprocess.Rd +++ b/man/liger_preprocess.Rd @@ -21,10 +21,17 @@ liger_preprocess( \arguments{ \item{sce}{SingleCellExperiment object or merged objects} -\item{k}{Inner dimension of factorization (number of factors). +\item{k}{Inner dimension of factorization (number of factors).} + +\item{unique_id_var}{the colData variable identifying unique samples. +Default is "manifest". Make a Liger object:} +\item{take_gene_union}{Whether to fill out raw.data matrices with union +of genes across all datasets (filling in 0 for missing data) +(requires make.sparse=T) (default FALSE).} + \item{remove.missing}{Whether to remove cells not expressing any measured genes, and genes not expressed in any cells (if take.gene.union = T, removes only genes @@ -32,6 +39,9 @@ not expressed in any dataset) (default TRUE). Select informative genes:} +\item{num_genes}{Number of genes to find for each dataset. +Set to 3000 as default.} + \item{combine}{How to combine variable genes across experiments. Either "union" or "intersect". (default "union")} @@ -43,14 +53,12 @@ Scale genes by root-mean-square across cells: Remove cells/genes with no expression across any genes/cells:} -\item{take.gene.union}{Whether to fill out raw.data matrices with union -of genes across all datasets (filling in 0 for missing data) -(requires make.sparse=T) (default FALSE).} +\item{use_cols}{Treat each column as a cell (default TRUE)} -\item{num.genes}{Number of genes to find for each dataset. -Set to 3000 as default.} +\item{num_cores}{Number of cores used on user's machine to run function. +Default fouynd by \code{future::availableCores()}} -\item{use.cols}{Treat each column as a cell (default TRUE)} +\item{...}{Additional arguments.} } \value{ liger preprocessed object. diff --git a/man/liger_reduce_dims.Rd b/man/liger_reduce_dims.Rd index 386b0d2..38029c3 100644 --- a/man/liger_reduce_dims.Rd +++ b/man/liger_reduce_dims.Rd @@ -50,6 +50,12 @@ this increments the random seed by 1 for each consecutive restart, so future factorizations of the same dataset can be run with one rep if necessary. (default 1)} +\item{h_init}{Initial values to use for H matrices. (default NULL)} + +\item{w_init}{Initial values to use for W matrix (default NULL)} + +\item{v_init}{Initial values to use for V matrices (default NULL)} + \item{rand_seed}{Random seed to allow reproducible results (default 1).} \item{print_obj}{Print objective function values after convergence @@ -76,11 +82,7 @@ sparse modalities like methylation data). (default FALSE)} \item{resolution}{Controls the number of communities detected. Higher resolution -> more communities. (default 1)} -\item{H.init}{Initial values to use for H matrices. (default NULL)} - -\item{W.init}{Initial values to use for W matrix (default NULL)} - -\item{V.init}{Initial values to use for V matrices (default NULL)} +\item{...}{Additional arguments.} } \value{ liger object with H, H.norm, W, and V slots sets. diff --git a/man/model_celltype_freqs.Rd b/man/model_celltype_freqs.Rd index 42cdcbd..872adae 100644 --- a/man/model_celltype_freqs.Rd +++ b/man/model_celltype_freqs.Rd @@ -25,6 +25,9 @@ model_celltype_freqs( \item{ref_class}{the class of dependent_var used as reference} +\item{var_order}{Optional re-ordering of subset_group factor levels. Default +NULL.} + \item{...}{Additional arguments} } \value{ diff --git a/man/perform_de.Rd b/man/perform_de.Rd index 8fbbb31..7db7b0e 100644 --- a/man/perform_de.Rd +++ b/man/perform_de.Rd @@ -64,6 +64,7 @@ Other differential gene expression: \code{\link{.perform_de_with_mast}()}, \code{\link{.preprocess_sce_for_de}()}, \code{\link{pseudobulk_sce}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} diff --git a/man/plot_expr_by_numeric_var.Rd b/man/plot_expr_by_numeric_var.Rd index 975e715..89509c3 100644 --- a/man/plot_expr_by_numeric_var.Rd +++ b/man/plot_expr_by_numeric_var.Rd @@ -18,6 +18,8 @@ plot_expr_by_numeric_var( \arguments{ \item{sce}{a SingleCellExperiment object} +\item{numeric_var}{The colData variable for x-axis groups. Default is p_tau} + \item{subset_var}{The colData variable to subset on} \item{subset_group}{The specific subset_var group to subset} @@ -29,8 +31,6 @@ plot_expr_by_numeric_var( \item{size}{point size} \item{label_angle}{The angle of x-axis labels (e.g. 0, 45)} - -\item{group_var}{The colData variable for x-axis groups} } \value{ p a ggplot object diff --git a/man/pseudobulk_sce.Rd b/man/pseudobulk_sce.Rd index 712f6df..c2cc7c6 100644 --- a/man/pseudobulk_sce.Rd +++ b/man/pseudobulk_sce.Rd @@ -38,6 +38,7 @@ Other differential gene expression: \code{\link{.perform_de_with_mast}()}, \code{\link{.preprocess_sce_for_de}()}, \code{\link{perform_de}()}, -\code{\link{report_de}()} +\code{\link{report_de}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} diff --git a/man/report_de.Rd b/man/report_de.Rd index 8c04765..a5c3d5a 100644 --- a/man/report_de.Rd +++ b/man/report_de.Rd @@ -36,6 +36,7 @@ Other differential gene expression: \code{\link{.perform_de_with_mast}()}, \code{\link{.preprocess_sce_for_de}()}, \code{\link{perform_de}()}, -\code{\link{pseudobulk_sce}()} +\code{\link{pseudobulk_sce}()}, +\code{\link{volcano_plot}()} } \concept{differential gene expression} diff --git a/man/volcano_plot.Rd b/man/volcano_plot.Rd new file mode 100644 index 0000000..140b360 --- /dev/null +++ b/man/volcano_plot.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/diffexp_models.R +\name{volcano_plot} +\alias{volcano_plot} +\title{Plot volcano plot for differential expression analysis} +\usage{ +volcano_plot(dt, fc_threshold = 1.05, pval_cutoff = 0.05, n_label = 10) +} +\arguments{ +\item{dt}{Differential expression result table from perform_de() function.} + +\item{fc_threshold}{Fold change threshold for the volcano plot. This will be adjusted and plotted as the log2 fold change. Default is 1.05.} + +\item{pval_cutoff}{The adjusted p-value cut-off for the volcano plot. Default is 0.05.} + +\item{n_label}{The number of top up & down differentially expressed genes to be labeled. Default is 10.} +} +\value{ +No return. The plot is printed out. +} +\description{ +Plot volcano plot for differential expression analysis +} +\seealso{ +Other differential gene expression: +\code{\link{.filter_sce_genes_for_de}()}, +\code{\link{.generate_model_from_vars}()}, +\code{\link{.perform_de_with_mast}()}, +\code{\link{.preprocess_sce_for_de}()}, +\code{\link{perform_de}()}, +\code{\link{pseudobulk_sce}()}, +\code{\link{report_de}()} +} +\concept{differential gene expression}