-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
261 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Coercion methods for SOMA classes | ||
|
||
# Set R6 methods formally as S3 to create apply generics | ||
methods::setOldClass("SOMASparseNDArrayRead") | ||
methods::setOldClass("TableReadIter") | ||
|
||
#' @importClassesFrom Matrix TsparseMatrix CsparseMatrix RsparseMatrix | ||
NULL | ||
|
||
#' @importFrom arrow as_arrow_table | ||
#' @export | ||
arrow::as_arrow_table | ||
|
||
|
||
#' @importFrom arrow as_arrow_table | ||
#' @export | ||
as_arrow_table.SOMASparseNDArrayRead <- function(x){ | ||
x$tables()$concat() | ||
} | ||
|
||
#' @export | ||
as.data.frame.SOMASparseNDArrayRead <- function(x, ...){ | ||
as.data.frame(x$tables()$concat(), ...) | ||
} | ||
|
||
# Coerce \link[tiledbsoma]{SOMASparseNDArrayRead} to Matrix::\link[Matrix]{dgTMatrix} | ||
setAs(from = "SOMASparseNDArrayRead", | ||
to = "TsparseMatrix", | ||
def = function(from) from$sparse_matrix()$concat() | ||
) | ||
|
||
# Coerce \link[tiledbsoma]{SOMASparseNDArrayRead} to Matrix::\link[Matrix]{dgCMatrix} | ||
setAs(from = "SOMASparseNDArrayRead", | ||
to = "CsparseMatrix", | ||
def = function(from) as(as(from, "TsparseMatrix"), "CsparseMatrix") | ||
) | ||
|
||
# Coerce \link[tiledbsoma]{SOMASparseNDArrayRead} to Matrix::\link[Matrix]{dgRMatrix} | ||
setAs(from = "SOMASparseNDArrayRead", | ||
to = "RsparseMatrix", | ||
def = function(from) as(as(from, "TsparseMatrix"), "RsparseMatrix") | ||
) | ||
|
||
#' @export | ||
as_arrow_table.TableReadIter <- function(x) x$concat() | ||
|
||
#' @export | ||
as.data.frame.TableReadIter <- function(x, row.names = NULL, optional = FALSE, ...){ | ||
as.data.frame(x$concat(), row.names = row.names, optional = optional, ...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.