Skip to content

Commit

Permalink
[FIX] - log transform plot error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leopoldguyot committed Jul 19, 2024
1 parent 8df166b commit 3f6898e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Imports:
viridisLite,
stats,
SingleCellExperiment,
ggplot2
ggplot2,
tidyr
Depends:
shinyBS,
R (>= 4.3.0)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ importFrom(shinydashboardPlus,boxSidebar)
importFrom(shinydashboardPlus,dashboardHeader)
importFrom(shinydashboardPlus,dashboardPage)
importFrom(stats,as.formula)
importFrom(tidyr,pivot_longer)
importFrom(utils,data)
importFrom(utils,read.table)
importFrom(viridisLite,viridis)
25 changes: 15 additions & 10 deletions R/utils_global.R
Original file line number Diff line number Diff line change
Expand Up @@ -564,25 +564,30 @@ plotlyridges <- function(
#' @rdname INTERNAL_summarize_assays_to_df
#' @keywords internal
#' @importFrom SummarizedExperiment assay colData rowData
#' @importFrom tidyr pivot_longer
#'

summarize_assays_to_df <- function(qfeatures, sample_column, feature_column = NULL) {

combined_df <- data.frame(PSM = character(), intensity = numeric(), sample = character())
for (assayName in names(qfeatures)) {
assayData <- assay(qfeatures[[assayName]])
assayData <- as.data.frame(assay(qfeatures[[assayName]]))

PSM <- rownames(assayData)
intensities <- as.vector(assayData)
sampleNames <- rep(colnames(assayData), each = nrow(assayData))
assayData <- pivot_longer(assayData, everything(), names_to = "sample", values_to = "intensity")
assayData$PSM <- rownames(assayData)
print(head(assayData))

matched_indices <- match(assayData$sample, rownames(colData(qfeatures)))
length(matched_indices)
assayData$sample_type <- colData(qfeatures)[matched_indices, sample_column]

assay_df <- data.frame(PSM = PSM, intensity = intensities, sample = sampleNames)
assay_df$sample_type <- colData(qfeatures)[assay_df$sample, sample_column] # Here I subset with a long vector that is compose of multiple time each sample
print(feature_column)
# assay_df$sample_type <- lapply(assay_df$sample, function(x) {
# colData(qfeatures)[x, sample_column]
# })
if (!is.null(feature_column)) {
assay_df$feature_type <- rowData(qfeatures[[assayName]])[assay_df$PSM, feature_column]
assayData$feature_type <- rowData(qfeatures[[assayName]])[assayData$PSM, feature_column]
}
combined_df <- rbind(combined_df, assay_df)
print(head(combined_df))
combined_df <- rbind(combined_df, assayData)
}
combined_df
}
Expand Down
2 changes: 1 addition & 1 deletion man/sampleTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f6898e

Please sign in to comment.