Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mojaveazure committed Feb 27, 2024
1 parent d365d3b commit 8b51ce6
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 21 deletions.
3 changes: 3 additions & 0 deletions R/AnnotationDataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ AnnotationDataframe <- R6::R6Class(
"'index_col' must be a scalar character" = is_scalar_character(index_col)
)

spdl::debug("Populating {} at '{}' with data.frame data", self$class(), self$uri)

# convert rownames to a column
x[[index_col]] <- rownames(x)
if (!self$exists()) {
Expand All @@ -58,6 +60,7 @@ AnnotationDataframe <- R6::R6Class(
#' @return A [`data.frame`] with row names containing values from the index
#' dimension
to_dataframe = function(attrs = NULL) {
spdl::debug("Returning {} at '{}' to data.frame", self$class(), self$uri)
spdl::info(sprintf("Reading %s into memory from '%s'", self$class(), self$uri))

# Check for legacy validity mode metadata tag
Expand Down
2 changes: 2 additions & 0 deletions R/AnnotationGroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ AnnotationGroup <- R6::R6Class(

# Assuming all members are TileDBArrays
for (member in names(self$members)) {
spdl::debug("Setting the query for '{}'", member)
self$members[[member]]$set_query(dims, attr_filter)
}
},
Expand All @@ -53,6 +54,7 @@ AnnotationGroup <- R6::R6Class(
#' @return NULL
reset_query = function(dims = TRUE, attr_filter = TRUE) {
for (member in names(self$members)) {
spdl::debug("Resetting the query for '{}'", member)
self$members[[member]]$reset_query(dims, attr_filter)
}
}
Expand Down
3 changes: 3 additions & 0 deletions R/AnnotationMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ AnnotationMatrix <- R6::R6Class(
"'index_col' must be a scalar character" = is_scalar_character(index_col)
)
private$validate_matrix(x)
spdl::debug("Populating {} at '{}' with matrix data", self$class(), self$uri)

# convert to a data frame containing the index column
x <- as.data.frame(x)
Expand All @@ -46,6 +47,8 @@ AnnotationMatrix <- R6::R6Class(
#' @return A [`matrix`]
to_matrix = function(attrs = NULL, batch_mode = FALSE) {

spdl::debug("Returning {} at '{}' as a matrix", self$class(), self$uri)

df <- private$read_data(
attrs = attrs,
batch_mode = batch_mode,
Expand Down
1 change: 1 addition & 0 deletions R/AnnotationMatrixGroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AnnotationMatrixGroup <- R6::R6Class(
# TODO: Verify that the matrix is aligned to the group's dimension

# create the new array
spdl::debug("Adding matrix as '{}' to group at '{}'", name, self$uri)
array_uri <- file_path(self$uri, name)
array <- AnnotationMatrix$new(
uri = array_uri,
Expand Down
11 changes: 11 additions & 0 deletions R/AnnotationPairwiseMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AnnotationPairwiseMatrix <- R6::R6Class(
"'value_col' must be a scalar character" = is_scalar_character(value_col)
)
private$validate_matrix(x)
spdl::debug("Populating {} at '{}' with matrix data", self$class(), self$uri)

x <- matrix_to_coo(
x = x,
Expand Down Expand Up @@ -65,6 +66,11 @@ AnnotationPairwiseMatrix <- R6::R6Class(
#' @description Read annotation data from TileDB into a sparse matrix
#' @return A [`Matrix::dgTMatrix-class`].
to_sparse_matrix = function() {
spdl::info(sprintf(
"Reading %s into sparse dgT matrix from '%s'",
self$class(),
self$uri
))
dataframe_to_dgtmatrix(
self$to_dataframe(),
index_cols = self$dimnames()
Expand All @@ -75,6 +81,11 @@ AnnotationPairwiseMatrix <- R6::R6Class(
#' @return A [`SeuratObject::Graph-class`]
#' @importFrom SeuratObject DefaultAssay
to_seurat_graph = function() {
spdl::info(sprintf(
"Reading %s into SeuratObject::Graph from '%s'",
self$class(),
self$uri
))
assay <- self$get_metadata(key = "assay_used")
object <- SeuratObject::as.Graph(self$to_sparse_matrix())
SeuratObject::DefaultAssay(object) <- assay
Expand Down
2 changes: 2 additions & 0 deletions R/AnnotationPairwiseMatrixGroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AnnotationPairwiseMatrixGroup <- R6::R6Class(

# TODO: Verify that the matrix is aligned to the group's dimension
# create the new array
spdl::debug("Adding {} as '{}' to group at '{}'", self$class(), name, self$uri)
array_uri <- file_path(self$uri, name)
array <- AnnotationPairwiseMatrix$new(
uri = array_uri,
Expand Down Expand Up @@ -65,6 +66,7 @@ AnnotationPairwiseMatrixGroup <- R6::R6Class(
assay <- SeuratObject::DefaultAssay(object)
array_name <- paste0(prefix, technique)

spdl::debug("Adding SeuratObject::Graph as '{}' to group at '{}'", array_name, self$uri)
self$add_matrix(
data = as(object, "TsparseMatrix"),
name = array_name,
Expand Down
6 changes: 6 additions & 0 deletions R/AssayMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ AssayMatrix <- R6::R6Class(
)
private$validate_matrix(x)

spdl::debug("Populating {} at '{}' with matrix data", self$class(), self$uri)

self$from_dataframe(
matrix_to_coo(x, index_cols = index_cols, value_cols = value_col),
index_cols = index_cols
Expand All @@ -52,6 +54,7 @@ AssayMatrix <- R6::R6Class(
length(index_cols) == 2,
all(index_cols %in% colnames(x))
)
spdl::debug("Populating {} at '{}' with triplet data", self$class(), self$uri)
if (!self$exists()) {
private$create_empty_array(x, index_cols)
} else {
Expand All @@ -66,6 +69,7 @@ AssayMatrix <- R6::R6Class(
#' @return A [`Matrix::dgTMatrix-class`].
#' @importFrom vctrs vec_rbind
to_dataframe = function(attrs = NULL, batch_mode = FALSE) {
spdl::debug("Returning {} at '{}' as triplets", self$class(), self$uri)
private$read_data(
attrs = attrs,
batch_mode = batch_mode,
Expand All @@ -83,6 +87,8 @@ AssayMatrix <- R6::R6Class(
}
stopifnot(is_scalar_character(attr))

spdl::debug("Returning {} at '{}' as a dgT matrix", self$class(), self$uri)

assay_data <- private$read_data(
attrs = attr,
batch_mode = batch_mode,
Expand Down
2 changes: 2 additions & 0 deletions R/AssayMatrixGroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ AssayMatrixGroup <- R6::R6Class(
stop("Must provide a `matrix` to ingest into the new AnnotationMatrix")
}

spdl::debug("Populating {} at '{}' with matrix data", self$class(), self$uri)

# create the new array
array_uri <- file_path(self$uri, name)
array <- AssayMatrix$new(
Expand Down
2 changes: 2 additions & 0 deletions R/CommandsArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CommandsArray <- R6::R6Class(
)
}

spdl::debug("Populating {} at '{}' with SeuratCommand data", self$class(), self$uri)

# Convert from list of objects to list of dataframes.
command_dataframes <- lapply(x, as.data.frame.SeuratCommand)

Expand Down
Loading

0 comments on commit 8b51ce6

Please sign in to comment.