Skip to content

Commit

Permalink
Increment version number to 0.1.2.9002
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghao-njmu committed Jun 18, 2022
1 parent 6d2540e commit f448617
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 510 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:

- name: Set up Linux swap space
if: runner.os == 'Linux'
uses: pierotofy/[email protected]
with:
swap-size-gb: 10

- name: Set up Windows swap space
if: runner.os == 'Windows'
uses: al-cheb/[email protected]
with:
minimum-size: 10GB

- uses: actions/checkout@v2

- name: Install system libraries
Expand All @@ -41,6 +54,7 @@ jobs:
if: ${{ matrix.config.os == 'macOS-latest' }}
run: |
brew install openssl
brew install --cask xquartz
- uses: r-lib/actions/setup-pandoc@v2

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:

- name: Set up Linux swap space
if: runner.os == 'Linux'
uses: pierotofy/[email protected]
with:
swap-size-gb: 10

- name: Set up Windows swap space
if: runner.os == 'Windows'
uses: al-cheb/[email protected]
with:
minimum-size: 10GB

- uses: actions/checkout@v2

- name: Install system libraries
Expand Down
14 changes: 6 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SCP
Type: Package
Title: Single Cell Pipeline
Version: 0.1.2.9001
Version: 0.1.2.9002
Author: Hao Zhang
Maintainer: Hao Zhang <[email protected]>
Description: The SCP package provides a comprehensive set of tools for single cell data processing and downstream analysis.
Expand Down Expand Up @@ -56,8 +56,6 @@ Imports:
symphony,
umap,
uwot,
harmony,
shiny,
rhdf5,
HDF5Array,
scDblFinder,
Expand All @@ -71,14 +69,13 @@ Imports:
harmony,
rliger,
png,
grDevices,
ggpubr,
ggVennDiagram,
ggupset,
circlize,
ggwordcloud,
MatrixGenerics,
symphony,
scmap,
SingleR,
shiny,
shinycssloaders,
styler
Expand All @@ -95,7 +92,8 @@ Suggests:
NMF,
MASS,
Mfuzz,
magick,
AUCell,
htmlwidgets
htmlwidgets,
testthat (>= 3.0.0)
RoxygenNote: 7.2.0
Config/testthat/edition: 3
10 changes: 5 additions & 5 deletions R/SCP-analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,19 @@ CellScoring <- function(srt, features, ncores = 1, method = "Seurat", classifica
#' @examples
#' library(dplyr)
#' data(pancreas1k)
#' pancreas1k <- RunDEtest(pancreas1k, group_by = "SubCellType")
#' pancreas1k <- RunDEtest(pancreas1k, group_by = "CellType")
#'
#' # Heatmap
#' de_filter <- filter(pancreas1k@tools$DEtest_SubCellType$AllMarkers_wilcox, p_val_adj < 0.01 & avg_log2FC > 1)
#' ExpHeatmapPlot(pancreas1k, genes = de_filter$gene, gene_groups = de_filter$group1, cell_group_by = "SubCellType")
#' de_filter <- filter(pancreas1k@tools$CellType$AllMarkers_wilcox, p_val_adj < 0.05 & avg_log2FC > 1)
#' ExpHeatmapPlot(pancreas1k, genes = de_filter$gene, gene_groups = de_filter$group1, cell_group_by = "CellType")
#'
#' # Dot plot
#' de_top <- de_filter %>%
#' group_by(gene) %>%
#' top_n(1, avg_log2FC) %>%
#' group_by(group1) %>%
#' top_n(3, avg_log2FC)
#' ExpDotPlot(pancreas1k, genes = de_top$gene, gene_groups = de_top$group1, cell_group_by = "SubCellType")
#' ExpDotPlot(pancreas1k, genes = de_top$gene, gene_groups = de_top$group1, cell_group_by = "CellType")
#' @export
#'
RunDEtest <- function(srt, group_by = NULL, cell_group1 = NULL, cell_group2 = NULL,
Expand Down Expand Up @@ -1300,7 +1300,7 @@ RunEnrichment <- function(geneID = NULL, geneID_groups = NULL, IDtype = "symbol"
#' if (interactive()) {
#' data("pancreas1k")
#' library(dplyr)
#' pancreas1k <- RunDEtest(pancreas1k, group_by = "CellType", only.pos = FALSE)
#' pancreas1k <- RunDEtest(pancreas1k, group_by = "CellType", only.pos = FALSE, fc.threshold = 1)
#' de_filter <- filter(pancreas1k@tools$DEtest_CellType$AllMarkers_wilcox, p_val_adj < 0.05)
#' res <- RunGSEA(geneID = de_filter$gene, geneScore = de_filter$avg_log2FC, geneID_groups = de_filter$group1, species = "Mus_musculus")
#' GSEAPlot(x = res$results[[1]], geneSetID = res$results[[1]]@result$ID[1])
Expand Down
186 changes: 96 additions & 90 deletions R/SCP-cell_annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,57 @@ Preprocess <- function() {
#' pancreas1k <- RunKNNPredict(srt_query = pancreas1k, query_group = "SubCellType", bulk_ref = SCP::ref_scMCA)
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#'
#' # Annotate using single cell RNA-seq data
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(stringr)
#' library(SeuratData)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#' if (interactive()) {
#' # Annotate using single cell RNA-seq data
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(stringr)
#' library(SeuratData)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#'
#' # Simply convert genes from human to mouse and preprocess the data
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#' # Simply convert genes from human to mouse and preprocess the data
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#'
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#' pancreas1k <- RunKNNPredict(srt_query = pancreas1k, srt_ref = panc8, ref_group = "celltype")
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#' pancreas1k <- RunKNNPredict(srt_query = pancreas1k, srt_ref = panc8, ref_group = "celltype")
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#'
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", ref_collapsing = FALSE
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_prob")
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", ref_collapsing = FALSE
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_prob")
#'
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "SubCellType", ref_group = "celltype",
#' query_collapsing = TRUE, ref_collapsing = TRUE
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "SubCellType", ref_group = "celltype",
#' query_collapsing = TRUE, ref_collapsing = TRUE
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#'
#' # Annotate with DE gene instead of HVF
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype",
#' features_type = "DE", feature_source = "ref"
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#' # Annotate with DE gene instead of HVF
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype",
#' features_type = "DE", feature_source = "ref"
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#'
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "SubCellType", ref_group = "celltype",
#' features_type = "DE", feature_source = "both"
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#' pancreas1k <- RunKNNPredict(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "SubCellType", ref_group = "celltype",
#' features_type = "DE", feature_source = "both"
#' )
#' ClassDimPlot(pancreas1k, group.by = "knnpredict_classification", label = TRUE)
#' ExpDimPlot(pancreas1k, features = "knnpredict_simil")
#' }
#' @importFrom methods as
#' @importFrom Matrix colSums t rowSums
#' @importFrom Seurat DefaultAssay GetAssayData FindVariableFeatures VariableFeatures AverageExpression
Expand Down Expand Up @@ -481,30 +483,32 @@ RunKNNPredict <- function(srt_query, srt_ref = NULL, bulk_ref = NULL,

#' Annotate single cells using scmap.
#' @examples
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(SeuratData)
#' library(stringr)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#' if (interactive()) {
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(SeuratData)
#' library(stringr)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#'
#' # Annotation
#' pancreas1k <- Standard_SCP(pancreas1k)
#' pancreas1k <- RunScmap(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", method = "scmapCluster"
#' )
#' ClassDimPlot(pancreas1k, group.by = "scmap_annotation")
#' # Annotation
#' pancreas1k <- Standard_SCP(pancreas1k)
#' pancreas1k <- RunScmap(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", method = "scmapCluster"
#' )
#' ClassDimPlot(pancreas1k, group.by = "scmap_annotation")
#'
#' pancreas1k <- RunScmap(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", method = "scmapCell"
#' )
#' ClassDimPlot(pancreas1k, group.by = "scmap_annotation")
#' pancreas1k <- RunScmap(
#' srt_query = pancreas1k, srt_ref = panc8,
#' ref_group = "celltype", method = "scmapCell"
#' )
#' ClassDimPlot(pancreas1k, group.by = "scmap_annotation")
#' }
#' @importFrom Seurat GetAssayData
#' @export
RunScmap <- function(srt_query, srt_ref, ref_group = NULL, method = "scmapCluster",
Expand Down Expand Up @@ -609,37 +613,39 @@ RunScmap <- function(srt_query, srt_ref, ref_group = NULL, method = "scmapCluste

#' Annotate single cells using scmap.
#' @examples
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(SeuratData)
#' library(stringr)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#' if (interactive()) {
#' if (!require("SeuratData", quietly = TRUE)) {
#' devtools::install_github("zhanghao-njmu/seurat-data")
#' }
#' library(SeuratData)
#' library(stringr)
#' suppressWarnings(InstallData("panc8"))
#' data("panc8")
#' genenm <- make.unique(str_to_title(rownames(panc8)))
#' panc8 <- RenameFeatures(panc8, newnames = genenm)
#' panc8 <- check_srtMerge(panc8, batch = "tech")[["srtMerge"]]
#'
#' # Annotation
#' pancreas1k <- Standard_SCP(pancreas1k)
#' pancreas1k <- RunSingleR(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "Standardclusters", ref_group = "celltype",
#' )
#' ClassDimPlot(pancreas1k, group.by = "singler_annotation")
#' # Annotation
#' pancreas1k <- Standard_SCP(pancreas1k)
#' pancreas1k <- RunSingleR(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = "Standardclusters", ref_group = "celltype",
#' )
#' ClassDimPlot(pancreas1k, group.by = "singler_annotation")
#'
#' pancreas1k <- RunSingleR(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = NULL, ref_group = "celltype"
#' )
#' ClassDimPlot(pancreas1k, group.by = "singler_annotation")
#' pancreas1k <- RunSingleR(
#' srt_query = pancreas1k, srt_ref = panc8,
#' query_group = NULL, ref_group = "celltype"
#' )
#' ClassDimPlot(pancreas1k, group.by = "singler_annotation")
#' }
#' @importFrom Seurat GetAssayData
#' @export
RunSingleR <- function(srt_query, srt_ref, query_group = NULL, ref_group = NULL,
genes = "de", de.method = "wilcox", sd.thresh = 1, de.n = NULL,
aggr.ref = FALSE, aggr.args = list(),
quantile = 0.8, fine.tune = TRUE, tune.thresh = 0.05, prune = TRUE,
BNPARAM = BiocNeighbors::KmknnParam(), BPPARAM = BiocParallel::bpparam(),
BPPARAM = BiocParallel::bpparam(),
query_assay = "RNA", ref_assay = "RNA", force = FALSE) {
if (!is.null(ref_group)) {
if (length(ref_group) == ncol(srt_ref)) {
Expand Down Expand Up @@ -713,7 +719,7 @@ RunSingleR <- function(srt_query, srt_ref, query_group = NULL, ref_group = NULL,
de.method = de.method, genes = genes, sd.thresh = sd.thresh, de.n = de.n,
aggr.ref = aggr.ref, aggr.args = aggr.args,
quantile = quantile, fine.tune = fine.tune, tune.thresh = tune.thresh, prune = prune,
BNPARAM = BNPARAM, BPPARAM = BPPARAM
BPPARAM = BPPARAM
)
names(SingleRCluster_results$labels) <- levels(factor(SummarizedExperiment::colData(sce_query)[[query_group]]))
rownames(SingleRCluster_results$scores) <- levels(factor(SummarizedExperiment::colData(sce_query)[[query_group]]))
Expand Down Expand Up @@ -748,7 +754,7 @@ RunSingleR <- function(srt_query, srt_ref, query_group = NULL, ref_group = NULL,
de.method = de.method, genes = genes, sd.thresh = sd.thresh, de.n = de.n,
aggr.ref = aggr.ref, aggr.args = aggr.args,
quantile = quantile, fine.tune = fine.tune, tune.thresh = tune.thresh, prune = prune,
BNPARAM = BNPARAM, BPPARAM = BPPARAM
BPPARAM = BPPARAM
)
srt_query$singler_annotation <- if (isTRUE(prune)) {
SingleRCell_results$pruned.labels
Expand Down
Loading

0 comments on commit f448617

Please sign in to comment.