Skip to content

Commit

Permalink
Merge pull request #142 from samuel-marsh/release/2.0.1
Browse files Browse the repository at this point in the history
Release/2.0.1
  • Loading branch information
samuel-marsh authored Nov 20, 2023
2 parents eb17b70 + 41c7dbc commit 3973745
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 35 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 2.0.0
Date: 2023-11-14 01:30:08 UTC
SHA: 8987da5397b33ac79a5a3a08da9f7eccfac71a03
Version: 2.0.1
Date: 2023-11-17 15:28:31 UTC
SHA: 2bf5f1166ee097878adef4e10d1a3923db44557b
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: scCustomize
Type: Package
Title: Custom Visualizations & Functions for Streamlined Analyses of Single Cell Sequencing
Description: Collection of functions created and/or curated to aid in the visualization and analysis of single-cell data using 'R'. 'scCustomize' aims to provide 1) Customized visualizations for aid in ease of use and to create more aesthetic and functional visuals. 2) Improve speed/reproducibility of common tasks/pieces of code in scRNA-seq analysis with a single or group of functions. For citation please use: Marsh SE (2021) "Custom Visualizations & Functions for Streamlined Analyses of Single Cell Sequencing" <doi:10.5281/zenodo.5706430>.
Version: 2.0.0
Date: 2023-11-13
Description: Collection of functions created and/or curated to aid in the visualization and analysis of single-cell data using 'R'. 'scCustomize' aims to provide 1) Customized visualizations for aid in ease of use and to create more aesthetic and functional visuals. 2) Improve speed/reproducibility of common tasks/pieces of code in scRNA-seq analysis with a single or group of functions. For citation please use: Marsh SE (2021) "Custom Visualizations & Functions for Streamlined Analyses of Single Cell Sequencing" <doi:10.5281/zenodo.5706430> RRID:SCR_024675.
Version: 2.0.1
Date: 2023-11-17
Authors@R: c(
person(given = "Samuel", family = "Marsh", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3012-6945")),
person(given = "Ming", family = "Tang", role = c("ctb"), email = "[email protected]"),
Expand Down
17 changes: 17 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# scCustomize 2.0.1 (2023-11-17)
## Added
- None.


## Changed
- Removed warning in `VariableFeaturePlot_scCustom` now fixed in Seurat release.


## Fixes
- Fixed error in `Add_Mito_Ribo_Seurat` causing failure due to error message when `overwrite = TRUE`.
- Fixed error in `Add_Top_Gene_Pct_Seurat` to avoid issue that accidentally could call function on normalized data.
- Fixed error in `Add_Top_Gene_Pct_Seurat` that caused error if more than one counts layer was present.
- Fixed error in `QC_Histogram` that prevented plotting or titling of plots.



# scCustomize 2.0.0 (2023-11-13)
## Added
- Added support for metrics produced by Cell Ranger `multi` pipeline to `Read10X_Metrics` via new parameter `cellranger_multi`.
Expand Down
4 changes: 2 additions & 2 deletions R/Internal_Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ Retrieve_Ensembl_Ribo <- function(
)
}
cli_inform(message = c("Columns with {.val {oxphos_name}} and/or {.val {apop_name}} already present in meta.data slot.",
"i" = "Overwriting those columns as .code {overwrite = TRUE.}")
"i" = "Overwriting those columns as {.code overwrite = TRUE.}")
)
}

Expand Down Expand Up @@ -739,7 +739,7 @@ Retrieve_Ensembl_Ribo <- function(
)
}
cli_inform(message = c("Column with {.val {ieg_name}} already present in meta.data slot.",
"i" = "Overwriting those column as .code {overwrite = TRUE.}")
"i" = "Overwriting those column as {.code overwrite = TRUE.}")
)
}

Expand Down
52 changes: 43 additions & 9 deletions R/Object_Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Add_Mito_Ribo_Seurat <- function(
)
}
cli_inform(message = c("Columns with {.val {mito_name}} and/or {.val {ribo_name}} already present in meta.data slot.",
"i" = "Overwriting those columns as .code {overwrite = TRUE.}")
"i" = "Overwriting those columns as {.code overwrite = TRUE.}")
)
}

Expand Down Expand Up @@ -391,9 +391,10 @@ Add_Cell_Complexity_Seurat <- function(
#' storing corrected and uncorrected assays in same object (e.g. outputs of both Cell Ranger and Cell Bender).
#' @param overwrite Logical. Whether to overwrite existing an meta.data column. Default is FALSE meaning that
#' function will abort if column with name provided to `meta_col_name` is present in meta.data slot.
#' @param verbose logical, whether to print messages with status updates, default is TRUE.
#'
#' @import cli
#' @importFrom dplyr select all_of
#' @importFrom dplyr select all_of bind_rows
#' @importFrom magrittr "%>%"
#' @importFrom rlang is_installed
#' @importFrom SeuratObject LayerData
Expand Down Expand Up @@ -425,7 +426,8 @@ Add_Top_Gene_Pct_Seurat <- function(
num_top_genes = 50,
meta_col_name = NULL,
assay = "RNA",
overwrite = FALSE
overwrite = FALSE,
verbose = TRUE
){
# Check for scuttle first
scuttle_check <- is_installed(pkg = "scuttle")
Expand Down Expand Up @@ -468,15 +470,47 @@ Add_Top_Gene_Pct_Seurat <- function(
)
}

count_layers_present <- Layers(object = seurat_object, search = "counts")

# Extract matrix
count_mat <- LayerData(object = seurat_object, assay = assay)
if (length(x = count_layers_present) == 1) {
if (isTRUE(x = verbose)) {
cli_inform(message = "Calculating percent expressing top {num_top_genes} for layer: {.field {count_layers_present}}")
}

count_mat <- LayerData(object = seurat_object, assay = assay, layer = "counts")

# calculate
res <- as.data.frame(scuttle::perCellQCMetrics(x = count_mat, percent.top = num_top_genes))

# select percent column
res <- res %>%
select(all_of(scuttle_colname))
}


if (length(x = count_layers_present) > 1) {
res_list <- lapply(1:length(x = count_layers_present), function(x) {
if (isTRUE(x = verbose)) {
cli_inform(message = "Calculating percent expressing top {num_top_genes} for layer: {.field {count_layers_present[x]}}")
}

# calculate
res <- as.data.frame(scuttle::perCellQCMetrics(x = count_mat, percent.top = num_top_genes))
# Get layer data
layer_count <- LayerData(object = seurat_object, assay = assay, layer = count_layers_present[x])

# select percent column
res <- res %>%
select(all_of(scuttle_colname))
# run scuttle
layer_res <- as.data.frame(scuttle::perCellQCMetrics(x = layer_count, percent.top = num_top_genes))
# select results column
layer_res <- layer_res %>%
select(all_of(scuttle_colname))
})

# combine results
if (isTRUE(x = verbose)) {
cli_inform(message = "Combining data from: {.field {count_layers_present}}")
}
res <- bind_rows(res_list)
}

# Add to object and return
seurat_object <- AddMetaData(object = seurat_object, metadata = res, col.name = meta_col_name)
Expand Down
10 changes: 6 additions & 4 deletions R/QC_Plotting_Seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,14 @@ QC_Histogram <- function(
}

# Check and set titles
if (is.null(x = plot_title) && is.null(x = split.by)) {
plot_titles <- all_found_features
if (!is.null(x = plot_title) && length(x = plot_title) != length(x = features)) {
cli_abort(message = "The number of {.code plot_title} (.field {length(x = plot_title)}}) does not equal number of features ({.field {length(x = all_found_features)}})")
} else {
plot_titles <- plot_title
}

if (!is.null(x = plot_title) && length(x = plot_title) != features) {
cli_abort(message = "The number of {.code plot_title} (.field {length(x = plot_title)}}) does not equal number of features ({.field {length(x = all_found_features)}})")
if (is.null(x = plot_title) && is.null(x = split.by)) {
plot_titles <- all_found_features
}

# Plot
Expand Down
6 changes: 0 additions & 6 deletions R/Seurat_Plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -2582,12 +2582,6 @@ VariableFeaturePlot_scCustom <- function(
# set assay (if null set to active assay)
assay <- assay %||% DefaultAssay(object = seurat_object)

if (isTRUE(x = Assay5_Check(seurat_object = seurat_object, assay = assay))) {
cli_inform(message = c("!" = "Currently labeling top variable genes from Assay5 object will not correctly label top variable features due to changes in Seurat5.",
"i" = "This feature will be updated when more information comes from Seurat Dev team.",
"i" = "For now the top variable features can be manually extracted and provided to {.code custom_features} parameter."))
}

# Extract num of desired features
top_features <- head(x = VariableFeatures(object = seurat_object, assay = assay, selection.method = selection.method), num_features)

Expand Down
10 changes: 4 additions & 6 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
## Minor Version Update
This is a major version update to v2.0.0. In this version I have:
This is a hotfix update with bug fixes now v2.0.1; apologies for not catching these in v2.0.0 submission last week. In this version I have:

- Added a number of new functions, added new function parameters, and fixed bugs (see News.md).
- Ensured compatibility with major version of Seurat package.
- Fixed in example code causing current CRAN check errors with current package version (v1.1.3).
- Fixed 5 minor bugs presented in v2.0.0 release.


## R CMD check results
Expand All @@ -29,5 +27,5 @@ This is a major version update to v2.0.0. In this version I have:
- The errors are from failures running package examples. This includes functions that have been part of prior CRAN releases.
NO errors are found when checking locally on macos platform using R 4.3.2 and none are found in GitHub Actions check on linux
or windows platforms. I believe to be error in GitHub Actions workflow and I have therefore refrained from adding `dontrun`
to examples that run fine on other platforms. If error occurs during CRAN check during submission I will re-evaluate changes
required.
to examples that run fine on other platforms. This was also the case with v2.0.0 which passed macos checks on CRAN,
furthering it is likely a GitHub Actions issue.
5 changes: 4 additions & 1 deletion man/Add_Top_Gene_Pct_Seurat.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/scCustomize-package.Rd

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

0 comments on commit 3973745

Please sign in to comment.