diff --git a/.gitignore b/.gitignore index c263a01..7d3f0a9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ inst/doc /doc/ /Meta/ .Rbuildignore -test_dev \ No newline at end of file +test_dev +docs diff --git a/DESCRIPTION b/DESCRIPTION index 96dcdf3..ffeba6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ Suggests: BiocStyle, ComplexUpset, UpSetR, - patchwork + ggpubr Config/testthat/edition: 3 URL: https://github.com/BioBam/scMaSigPro/ biocViews: Clustering, Regression, TimeCourse, DifferentialExpression, diff --git a/R/plotIntersect.R b/R/plotIntersect.R index b33d9e2..266af66 100644 --- a/R/plotIntersect.R +++ b/R/plotIntersect.R @@ -7,7 +7,7 @@ #' @importFrom S4Vectors isEmpty #' @importFrom RColorConesa colorConesa #' @importFrom utils packageVersion -#' +#' #' @param scmpObj An object of class \code{\link{ScMaSigPro}}. #' @param min_intersection_size Minimal number of observations in an intersection #' for it to be included. diff --git a/R/sc.p.vector.R b/R/sc.p.vector.R index 80627ac..f86c923 100644 --- a/R/sc.p.vector.R +++ b/R/sc.p.vector.R @@ -25,6 +25,8 @@ #' @param max_it Maximum number of iterations to fit the model. #' @param parallel Use forking process to run parallelly. (Default is FALSE) #' (Currently, Windows is not supported) +#' @param n_cores Explicitly specify the number of cores to use for parallel model +#' fitting. (Default is inferred from the system using availableCores()-2) #' @param verbose Print detailed output in the console. (Default is TRUE) #' #' @return An object of class \code{\link{ScMaSigPro}}, with updated `Profile` @@ -48,6 +50,7 @@ sc.p.vector <- function(scmpObj, p_value = 0.05, mt_correction = "BH", verbose = TRUE, offset = TRUE, parallel = FALSE, + n_cores = availableCores() - 2, log_offset = FALSE, max_it = 100, link = "log") { @@ -106,12 +109,6 @@ sc.p.vector <- function(scmpObj, p_value = 0.05, mt_correction = "BH", p <- dim(dis)[2] sc.p.vector <- vector(mode = "numeric", length = g) - if (parallel == FALSE) { - if (verbose) { - pb <- txtProgressBar(min = 0, max = g, style = 3) - } - } - # Calculate offset if (offset) { dat <- dat + 1 @@ -130,13 +127,21 @@ sc.p.vector <- function(scmpObj, p_value = 0.05, mt_correction = "BH", numCores <- 1 warning("Currently, we only support sequential processing on windows based systems...") } else { - numCores <- availableCores() - 1 + n_cores <- as.integer(n_cores) + # Check Required Cores + assert_that(n_cores <= availableCores(), + msg = paste("Number of cores requested is invalid. This session has access to", as.integer(availableCores()), "cores only.") + ) + numCores <- n_cores } if (verbose) { message(paste("Running with", numCores, "cores...")) } } else { numCores <- 1 + if (verbose) { + pb <- txtProgressBar(min = 0, max = g, style = 3) + } } # Check for weight usage diff --git a/R/sc.t.fit.R b/R/sc.t.fit.R index 6c65c6a..dde8377 100644 --- a/R/sc.t.fit.R +++ b/R/sc.t.fit.R @@ -22,6 +22,8 @@ #' @param max_it Maximum number of iterations to fit the model. #' @param parallel Use forking process to run parallelly. (Default is FALSE) #' (Currently, Windows is not supported) +#' @param n_cores Explicitly specify the number of cores to use for parallel model +#' fitting. (Default is inferred from the system using availableCores()-2) #' @param verbose Print detailed output in the console. (Default is TRUE) #' #' @return An object of class \code{\link{ScMaSigPro}}, with updated `Estimate` @@ -47,6 +49,7 @@ sc.t.fit <- function(scmpObj, offset = scmpObj@Parameters@offset, verbose = TRUE, parallel = FALSE, + n_cores = availableCores() - 2, log_offset = scmpObj@Parameters@log_offset, max_it = scmpObj@Parameters@max_it, link = scmpObj@Parameters@link) { @@ -137,7 +140,12 @@ sc.t.fit <- function(scmpObj, numCores <- 1 warning("Currently, we only support sequential processing on windows based systems...") } else { - numCores <- availableCores() - 1 + n_cores <- as.integer(n_cores) + # Check Required Cores + assert_that(n_cores <= availableCores(), + msg = paste("Number of cores requested is invalid. This session has access to", as.integer(availableCores()), "cores only.") + ) + numCores <- n_cores } if (verbose) { message(paste("Running with", numCores, "cores...")) diff --git a/README.md b/README.md index b652687..1fef302 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# ScMaSigPro +scMaSigPro Logo -Implementation of MaSigPro for scRNA-Seq Data +### Implementation of MaSigPro for scRNA-Seq Data. - [![R-CMD-Check](https://github.com/BioBam/scMaSigPro/actions/workflows/r.yml/badge.svg?branch=main)](https://github.com/BioBam/scMaSigPro/actions/workflows/r.yml) [![test-coverage](https://github.com/BioBam/scMaSigPro/actions/workflows/test-coverage.yaml/badge.svg?branch=main)](https://github.com/BioBam/scMaSigPro/actions/workflows/test-coverage.yaml) +[![R-CMD-Check](https://github.com/BioBam/scMaSigPro/actions/workflows/r.yml/badge.svg?branch=main)](https://github.com/BioBam/scMaSigPro/actions/workflows/r.yml) +[![test-coverage](https://github.com/BioBam/scMaSigPro/actions/workflows/test-coverage.yaml/badge.svg?branch=main)](https://github.com/BioBam/scMaSigPro/actions/workflows/test-coverage.yaml) --- diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..505307a --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,5 @@ +url: https://github.com/BioBam/scMaSigPro +logo: man/figures/logo.png +template: + bootstrap: 5 + diff --git a/man/figures/logo.png b/man/figures/logo.png new file mode 100644 index 0000000..3b8d989 Binary files /dev/null and b/man/figures/logo.png differ diff --git a/man/sc.p.vector.Rd b/man/sc.p.vector.Rd index 1482286..95c4c4d 100644 --- a/man/sc.p.vector.Rd +++ b/man/sc.p.vector.Rd @@ -14,6 +14,7 @@ sc.p.vector( verbose = TRUE, offset = TRUE, parallel = FALSE, + n_cores = availableCores() - 2, log_offset = FALSE, max_it = 100, link = "log" @@ -42,6 +43,9 @@ model.} \item{parallel}{Use forking process to run parallelly. (Default is FALSE) (Currently, Windows is not supported)} +\item{n_cores}{Explicitly specify the number of cores to use for parallel model +fitting. (Default is inferred from the system using availableCores()-2)} + \item{log_offset}{A logical value specifying whether to take the logarithm of the offsets.} diff --git a/man/sc.t.fit.Rd b/man/sc.t.fit.Rd index e080f16..9fb73fd 100644 --- a/man/sc.t.fit.Rd +++ b/man/sc.t.fit.Rd @@ -14,6 +14,7 @@ sc.t.fit( offset = scmpObj@Parameters@offset, verbose = TRUE, parallel = FALSE, + n_cores = availableCores() - 2, log_offset = scmpObj@Parameters@log_offset, max_it = scmpObj@Parameters@max_it, link = scmpObj@Parameters@link @@ -40,6 +41,9 @@ regression.} \item{parallel}{Use forking process to run parallelly. (Default is FALSE) (Currently, Windows is not supported)} +\item{n_cores}{Explicitly specify the number of cores to use for parallel model +fitting. (Default is inferred from the system using availableCores()-2)} + \item{log_offset}{A logical value specifying whether to take the logarithm of the offsets.} diff --git a/pkgdown/favicon/apple-touch-icon-120x120.png b/pkgdown/favicon/apple-touch-icon-120x120.png new file mode 100644 index 0000000..a3a0637 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon-120x120.png differ diff --git a/pkgdown/favicon/apple-touch-icon-152x152.png b/pkgdown/favicon/apple-touch-icon-152x152.png new file mode 100644 index 0000000..984bd52 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon-152x152.png differ diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png new file mode 100644 index 0000000..7c31ff4 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png new file mode 100644 index 0000000..331a590 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png new file mode 100644 index 0000000..2470ee6 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png new file mode 100644 index 0000000..42e0a9f Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-16x16.png b/pkgdown/favicon/favicon-16x16.png new file mode 100644 index 0000000..057aab1 Binary files /dev/null and b/pkgdown/favicon/favicon-16x16.png differ diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png new file mode 100644 index 0000000..0a03464 Binary files /dev/null and b/pkgdown/favicon/favicon-32x32.png differ diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico new file mode 100644 index 0000000..49576e2 Binary files /dev/null and b/pkgdown/favicon/favicon.ico differ diff --git a/vignettes/Basic-Workflow.Rmd b/vignettes/Basic-Workflow.Rmd index 5cf3d35..a145929 100644 --- a/vignettes/Basic-Workflow.Rmd +++ b/vignettes/Basic-Workflow.Rmd @@ -319,7 +319,7 @@ By setting the vars parameter to "groups", the function will add genes with $R^2$ >= 0.7 to the object. To explore the number of genes per group, we will make an upset plot: ```{r, "uspet",eval=TRUE, echo=TRUE, fig.width=8, fig.height=6} -plotIntersect(scmp_ob, package = "ComplexUpset") +plotIntersect(scmp_ob, package = "UpSetR") ``` Here, we observe that 23 genes belong to both Path2vsPath1 and Path1, indicating @@ -333,7 +333,10 @@ FigureA <- plotTrend(scmp_ob, "Gene9", logs = TRUE, logType = "log") FigureB <- plotTrend(scmp_ob, "Gene95", logs = TRUE, logType = "log") FigureC <- plotTrend(scmp_ob, "Gene10", logs = TRUE, logType = "log") FigureD <- plotTrend(scmp_ob, "Gene92", logs = TRUE, logType = "log") -(FigureA + FigureB) / (FigureC + FigureD) +ggpubr::ggarrange(FigureA, FigureB, FigureC, FigureD, + ncol = 2, nrow = 2, + labels = c("A", "B", "C", "D") +) ``` These plots illustrate the gene expression trends for selected genes, providing diff --git a/vignettes/scMaSigPro-Class.Rmd b/vignettes/scMaSigPro-Class.Rmd index 7fc0d5f..40ce57a 100644 --- a/vignettes/scMaSigPro-Class.Rmd +++ b/vignettes/scMaSigPro-Class.Rmd @@ -246,7 +246,9 @@ for (i in rownames(head(pTime_up, 4))) { } # Plot combined -(pTime_up.plots[[1]] + pTime_up.plots[[2]]) / (pTime_up.plots[[3]] + pTime_up.plots[[4]]) +ggpubr::ggarrange(pTime_up.plots[[1]], pTime_up.plots[[2]], pTime_up.plots[[3]], pTime_up.plots[[4]], + ncol = 2, nrow = 2, labels = c("A", "B", "C", "D") +) ``` ```{r, "Pseudotime_path"} @@ -272,7 +274,7 @@ for (i in rownames(head(pTime_path_up, 4))) { } # Plot combined -(pTime_path_up.plots[[1]] + pTime_path_up.plots[[2]]) / (pTime_path_up.plots[[3]] + pTime_path_up.plots[[4]]) +ggpubr::ggarrange(pTime_path_up.plots[[1]], pTime_path_up.plots[[2]], pTime_path_up.plots[[3]], pTime_path_up.plots[[4]], ncol = 2, nrow = 2, labels = c("A", "B", "C", "D")) ``` ```{r, echo=FALSE}