Skip to content

Commit

Permalink
[r] Docs and NAMESPACE cleanup (#1566)
Browse files Browse the repository at this point in the history
* Mark transformer functions as internal
* Add noRd to transformer functions
* Mark base R6 classes as internal
* Mark low-level package version functions internal
* Unexport low-level sr_* functions
* Unexport shape and nnz
  These are both available as methods on the appropriate R6 classes
* Document which package versions are retrieved
* Add noRd to internal version retrieval functions
* Refine stats docs
* README typo
* Stop exporting soma_array_reader()
* Stop exporting pad_matrix()
* Bump version and update docs
  • Loading branch information
aaronwolen authored Aug 2, 2023
1 parent 5729480 commit 3d4a5ad
Show file tree
Hide file tree
Showing 47 changed files with 150 additions and 449 deletions.
2 changes: 1 addition & 1 deletion apis/r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Title: TileDB SOMA
Description: Interface for working with 'TileDB'-based Stack of Matrices,
Annotated ('SOMA'): an open data model for representing annotated matrices,
like those commonly used for single cell data analysis.
Version: 0.99.2
Version: 0.99.3
Authors@R: c(
person(given = "Aaron",
family = "Wolen",
Expand Down
13 changes: 4 additions & 9 deletions apis/r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ S3method("[[<-",MappingBase)
S3method(as.list,MappingBase)
S3method(length,MappingBase)
S3method(names,MappingBase)
S3method(pad_matrix,default)
S3method(pad_matrix,matrix)
S3method(write_soma,Assay)
S3method(write_soma,DimReduc)
S3method(write_soma,Graph)
Expand All @@ -17,13 +15,17 @@ S3method(write_soma,data.frame)
S3method(write_soma,matrix)
export(ConfigList)
export(EphemeralCollection)
export(EphemeralCollectionBase)
export(EphemeralExperiment)
export(EphemeralMeasurement)
export(MappingBase)
export(PlatformConfig)
export(ReadIter)
export(SOMAAxisIndexer)
export(SOMAAxisQuery)
export(SOMAAxisQueryResult)
export(SOMACollection)
export(SOMACollectionBase)
export(SOMACollectionCreate)
export(SOMACollectionOpen)
export(SOMAContextBase)
Expand Down Expand Up @@ -58,14 +60,7 @@ export(extract_dataset)
export(list_datasets)
export(load_dataset)
export(matrixZeroBasedView)
export(nnz)
export(pad_matrix)
export(shape)
export(show_package_versions)
export(soma_array_reader)
export(sr_complete)
export(sr_next)
export(sr_setup)
export(tiledbsoma_stats_disable)
export(tiledbsoma_stats_dump)
export(tiledbsoma_stats_enable)
Expand Down
5 changes: 1 addition & 4 deletions apis/r/R/MappingBase.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
#' getting (\code{self$get()}) and setting (\code{self$set()}) items in the map
#'
#' @keywords internal
#'
#' @export
#'
#' @noMd
#'

MappingBase <- R6::R6Class(
classname = 'MappingBase',
lock_class = TRUE,
Expand Down
38 changes: 18 additions & 20 deletions apis/r/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ get_column_types <- function(uri, colnames) {
.Call(`_tiledbsoma_get_column_types`, uri, colnames)
}

#' @rdname soma_array_reader
#' @export
nnz <- function(uri, config = NULL) {
.Call(`_tiledbsoma_nnz`, uri, config)
}
Expand All @@ -32,8 +30,6 @@ check_arrow_array_tag <- function(xp) {
.Call(`_tiledbsoma_check_arrow_array_tag`, xp)
}

#' @rdname soma_array_reader
#' @export
shape <- function(uri, config = NULL) {
.Call(`_tiledbsoma_shape`, uri, config)
}
Expand Down Expand Up @@ -82,63 +78,65 @@ shape <- function(uri, config = NULL) {
#' }
#' summary(rl)
#' }
#' @export
#' @noRd
sr_setup <- function(uri, config, colnames = NULL, qc = NULL, dim_points = NULL, dim_ranges = NULL, batch_size = "auto", result_order = "auto", timestamp_end = NULL, loglevel = "auto") {
.Call(`_tiledbsoma_sr_setup`, uri, config, colnames, qc, dim_points, dim_ranges, batch_size, result_order, timestamp_end, loglevel)
}

#' @rdname sr_setup
#' @export
sr_complete <- function(sr) {
.Call(`_tiledbsoma_sr_complete`, sr)
}

#' @rdname sr_setup
#' @export
sr_next <- function(sr) {
.Call(`_tiledbsoma_sr_next`, sr)
}

#' TileDB Statistics interface
#' TileDB SOMA statistics
#'
#' These functions expose the TileDB Core functionality for performance measurements
#' and statistics.
#'
#' The functions `tiledbsoma_stats_enable`, `tiledbsoma_stats_disable`, `tiledbsoma_stats_reset`
#' and `tiledbsoma_stats_dump` expose the TileDB Core functionality for performance measurements
#' and statistics. The first three just turn on, off or reset, the fourth returns a JSON string.
#' For convenience the function `tiledbsoma_stats_show` displays the information on the console.
#' - `tiledbsoma_stats_enable()`/`tiledbsoma_stats_disable()`: Enable and disable TileDB's internal statistics.
#' - `tiledbsoma_stats_reset()`: Reset all statistics to 0.
#' - `tiledbsoma_stats_dump()`: Dump all statistics to a JSON string.
#' - `tiledbsoma_stats_show()`: Print all statistics to the console.
#'
#' @name tiledbsoma_stats
#' @export
tiledbsoma_stats_enable <- function() {
invisible(.Call(`_tiledbsoma_tiledbsoma_stats_enable`))
}

#' @rdname tiledbsoma_stats_enable
#' @rdname tiledbsoma_stats
#' @export
tiledbsoma_stats_disable <- function() {
invisible(.Call(`_tiledbsoma_tiledbsoma_stats_disable`))
}

#' @rdname tiledbsoma_stats_enable
#' @rdname tiledbsoma_stats
#' @export
tiledbsoma_stats_reset <- function() {
invisible(.Call(`_tiledbsoma_tiledbsoma_stats_reset`))
}

#' @rdname tiledbsoma_stats_enable
#' @rdname tiledbsoma_stats
#' @export
tiledbsoma_stats_dump <- function() {
.Call(`_tiledbsoma_tiledbsoma_stats_dump`)
}

#' libtiledbsoma version information
#' libtiledbsoma version
#'
#' Returns a string with version information for libtiledbsoma and the linked TileDB Embedded library.
#' @noRd
libtiledbsoma_version <- function() {
.Call(`_tiledbsoma_libtiledbsoma_version`)
}

#' TileDB Embedded Version interface
#' TileDB embedded version
#'
#' This gets the version of the TileDB Embedded library that is currently in use.
#' Gets the version of the TileDB Embedded library that is currently in use.
#' @noRd
tiledb_embedded_version <- function() {
.Call(`_tiledbsoma_tiledb_embedded_version`)
}
Expand Down
6 changes: 4 additions & 2 deletions apis/r/R/ReadIter.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' SOMA Read Iterator Base class
#'
#' Class that allows for read iteration of SOMA reads.
#' @keywords internal
#' @export

ReadIter <- R6::R6Class(
classname = "ReadIter",

public = list(

#' @description Create (lifecycle: experimental)
#' @param sr soma read pointer
initialize = function(sr) {
Expand Down Expand Up @@ -39,7 +41,7 @@ ReadIter <- R6::R6Class(
}
}
},

#' @description Concatenate remainder of iterator
# to be refined in derived classes
concat = function() {
Expand Down
4 changes: 3 additions & 1 deletion apis/r/R/SOMAArrayBase.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' SOMA Array Base Class
#'
#' Adds SOMA-specific functionality to the [`TileDBArray`] class. (lifecycle: experimental)
#' Adds SOMA-specific functionality to the [`TileDBArray`] class. (lifecycle:
#' experimental)
#' @keywords internal

SOMAArrayBase <- R6::R6Class(
classname = "SOMAArrayBase",
Expand Down
1 change: 1 addition & 0 deletions apis/r/R/SOMAAxisIndexer.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' result. Coordinates outside of the query result will return
#' [`arrow::null()`].
#' @keywords internal
#' @export
SOMAAxisIndexer <- R6::R6Class("SOMAAxisIndexer",
public = list(

Expand Down
3 changes: 3 additions & 0 deletions apis/r/R/SOMACollectionBase.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#'
#' @description Base class for objects containing persistent collection of SOMA
#' objects, mapping string keys to any SOMA object. (lifecycle: experimental)
#' @keywords internal
#' @export

SOMACollectionBase <- R6::R6Class(
classname = "SOMACollectionBase",
inherit = TileDBGroup,
Expand Down
5 changes: 1 addition & 4 deletions apis/r/R/SOMAContextBase.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
#' context options
#'
#' @keywords internal
#'
#' @export
#'
#' @noMd
#'

SOMAContextBase <- R6::R6Class(
classname = 'SOMAContextBase',
inherit = ScalarMap,
Expand Down
1 change: 1 addition & 0 deletions apis/r/R/SOMANDArrayBase.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' Adds NDArray-specific functionality to the [`SOMAArrayBase`] class.
#' (lifecycle: experimental)
#'
#' @keywords internal
#' @export
#' @importFrom bit64 as.integer64

Expand Down
1 change: 1 addition & 0 deletions apis/r/R/SOMASparseNDArrayRead.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#'
#' @description
#' Intermediate type to choose result format when reading a sparse array
#' @keywords internal
#' @export

SOMASparseNDArrayRead <- R6::R6Class(
Expand Down
4 changes: 1 addition & 3 deletions apis/r/R/SOMATileDBContext.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#' Context map for TileDB-backed SOMA objects
#'
#' @export
#'
#' @noMd
#'

SOMATileDBContext <- R6::R6Class(
classname = 'SOMATileDBContext',
inherit = SOMAContextBase,
Expand Down
7 changes: 3 additions & 4 deletions apis/r/R/ScalarMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#'
#' An R6 mapping type that is limited to scalar atomic vector types only; can
#' optionally be limited further to a specific atomic vector type
#' (eg. \dQuote{\code{logical}})
#' (eg. \dQuote{\code{logical}}).
#'
#' @keywords internal
#' @export
#'
#' @noMd
#'

ScalarMap <- R6::R6Class(
classname = 'ScalarMap',
inherit = MappingBase,
Expand Down
1 change: 1 addition & 0 deletions apis/r/R/TileDBArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @description Base class for representing an individual TileDB array.
#' (lifecycle: experimental)
#'
#' @keywords internal
#' @export
TileDBArray <- R6::R6Class(
classname = "TileDBArray",
Expand Down
1 change: 1 addition & 0 deletions apis/r/R/TileDBGroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @description
#' Base class for interacting with TileDB groups (lifecycle: experimental)
#' @importFrom spdl info debug
#' @keywords internal
#' @export
TileDBGroup <- R6::R6Class(
classname = "TileDBGroup",
Expand Down
3 changes: 2 additions & 1 deletion apis/r/R/ephemeral.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#' @description \Sexpr[results=rd]{tiledbsoma:::rd_ephemeral_cls("collection", TRUE)}
#'
#' @keywords internal
#' @export
#' @importFrom data.table address
#'

EphemeralCollectionBase <- R6::R6Class(
classname = 'EphemeralCollectionBase',
inherit = SOMACollectionBase,
Expand Down
16 changes: 4 additions & 12 deletions apis/r/R/pad_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#'
#' @return A matrix containing the data of \code{x} padded out to \code{shape}
#'
#' @keywords internal
#'
#' @export
#'
#' @noRd
pad_matrix <- function(x, ...) {
UseMethod(generic = 'pad_matrix', object = x)
}
Expand All @@ -25,12 +22,8 @@ pad_matrix <- function(x, ...) {
#' row/column names
#'
#' @importFrom Matrix sparseMatrix
#'
#' @noRd
#'
#' @method pad_matrix default
#' @export
#'
#' @noRd
pad_matrix.default <- function(x, rownames = NULL, colnames = NULL, ...) {
stopifnot(
inherits(x, "Matrix"),
Expand Down Expand Up @@ -75,10 +68,9 @@ pad_matrix.default <- function(x, rownames = NULL, colnames = NULL, ...) {

#' @param sparse Return a \link[Matrix:TsparseMatrix-class]{sparse matrix}
#' @rdname pad_matrix
#'
#' @method pad_matrix matrix
#' @export
#'
#' @noRd

pad_matrix.matrix <- function(x, rowidx, colidx, shape, sparse = FALSE, ...) {
stopifnot(
rlang::is_integerish(shape, n = 2L, finite = TRUE) && all(shape > 0L),
Expand Down
2 changes: 1 addition & 1 deletion apis/r/R/soma_array_reader.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' z <- soma_array_reader(uri)
#' arrow::RecordBatch$import_from_c(z$array_data, z$schema)
#' }
#' @export
#' @noRd
soma_array_reader <- function(uri, colnames = NULL, qc = NULL, dim_points = NULL, dim_ranges = NULL,
batch_size = "auto", result_order = "auto", loglevel = "auto",
config = NULL) {
Expand Down
Loading

0 comments on commit 3d4a5ad

Please sign in to comment.