Skip to content

Commit

Permalink
Smaller test dataset; change default for chunk.size=100
Browse files Browse the repository at this point in the history
  • Loading branch information
mass-a committed Feb 21, 2024
1 parent da4bc9d commit 9169c3d
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: UCell
Type: Package
Title: Rank-based signature enrichment analysis for single-cell data
Version: 2.7.3
Version: 2.7.4
Authors@R: c(
person('Massimo', 'Andreatta',
email = '[email protected]',
Expand Down
4 changes: 3 additions & 1 deletion R/AddModuleScore_UCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#'
#' @export
AddModuleScore_UCell <- function(obj, features, maxRank=1500,
chunk.size=1000, BPPARAM=NULL, ncores=1, storeRanks=FALSE,
chunk.size=100, BPPARAM=NULL, ncores=1, storeRanks=FALSE,
w_neg=1, assay=NULL, slot="counts", ties.method="average",
force.gc=FALSE, name="_UCell") {
if (!requireNamespace("Seurat", quietly = TRUE)) {
Expand All @@ -89,6 +89,7 @@ AddModuleScore_UCell <- function(obj, features, maxRank=1500,
if (is.null(layers)) {
stop(sprintf("Cannot find layer %s in assay %s", slot, assay))
}

meta.list <- lapply(layers, function(x) {
calculate_Uscore(
Seurat::GetAssayData(obj, layer=x, assay=assay),
Expand All @@ -97,6 +98,7 @@ AddModuleScore_UCell <- function(obj, features, maxRank=1500,
ncores=ncores, BPPARAM=BPPARAM, ties.method=ties.method,
force.gc=force.gc, storeRanks=storeRanks, name=name)
})

meta.list <- unlist(meta.list, recursive = FALSE)
#store ranks matrix?
if (storeRanks==TRUE){
Expand Down
8 changes: 4 additions & 4 deletions R/HelperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ u_stat_signature_list <- function(sig_list, ranks_matrix, maxRank=1000,
#' @param matrix Input data matrix
#' @param features List of signatures
#' @param maxRank Rank cutoff (1500)
#' @param chunk.size Cells per sub-matrix (1000)
#' @param chunk.size Cells per sub-matrix (100)
#' @param BPPARAM A BioParallel object to instruct UCell how to
#' parallelize
#' @param ncores Number of cores to use for parallelization
Expand All @@ -99,7 +99,7 @@ u_stat_signature_list <- function(sig_list, ranks_matrix, maxRank=1000,
#' @import Matrix
#' @import BiocParallel
calculate_Uscore <- function(
matrix, features, maxRank=1500, chunk.size=1000,
matrix, features, maxRank=1500, chunk.size=100,
BPPARAM = NULL, ncores=1, w_neg=1, ties.method="average",
storeRanks=FALSE, force.gc=FALSE, name="_UCell"){

Expand Down Expand Up @@ -185,7 +185,7 @@ calculate_Uscore <- function(
#'
#' @return A list of signature scores
#' @import data.table
rankings2Uscore <- function(ranks_matrix, features, chunk.size=1000, w_neg=1,
rankings2Uscore <- function(ranks_matrix, features, chunk.size=100, w_neg=1,
BPPARAM = NULL,ncores=1, force.gc=FALSE,
name="_UCell") {

Expand Down Expand Up @@ -313,7 +313,7 @@ data_to_ranks_data_table <- function(data, ties.method="average") {
#' @param chunk.size How many cells to include in each sub-matrix
#'
#' @return A list of sub-matrices, each with size {n_features x chunk_size}
split_data.matrix <- function(matrix, chunk.size=1000) {
split_data.matrix <- function(matrix, chunk.size=100) {
ncols <- dim(matrix)[2]
nchunks <- (ncols-1) %/% chunk.size + 1

Expand Down
2 changes: 1 addition & 1 deletion R/ScoreSignatures_UCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
ScoreSignatures_UCell <- function(
matrix=NULL,features, precalc.ranks=NULL,
maxRank=1500, w_neg=1, name="_UCell",
assay="counts", chunk.size=1000,
assay="counts", chunk.size=100,
BPPARAM=NULL, ncores=1,
ties.method="average", force.gc=FALSE) {

Expand Down
2 changes: 1 addition & 1 deletion R/StoreRankings_UCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' @importFrom SummarizedExperiment assay
#' @import Matrix
#' @export
StoreRankings_UCell <- function(matrix, maxRank=1500, chunk.size=1000,
StoreRankings_UCell <- function(matrix, maxRank=1500, chunk.size=100,
BPPARAM=NULL, ncores=1, assay='counts',
ties.method="average", force.gc=FALSE) {

Expand Down
4 changes: 2 additions & 2 deletions R/datasets.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Sample dataset to test UCell installation
#'
#' A sparse matrix (class "dgCMatrix") of single-cell transcriptomes
#' (scRNA-seq) for 600 cells and 20729 genes.
#' (scRNA-seq) for 30 cells and 20729 genes.
#' Single-cell UMI counts were normalized using a standard log-normalization:
#' counts for each cell were divided by the total counts for that cell and
#' multiplied by 10,000, then natural-log transformed using `log1p`. \cr\cr
Expand All @@ -11,7 +11,7 @@
#' available as UMI counts at
#' \url{https://atlas.fredhutch.org/data/nygc/multimodal/pbmc_multimodal.h5seurat}
#'
#' @format A sparse matrix of 600 cells and 20729 genes.
#' @format A sparse matrix of 30 cells and 20729 genes.
#' @source \url{https://doi.org/10.1016/j.cell.2021.04.048}
"sample.matrix"

Binary file modified data/sample.matrix.RData
Binary file not shown.
7 changes: 7 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
\name{NEWS}
\title{News for package \pkg{UCell}}

\section{New in version 2.7.4}{
\itemize{
\item Add support for Seurat v5 assay and datasets in multiple layers. Added dependency on Seurat >= 5.0.
\item Change default for \code{chunk.size} to 100. On parallelized jobs, this can improve up to 2-fold execution time.
\item Smaller test dataset (30 cells), to speed up package function checks.
}}

\section{New in version 2.1.2}{
\itemize{
\item New function \code{SmoothKNN()} for k-nearest neighbor smoothing of UCell scores. It can be applied both on SingleCellExperiment and Seurat objects (S3 method).
Expand Down
2 changes: 1 addition & 1 deletion man/AddModuleScore_UCell.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/ScoreSignatures_UCell.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/StoreRankings_UCell.Rd

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

4 changes: 2 additions & 2 deletions man/calculate_Uscore.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/rankings2Uscore.Rd

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

4 changes: 2 additions & 2 deletions man/sample.matrix.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/split_data.matrix.Rd

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

0 comments on commit 9169c3d

Please sign in to comment.