Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 1, 2024
1 parent 6aa6b07 commit 4aa5fe8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 68 deletions.
11 changes: 6 additions & 5 deletions R/DeconvExplorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,12 @@ DeconvExplorer <- function(deconvexp_bulk = NULL,

# start the tour
observeEvent(input$startTour, {
tour_steps <- read.delim(system.file("extdata", "tour_intro.txt",
package = "DeconvExplorer"
),
sep = ";", stringsAsFactors = FALSE,
row.names = NULL, quote = ""
tour_steps <- read.delim(
system.file("extdata", "tour_intro.txt",
package = "DeconvExplorer"
),
sep = ";", stringsAsFactors = FALSE,
row.names = NULL, quote = ""
)
introjs(session, options = list(
steps = tour_steps,
Expand Down
115 changes: 52 additions & 63 deletions R/Global.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Get subset of deconvolution results
#'
#' This function returns the requested deconvolution results as a list
Expand Down Expand Up @@ -44,66 +43,56 @@ returnSelectedDeconvolutions <- function(deconv_select, deconv_list) {
#' @examples
#' # CosTODO
# plot_benchmark <- function(deconvolutions) {
# # import and preformat data
#
# # deconvolution_list <- list()
# # for (deconvolution in deconv_select) {
# # # deconvolution_list[length(deconvolution_list) + 1] <- deconv_list[[deconvolution]][1]
# # deconvolution_list[deconvolution] <- deconv_list[[deconvolution]][1]
# # }
#
# # add samples and deconvolution method
# deconvolutions <- lapply(deconvolutions, function(x) cbind(x, sample = rownames(x)))
# deconvolutions <- lapply(names(deconvolutions), function(x) {
# cbind(deconvolutions[[x]], method = rep(x, nrow(deconvolutions[[x]])))
# })
#
# deconvolutions <- lapply(deconvolutions, function(x) {
# tidyr::pivot_longer(data.frame(x), !c("sample", "method"),
# names_to = "cell_type", values_to = "predicted_fraction"
# )
# })
#
# # combine to one dataframe
# data <- do.call("rbind", deconvolutions)
#
# # preformat reference data
# ref <- omnideconv::RefData
# ref$sample <- rownames(ref)
# ref <- tidyr::pivot_longer(ref, !sample, names_to = "cell_type", values_to = "true_fraction")
#
# # merge the reference data with the deconvolution results
# data <- merge(ref, data, by = c("sample", "cell_type"))
#
# # change datatype to numeric
# data$predicted_fraction <- as.numeric(data$predicted_fraction)
# data$true_fraction <- as.numeric(data$true_fraction)
#
# # calculate max width/heigth -> plot symmetric and line @ 45 Degrees
# max_value <- max(max(data$true_fraction), max(data$predicted_fraction)) + 0.1
#
# # create plot
# plot <- ggplot(data, aes(
# x = .data$true_fraction, y = predicted_fraction, color = cell_type,
# text = paste0("Sample: ", sample, "\nTrue: ", true_fraction, "\nPredicted: ", predicted_fraction)
# )) +
# geom_point(size = 4) +
# facet_wrap(~method) +
# geom_abline(color = "black") +
# labs(x = "True Fraction", y = "predicted Fraction", color = "cell type") +
# coord_cartesian(xlim = c(0, max_value), ylim = c(0, max_value))
#
# # render
# plotly::ggplotly(plot, tooltip = c("text")) |>
# plotly::config(
# displaylogo = FALSE, showTips = FALSE, toImageButtonOptions = list(filename = paste0("plotMethod", "_plot")),
# modeBarButtonsToRemove = list(
# "hoverClosestCartesian",
# "hoverCompareCartesian",
# "zoomIn2d", "zoomOut2d",
# "lasso2d", "zoom2d",
# "pan2d", "autoScale2d", "select2d"
# )
# ) |>
# plotly::layout(xaxis = list(fixedrange = TRUE), yaxis = list(fixedrange = TRUE))
#' # # import and preformat data
#' # # deconvolution_list <- list()
#' # # for (deconvolution in deconv_select) {
#' # # # deconvolution_list[length(deconvolution_list) + 1] <- deconv_list[[deconvolution]][1]
#' # # deconvolution_list[deconvolution] <- deconv_list[[deconvolution]][1]
#' # # }
#' # # add samples and deconvolution method
#' # deconvolutions <- lapply(deconvolutions, function(x) cbind(x, sample = rownames(x)))
#' # deconvolutions <- lapply(names(deconvolutions), function(x) {
#' # cbind(deconvolutions[[x]], method = rep(x, nrow(deconvolutions[[x]])))
#' # })
#' # deconvolutions <- lapply(deconvolutions, function(x) {
#' # tidyr::pivot_longer(data.frame(x), !c("sample", "method"),
#' # names_to = "cell_type", values_to = "predicted_fraction"
#' # )
#' # })
#' # # combine to one dataframe
#' # data <- do.call("rbind", deconvolutions)
#' # # preformat reference data
#' # ref <- omnideconv::RefData
#' # ref$sample <- rownames(ref)
#' # ref <- tidyr::pivot_longer(ref, !sample, names_to = "cell_type", values_to = "true_fraction")
#' # # merge the reference data with the deconvolution results
#' # data <- merge(ref, data, by = c("sample", "cell_type"))
#' # # change datatype to numeric
#' # data$predicted_fraction <- as.numeric(data$predicted_fraction)
#' # data$true_fraction <- as.numeric(data$true_fraction)
#' # # calculate max width/heigth -> plot symmetric and line @ 45 Degrees
#' # max_value <- max(max(data$true_fraction), max(data$predicted_fraction)) + 0.1
#' # # create plot
#' # plot <- ggplot(data, aes(
#' # x = .data$true_fraction, y = predicted_fraction, color = cell_type,
#' # text = paste0("Sample: ", sample, "\nTrue: ", true_fraction, "\nPredicted: ", predicted_fraction)
#' # )) +
#' # geom_point(size = 4) +
#' # facet_wrap(~method) +
#' # geom_abline(color = "black") +
#' # labs(x = "True Fraction", y = "predicted Fraction", color = "cell type") +
#' # coord_cartesian(xlim = c(0, max_value), ylim = c(0, max_value))
#' # # render
#' # plotly::ggplotly(plot, tooltip = c("text")) |>
#' # plotly::config(
#' # displaylogo = FALSE, showTips = FALSE, toImageButtonOptions = list(filename = paste0("plotMethod", "_plot")),
#' # modeBarButtonsToRemove = list(
#' # "hoverClosestCartesian",
#' # "hoverCompareCartesian",
#' # "zoomIn2d", "zoomOut2d",
#' # "lasso2d", "zoom2d",
#' # "pan2d", "autoScale2d", "select2d"
#' # )
#' # ) |>
#' # plotly::layout(xaxis = list(fixedrange = TRUE), yaxis = list(fixedrange = TRUE))
# }

0 comments on commit 4aa5fe8

Please sign in to comment.