Skip to content

Commit

Permalink
Merge pull request #95 from zhanghao-njmu/develop
Browse files Browse the repository at this point in the history
fix bugs for CellCorHeatmap
  • Loading branch information
zhanghao-njmu authored Jan 28, 2023
2 parents 159df59 + 9861983 commit e699cc5
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 108 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Imports:
sf,
simplifyEnrichment (>= 1.5.2),
slingshot,
stringr,
uwot
Remotes:
jokergoo/ComplexHeatmap,
Expand Down
5 changes: 1 addition & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export(adata_to_srt)
export(adjcolors)
export(as_matrix)
export(blendcolors)
export(capitalize)
export(check_DataType)
export(check_Python)
export(check_R)
Expand Down Expand Up @@ -456,10 +457,6 @@ importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,var)
importFrom(stats,xtabs)
importFrom(stringr,str_extract)
importFrom(stringr,str_replace)
importFrom(stringr,str_split)
importFrom(stringr,str_wrap)
importFrom(utils,askYesNo)
importFrom(utils,capture.output)
importFrom(utils,download.file)
Expand Down
2 changes: 1 addition & 1 deletion R/SCP-analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ AddModuleScore2 <- function(object, slot = "data", features, pool = NULL, nbin =
#' )
#' ClassDimPlot(panc_merge, group.by = c("tech", "celltype", "SubCellType", "Phase"))
#'
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub[["RNA"]])))
#' genenames <- make.unique(capitalize(rownames(panc8_sub[["RNA"]]), force_tolower = TRUE))
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames, assay = "RNA")
#' head(rownames(panc8_sub))
#' panc_merge <- Integration_SCP(
Expand Down
6 changes: 3 additions & 3 deletions R/SCP-cell_annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NULL
#' # Annotate using single cell RNA-seq data
#' data("panc8_sub")
#' # Simply convert genes from human to mouse and preprocess the data
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
#'
Expand Down Expand Up @@ -509,7 +509,7 @@ RunKNNPredict <- function(srt_query, srt_ref = NULL, bulk_ref = NULL,
#' @examples
#' data("panc8_sub")
#' # Simply convert genes from human to mouse and preprocess the data
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
#'
Expand Down Expand Up @@ -651,7 +651,7 @@ RunScmap <- function(srt_query, srt_ref, ref_group = NULL, method = "scmapCluste
#' @examples
#' data("panc8_sub")
#' # Simply convert genes from human to mouse and preprocess the data
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
#' panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
#' panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
#'
Expand Down
172 changes: 84 additions & 88 deletions R/SCP-plot.R

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/SCP-workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ RecoverCounts <- function(srt, assay = NULL, trans = c("expm1", "exp", "none"),
#' data("panc8_sub")
#' head(rownames(panc8_sub))
#' # Simply convert genes from human to mouse and preprocess the data
#' genenames <- make.unique(stringr::str_to_title(rownames(panc8_sub)))
#' genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
#' panc8_rename <- RenameFeatures(panc8_sub, newnames = genenames)
#' head(rownames(panc8_rename))
#'
Expand Down
22 changes: 22 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,25 @@ as_matrix <- function(matrix) {
colnames(out) <- matrix@Dimnames[[2]]
return(out)
}

#' Capitalizes the characters
#' Making the first letter uppercase
#'
#' @param x A vector of character strings to be capitalized.
#' @param force_tolower Whether to force the remaining letters to be lowercase.
#' @export
capitalize <- function(x, force_tolower = FALSE) {
if (!inherits(x, "character")) {
stop("x must be the type of character.")
}
if (isTRUE(force_tolower)) {
paste(toupper(substr(x, 1, 1)), tolower(substr(x, 2, nchar(x))), sep = "")
} else {
paste(toupper(substr(x, 1, 1)), substr(x, 2, nchar(x)), sep = "")
}
}

str_wrap <- function(x, width = 80) {
x_wrap <- unlist(lapply(x, function(i) paste0(strwrap(i, width = width), collapse = "\n")))
return(x_wrap)
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ClassDimPlot(
### Cell projection between single-cell datasets

```{r RunKNNMap}
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(stringr::str_to_title(rownames(panc8_sub))), assays = "RNA")
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE)), assays = "RNA")
pancreas_sub <- RunKNNMap(srt_query = pancreas_sub, srt_ref = panc8_rename, ref_umap = "SeuratUMAP2D")
ProjectionPlot(
srt_query = pancreas_sub, srt_ref = panc8_rename,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ ClassDimPlot(
### Cell projection between single-cell datasets

``` r
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(stringr::str_to_title(rownames(panc8_sub))), assays = "RNA")
panc8_rename <- RenameFeatures(srt = panc8_sub, newnames = make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE)), assays = "RNA")
pancreas_sub <- RunKNNMap(srt_query = pancreas_sub, srt_ref = panc8_rename, ref_umap = "SeuratUMAP2D")
ProjectionPlot(
srt_query = pancreas_sub, srt_ref = panc8_rename,
Expand Down
Binary file modified README/README-RunKNNPredict-scrna-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/CellCorHeatmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/CellScoring.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/RenameFeatures.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/RunKNNPredict.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/RunScmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/RunSingleR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/capitalize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/conda_install.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/palette_scp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e699cc5

Please sign in to comment.