diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 2aed5bc..1c81026 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,19 +1,15 @@ -# 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 +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master - - devel + branches: [main, master, devel] pull_request: - branches: - - main - - master - - devel + branches: [main, master, devel] name: R-CMD-check +permissions: read-all + jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -24,67 +20,33 @@ jobs: fail-fast: false matrix: config: + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + #- {os: ubuntu-latest, r: 'oldrel-1'} env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + extra-packages: any::rcmdcheck + needs: check - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check - - - name: Test coverage - run: covr::codecov() - shell: Rscript {0} \ No newline at end of file + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index 85ea3f7..27a9479 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -52,9 +52,11 @@ jobs: fail-fast: false matrix: config: - - { os: ubuntu-latest, r: '4.0', bioc: '3.12', cont: "bioconductor/bioconductor_docker:RELEASE_3_12", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - - { os: macOS-latest, r: '4.0', bioc: '3.12'} - - { os: windows-latest, r: '4.0', bioc: '3.12'} + - { os: ubuntu-latest, r: '4.4', bioc: '3.19', cont: "bioconductor/bioconductor_docker:RELEASE_3_19", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" } + - { os: macOS-latest, r: '4.4', bioc: '3.19'} + - { os: windows-latest, r: '4.4', bioc: '3.19'} + ## Check https://github.com/r-lib/actions/tree/master/examples + ## for examples using the http-user-agent env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} @@ -77,19 +79,20 @@ jobs: ## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml ## If they update their steps, we will also need to update ours. - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 ## R is already included in the Bioconductor docker images - name: Setup R from r-lib if: runner.os != 'Linux' - uses: r-lib/actions/setup-r@master + uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} ## pandoc is already included in the Bioconductor docker images - name: Setup pandoc from r-lib if: runner.os != 'Linux' - uses: r-lib/actions/setup-pandoc@master + uses: r-lib/actions/setup-pandoc@v2 - name: Query dependencies run: | @@ -97,28 +100,28 @@ jobs: saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) shell: Rscript {0} - - name: Cache R packages + - name: Restore R package cache if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'" - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ env.R_LIBS_USER }} - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0- + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4- - name: Cache R packages on Linux if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /home/runner/work/_temp/Library - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0- + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4- - - name: Install Linux system dependencies - if: runner.os == 'Linux' - run: | - sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))') - echo $sysreqs - sudo -s eval "$sysreqs" + # - name: Install Linux system dependencies + # if: runner.os == 'Linux' + # run: | + # sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))') + # echo $sysreqs + # sudo -s eval "$sysreqs" - name: Install macOS system dependencies if: matrix.config.os == 'macOS-latest' @@ -137,6 +140,9 @@ jobs: ## For installing usethis's dependency gert brew install libgit2 + ## Required for tcltk + brew install xquartz --cask + - name: Install Windows system dependencies if: runner.os == 'Windows' run: | @@ -151,7 +157,7 @@ jobs: - name: Set BiocVersion run: | - BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE) + BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE, force = TRUE) shell: Rscript {0} - name: Install dependencies pass 1 @@ -163,9 +169,13 @@ jobs: ## https://github.com/r-lib/remotes/issues/296 ## Ideally, all dependencies should get installed in the first pass. + ## For running the checks + message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****')) + install.packages(c("rcmdcheck", "BiocCheck"), repos = BiocManager::repositories()) + ## Pass #1 at installing dependencies message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****')) - remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) + remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = FALSE, upgrade = TRUE) continue-on-error: true shell: Rscript {0} @@ -173,12 +183,7 @@ jobs: run: | ## Pass #2 at installing dependencies message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****')) - remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) - - ## For running the checks - message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****')) - remotes::install_cran("rcmdcheck") - BiocManager::install("BiocCheck") + remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE, force = TRUE) shell: Rscript {0} - name: Install BiocGenerics @@ -189,13 +194,13 @@ jobs: shell: Rscript {0} - name: Install covr - if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux' + if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux' run: | remotes::install_cran("covr") shell: Rscript {0} - name: Install pkgdown - if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux' + if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux' run: | remotes::install_cran("pkgdown") shell: Rscript {0} @@ -210,10 +215,12 @@ jobs: - name: Run CMD check env: _R_CHECK_CRAN_INCOMING_: false + DISPLAY: 99.0 run: | + options(crayon.enabled = TRUE) rcmdcheck::rcmdcheck( - args = c("--no-build-vignettes", "--no-manual", "--timings"), - build_args = c("--no-manual", "--no-resave-data"), + args = c("--no-manual", "--no-vignettes", "--timings"), + build_args = c("--no-manual", "--keep-empty-dirs", "--no-resave-data"), error_on = "warning", check_dir = "check" ) @@ -231,6 +238,8 @@ jobs: shell: Rscript {0} - name: Run BiocCheck + env: + DISPLAY: 99.0 run: | BiocCheck::BiocCheck( dir('check', 'tar.gz$', full.names = TRUE), @@ -241,40 +250,89 @@ jobs: shell: Rscript {0} - name: Test coverage - if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux' + if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux' run: | - covr::codecov() + covr::codecov(coverage = covr::package_coverage(type = "all")) shell: Rscript {0} - name: Install package - if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux' + if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux' run: R CMD INSTALL . - - name: Deploy package - if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux' - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)" - shell: bash {0} + - name: Build pkgdown site + if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux' + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} ## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE) ## at least one locally before this will work. This creates the gh-pages ## branch (erasing anything you haven't version controlled!) and ## makes the git history recognizable by pkgdown. + - name: Install deploy dependencies + if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux' + run: | + apt-get update && apt-get -y install rsync + + - name: Deploy pkgdown site to GitHub pages 🚀 + if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux' + uses: JamesIves/github-pages-deploy-action@releases/v4 + with: + clean: false + branch: gh-pages + folder: docs + - name: Upload check results if: failure() uses: actions/upload-artifact@master with: - name: ${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-results + name: ${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-results path: check - - uses: docker/build-push-action@v1 - if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && runner.os == 'Linux' " + + ## Code adapted from + ## https://github.com/waldronlab/cBioPortalData/blob/e0440a4445f0cc731e426363a76faa22ee5e0f9d/.github/workflows/devel_check_dock.yml#L65-L92 + docker-build-and-push: + runs-on: ubuntu-latest + needs: build-check + steps: + - name: Checkout Repository + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'" + uses: actions/checkout@v3 + + - name: Register repo name + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'" + id: reg_repo_name + run: | + echo CONT_IMG_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + + - name: Set up QEMU + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'" + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'" + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'" + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + ## Note that DOCKERHUB_TOKEN is really a token for your dockerhub + ## account, not your actual dockerhub account password. You can get it + ## from https://hub.docker.com/settings/security. + ## Check https://github.com/docker/build-push-action/tree/v4.0.0 + ## for more details. + ## Alternatively, try checking + ## https://seandavi.github.io/BuildABiocWorkshop/articles/HOWTO_BUILD_WORKSHOP.html. + + - name: Build and Push Docker + if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel' && success()" + uses: docker/build-push-action@v4 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: pyanglab/cepo - tag_with_ref: true - tag_with_sha: true - tags: latest + context: . + push: true + tags: > + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:latest, + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 3c908d3..70ad1e3 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,48 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master, devel] + pull_request: + branches: [main, master, devel] + release: + types: [published] + workflow_dispatch: name: pkgdown +permissions: read-all + jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") - shell: Rscript {0} + extra-packages: any::pkgdown, local::. + needs: website - - name: Install package - run: R CMD INSTALL . + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/DESCRIPTION b/DESCRIPTION index e27a888..6689a41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Cepo Title: Cepo for the identification of differentially stable genes -Version: 1.10.0 +Version: 1.10.2 Authors@R: c( person(given = "Hani Jieun", @@ -19,7 +19,7 @@ License: MIT + file LICENSE Encoding: UTF-8 LazyData: false Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.1.9001 +RoxygenNote: 7.3.1 Imports: DelayedMatrixStats, DelayedArray, @@ -35,7 +35,8 @@ Imports: reshape2, BiocParallel, stats, - dplyr + dplyr, + purrr biocViews: Classification, GeneExpression, SingleCell, Software, Sequencing, DifferentialExpression Suggests: knitr, @@ -48,8 +49,7 @@ Suggests: scMerge, fgsea, escape, - pheatmap, - patchwork + pheatmap VignetteBuilder: knitr Depends: GSEABase, diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..813fa3d --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2024 +COPYRIGHT HOLDER: Cepo authors diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9842340 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2024 Cepo authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NAMESPACE b/NAMESPACE index 77e8d11..e9ea0a6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,6 +20,8 @@ importFrom(grDevices,rainbow) importFrom(methods,is) importFrom(patchwork,plot_layout) importFrom(patchwork,wrap_plots) +importFrom(purrr,map) +importFrom(purrr,map2) importFrom(reshape2,melt) importFrom(rlang,.data) importFrom(stats,pchisq) diff --git a/R/Cepo.R b/R/Cepo.R index 436b84d..6eecf82 100644 --- a/R/Cepo.R +++ b/R/Cepo.R @@ -6,7 +6,7 @@ #' Default to NULL to not remove any genes. #' @param prefilter_sd Numeric value indicating threshold relating to standard #' deviation of genes. Used with prefilter_zeros. -#' @param prefilter_pzeros Numeric value indicating threshold relating to the +#' @param prefilter_pzero Numeric value indicating threshold relating to the #' percentage of zero expression of genes. Used with prefilter_sd. #' @param logfc Numeric value indicating the threshold of log fold-change #' to use to filter genes. @@ -39,6 +39,7 @@ #' @importFrom HDF5Array HDF5Array #' @importFrom BiocParallel SerialParam MulticoreParam SnowParam bplapply #' @importFrom stats pnorm pchisq +#' @importFrom purrr map map2 #' @import dplyr #' @return Returns a list of key genes. #' @description ExprsMat accepts various matrix objects, @@ -52,7 +53,7 @@ #' cepoOutput <- Cepo(logcounts(cellbench), cellbench$celltype) #' cepoOutput #' -Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct = NULL, +Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct = 0.05, prefilter_sd = NULL, prefilter_pzero = NULL, logfc = NULL, computePvalue = NULL, computeFastPvalue = TRUE, variability = "CV", method = "weightedMean", @@ -258,8 +259,8 @@ bootFastCepo <- function(exprsMat, cellTypes, minCells, exprsPct, logfc, variabi this_celltype_stats_matrix = purrr::map(.x = sampled_cepo_stats, .f = function(this_sampled_stats){ this_sampled_stats[,this_celltype] }) %>% do.call(cbind, .) - this_celltype_stats_mean = Cepo:::rowMeans_withnames(this_celltype_stats_matrix) - this_celltype_stats_sd = Cepo:::rowSds_withnames(this_celltype_stats_matrix) + this_celltype_stats_mean = rowMeans_withnames(this_celltype_stats_matrix) + this_celltype_stats_sd = rowSds_withnames(this_celltype_stats_matrix) return(data.frame(mean = this_celltype_stats_mean, sd = this_celltype_stats_sd)) }) names(celltype_norm_stats) = cts diff --git a/man/Cepo.Rd b/man/Cepo.Rd index c3d3b2f..459bbcc 100644 --- a/man/Cepo.Rd +++ b/man/Cepo.Rd @@ -9,7 +9,7 @@ Cepo( cellTypes, minCells = 20, minCelltype = 3, - exprsPct = NULL, + exprsPct = 0.05, prefilter_sd = NULL, prefilter_pzero = NULL, logfc = NULL, @@ -41,6 +41,9 @@ Default to NULL to not remove any genes.} \item{prefilter_sd}{Numeric value indicating threshold relating to standard deviation of genes. Used with prefilter_zeros.} +\item{prefilter_pzero}{Numeric value indicating threshold relating to the +percentage of zero expression of genes. Used with prefilter_sd.} + \item{logfc}{Numeric value indicating the threshold of log fold-change to use to filter genes.} @@ -71,9 +74,6 @@ For workers greater than 1, see the \code{workers} argument in \item{...}{Additional arguments passed to \code{BiocParallel::MulticoreParam} and \code{BiocParallel::SnowParam}.} - -\item{prefilter_pzeros}{Numeric value indicating threshold relating to the -percentage of zero expression of genes. Used with prefilter_sd.} } \value{ Returns a list of key genes. diff --git a/vignettes/cepo.Rmd b/vignettes/cepo.Rmd index 2821458..52c2b2b 100644 --- a/vignettes/cepo.Rmd +++ b/vignettes/cepo.Rmd @@ -18,6 +18,10 @@ We introduce *Cepo*, a method to determine genes governing cell identity from sc *Cepo* is therefore distinct from most methods for differential analysis (e.g., differential expression) that prioritise differences in the mean abundance between cell types. *Cepo* is able to capture subtle variations in distribution that does not necessarily involve changes in mean. *Cepo* is particularly suitable for large atlas data as it is computationally efficient and fast. Moreover, *Cepo* can perform differential stability analysis for multi-group comparisons in single-cell data. +```{r, include = FALSE} +knitr::opts_chunk$set(crop = NULL) +``` + To access the R code used in the vignettes, type: ``` browseVignettes("Cepo") @@ -283,9 +287,8 @@ We can also perform a plethora of downstream analyses, from gene set enrichment ```{r gsea, message = FALSE} library(escape) library(fgsea) -hallmark <- getGeneSets(species = "Homo sapiens", +hallmarkList <- getGeneSets(species = "Homo sapiens", library = "H") -hallmarkList <- geneIds(hallmark) fgseaRes <- fgsea(pathways = hallmarkList, stats = sort(ds_res_batches$average$stats[,"beta"]), @@ -303,8 +306,8 @@ enriched_beta[1:5] Finally, we can visualise the enrichment using the `plotEnrichment` function from the `fgsea` package. ```{r fig.height=5, fig.width=5} -plotEnrichment(hallmarkList[["HALLMARK_PANCREAS_BETA_CELLS"]], - sort(ds_res_batches$average$stats[, "beta"])) + labs(title="HALLMARK_PANCREAS_BETA_CELLS") +plotEnrichment(hallmarkList[["HALLMARK-PANCREAS-BETA-CELLS"]], + sort(ds_res_batches$average$stats[, "beta"])) + labs(title="HALLMARK-PANCREAS-BETA-CELLS") ```