Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added spatial experiment handling #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 27 additions & 5 deletions R/viper_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,45 @@ run_viper.data.frame <- function(input, regulons, options = list(),

#' @export
run_viper.SingleCellExperiment <- function(input, regulons, options = list(),
tidy = FALSE, assay_key = "RNA") {
tidy = FALSE, assay_key = "logcounts") {
if (tidy) {
tidy <- FALSE
warning("The argument 'tidy' cannot be TRUE for 'SingleCellExperiment' ",
"objects. ","'tidy' is set to FALSE")
}

mat <- as.matrix(SingleCellExperiment::logcounts(input))

mat <- as.matrix(assay(input, assay_key))
tf_activities <- run_viper(mat, regulons = regulons, options = options,
tidy = FALSE)

# include TF activities into SingleCellExperiment object
dorothea_se <- SummarizedExperiment::SummarizedExperiment(tf_activities)
SummarizedExperiment::assayNames(dorothea_se) <- "tf_activities"
SingleCellExperiment::altExp(input, "dorothea") <- dorothea_se

return(input)
}

#' @export
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you export this, shouldn't it have some docs?

run_viper.SpatialExperiment <- function(input, regulons, options = list(),
tidy = FALSE, assay_key = "logcounts") {
if (tidy) {
tidy <- FALSE
warning("The argument 'tidy' cannot be TRUE for 'SpatialExperiment' ",
"objects. ","'tidy' is set to FALSE")
}

mat <- as.matrix(assay(input, assay_key))

tf_activities <- run_viper(mat, regulons = regulons, options = options,
tidy = FALSE)

# include TF activities into SingleCellExperiment object
dorothea_se <- SummarizedExperiment::SummarizedExperiment(tf_activities)
SummarizedExperiment::assayNames(dorothea_se) <- "tf_activities"
SingleCellExperiment::altExp(input, "dorothea") <- dorothea_se

return(input)
}

Expand Down