Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,13 @@ setGeneric("addMDS", signature = "x", function(x, ...)
#' @export
setGeneric("getReducedDimAttribute", signature = "x", function(x, ...)
standardGeneric("getReducedDimAttribute"))

#' @rdname utilization_functions
#' @export
setGeneric("convertToMAE", signature = "x", function(x, ...)
standardGeneric("convertToMAE"))

#' @rdname utilization_functions
#' @export
setGeneric("convertToTreeSE", signature = "x", function(x, ...)
standardGeneric("convertToTreeSE"))
30 changes: 29 additions & 1 deletion R/utilization_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#'
NULL

#'
#' @export
#' @rdname utilization_functions
#' @importFrom SingleCellExperiment reducedDim
Expand All @@ -69,6 +68,35 @@ setMethod("getReducedDimAttribute", "SingleCellExperiment",
}
)

#' @export
#' @rdname utilization_functions
#' @importFrom SingleCellExperiment reducedDims
setMethod("convertToMAE", "SingleCellExperiment",
function(x, name = "main", ...){
exps <- setNames(list(x), name)
exps <- c(exps, altExps(x) |> as.list()) |> ExperimentList()
mae <- MultiAssayExperiment(experiments = exps, colData = colData(x))
return(mae)
}
)

#' @export
#' @rdname utilization_functions
#' @importFrom MultiAssayExperiment intersectColumns experiments
setMethod("convertToTreeSE", "MultiAssayExperiment",
function(x, ...){
x <- intersectColumns(x)
exps <- experiments(x)
if( !all(vapply(exps, function(x) is(x, "SummarizedExperiment"), logical(1L))) ){
stop("All experiments must be SummarizedExperiment objects.", call. = FALSE)
}
tse <- exps[[1L]] |> as("TreeSummarizedExperiment")
altExps(tse) <- exps[-1]
return(tse)
}
)


################################ HELP FUNCTIONS ################################

# From a list, extract those elements that user has specified
Expand Down
Binary file removed data/ibdmdb_2omic_demo.rda
Binary file not shown.
Loading