Skip to content

Commit

Permalink
Merge pull request #150 from zhanghao-njmu/develop
Browse files Browse the repository at this point in the history
fix bugs in CellQC function
  • Loading branch information
zhanghao-njmu authored Aug 29, 2023
2 parents bf814dd + 90caca4 commit 4315323
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions R/SCP-cellqc.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ isOutlier <- function(x, nmads = 2.5, constant = 1.4826, type = c("both", "lower
#' plot_type = "upset", stat_level = "Fail"
#' )
#' table(ifnb_sub$CellQC)
#' @importFrom Seurat Assays as.SingleCellExperiment PercentageFeatureSet WhichCells SplitObject
#' @importFrom Seurat Assays as.SingleCellExperiment PercentageFeatureSet WhichCells SplitObject AddMetaData
#' @importFrom stats loess predict aggregate
#' @importFrom Matrix colSums t
#' @export
Expand Down Expand Up @@ -337,6 +337,7 @@ RunCellQC <- function(srt, assay = "RNA", batch = NULL,
if (!paste0("nFeature_", assay) %in% colnames(srt@meta.data)) {
srt@meta.data[[paste0("nFeature_", assay)]] <- colSums(srt[[assay]]@counts > 0)
}
srt_raw <- srt
if (!is.null(batch)) {
srtList <- SplitObject(srt, split.by = batch)
} else {
Expand Down Expand Up @@ -475,9 +476,9 @@ RunCellQC <- function(srt, assay = "RNA", batch = NULL,
}
srtList[[i]] <- srt
}
if (length(srtList) > 1) {
return(Reduce(merge, srtList))
} else {
return(srtList[[1]])
}
cells <- unlist(lapply(srtList, colnames))
srt_raw <- srt_raw[, cells]
meta.data <- do.call(rbind.data.frame, unname(lapply(srtList, function(x) x@meta.data)))
srt_raw <- AddMetaData(srt_raw, metadata = meta.data)
return(srt_raw)
}
4 changes: 2 additions & 2 deletions R/SCP-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -13121,8 +13121,8 @@ EnrichmentPlot <- function(srt, db = "GO_BP", group_by = NULL, group_use = NULL,
guides(linewidth = guide_legend(override.aes = list(alpha = 1, color = "grey"), order = 2)) +
scale_fill_manual(
name = switch(enrichmap_label,
"term" = "Gene:",
"gene" = "Term:"
"term" = "Feature:",
"feature" = "Term:"
),
values = palette_scp(levels(df_nodes[["clusters"]]), palette = palette, palcolor = palcolor),
labels = if (enrichmap_label == "term") df_keyword2[levels(df_nodes[["clusters"]]), "label"] else df_keyword1[levels(df_nodes[["clusters"]]), "label"],
Expand Down

0 comments on commit 4315323

Please sign in to comment.