Skip to content

Commit e699cc5

Browse files
Merge pull request #95 from zhanghao-njmu/develop
fix bugs for CellCorHeatmap
2 parents 159df59 + 9861983 commit e699cc5

19 files changed

+141
-108
lines changed

DESCRIPTION

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ Imports:
5454
sf,
5555
simplifyEnrichment (>= 1.5.2),
5656
slingshot,
57-
stringr,
5857
uwot
5958
Remotes:
6059
jokergoo/ComplexHeatmap,

NAMESPACE

+1-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export(adata_to_srt)
111111
export(adjcolors)
112112
export(as_matrix)
113113
export(blendcolors)
114+
export(capitalize)
114115
export(check_DataType)
115116
export(check_Python)
116117
export(check_R)
@@ -456,10 +457,6 @@ importFrom(stats,sd)
456457
importFrom(stats,setNames)
457458
importFrom(stats,var)
458459
importFrom(stats,xtabs)
459-
importFrom(stringr,str_extract)
460-
importFrom(stringr,str_replace)
461-
importFrom(stringr,str_split)
462-
importFrom(stringr,str_wrap)
463460
importFrom(utils,askYesNo)
464461
importFrom(utils,capture.output)
465462
importFrom(utils,download.file)

R/SCP-analysis.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ AddModuleScore2 <- function(object, slot = "data", features, pool = NULL, nbin =
655655
#' )
656656
#' ClassDimPlot(panc_merge, group.by = c("tech", "celltype", "SubCellType", "Phase"))
657657
#'
658-
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub[["RNA"]])))
658+
#' genenames <- make.unique(capitalize(rownames(panc8_sub[["RNA"]]), force_tolower = TRUE))
659659
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames, assay = "RNA")
660660
#' head(rownames(panc8_sub))
661661
#' panc_merge <- Integration_SCP(

R/SCP-cell_annotation.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ NULL
4848
#' # Annotate using single cell RNA-seq data
4949
#' data("panc8_sub")
5050
#' # Simply convert genes from human to mouse and preprocess the data
51-
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
51+
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
5252
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
5353
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
5454
#'
@@ -509,7 +509,7 @@ RunKNNPredict <- function(srt_query, srt_ref = NULL, bulk_ref = NULL,
509509
#' @examples
510510
#' data("panc8_sub")
511511
#' # Simply convert genes from human to mouse and preprocess the data
512-
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
512+
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
513513
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
514514
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
515515
#'
@@ -651,7 +651,7 @@ RunScmap <- function(srt_query, srt_ref, ref_group = NULL, method = "scmapCluste
651651
#' @examples
652652
#' data("panc8_sub")
653653
#' # Simply convert genes from human to mouse and preprocess the data
654-
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
654+
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
655655
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
656656
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
657657
#'

R/SCP-plot.R

+84-88
Large diffs are not rendered by default.

R/SCP-workflow.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ RecoverCounts <- function(srt, assay = NULL, trans = c("expm1", "exp", "none"),
411411
#' data("panc8_sub")
412412
#' head(rownames(panc8_sub))
413413
#' # Simply convert genes from human to mouse and preprocess the data
414-
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
414+
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
415415
#' panc8_rename <- RenameFeatures(panc8_sub, newnames = genenames)
416416
#' head(rownames(panc8_rename))
417417
#'

R/utils.R

+22
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,25 @@ as_matrix <- function(matrix) {
614614
colnames(out) <- matrix@Dimnames[[2]]
615615
return(out)
616616
}
617+
618+
#' Capitalizes the characters
619+
#' Making the first letter uppercase
620+
#'
621+
#' @param x A vector of character strings to be capitalized.
622+
#' @param force_tolower Whether to force the remaining letters to be lowercase.
623+
#' @export
624+
capitalize <- function(x, force_tolower = FALSE) {
625+
if (!inherits(x, "character")) {
626+
stop("x must be the type of character.")
627+
}
628+
if (isTRUE(force_tolower)) {
629+
paste(toupper(substr(x, 1, 1)), tolower(substr(x, 2, nchar(x))), sep = "")
630+
} else {
631+
paste(toupper(substr(x, 1, 1)), substr(x, 2, nchar(x)), sep = "")
632+
}
633+
}
634+
635+
str_wrap <- function(x, width = 80) {
636+
x_wrap <- unlist(lapply(x, function(i) paste0(strwrap(i, width = width), collapse = "\n")))
637+
return(x_wrap)
638+
}

README.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ClassDimPlot(
266266
### Cell projection between single-cell datasets
267267

268268
```{r RunKNNMap}
269-
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(stringr::str_to_title(rownames(panc8_sub))), assays = "RNA")
269+
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE)), assays = "RNA")
270270
pancreas_sub <- RunKNNMap(srt_query = pancreas_sub, srt_ref = panc8_rename, ref_umap = "SeuratUMAP2D")
271271
ProjectionPlot(
272272
srt_query = pancreas_sub, srt_ref = panc8_rename,

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ ClassDimPlot(
331331
### Cell projection between single-cell datasets
332332

333333
``` r
334-
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(stringr::str_to_title(rownames(panc8_sub))), assays = "RNA")
334+
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE)), assays = "RNA")
335335
pancreas_sub <- RunKNNMap(srt_query = pancreas_sub, srt_ref = panc8_rename, ref_umap = "SeuratUMAP2D")
336336
ProjectionPlot(
337337
srt_query = pancreas_sub, srt_ref = panc8_rename,
13.1 KB
Loading

man/CellCorHeatmap.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/CellScoring.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/RenameFeatures.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/RunKNNPredict.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/RunScmap.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/RunSingleR.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/capitalize.Rd

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/conda_install.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/palette_scp.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)