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

calling internal functions (like .homogenizeDEA) doenst work #26

Open
SebastianHesse opened this issue Dec 4, 2023 · 1 comment
Open

Comments

@SebastianHesse
Copy link

Im working with version 0.99.32 and found that calling the internal functions (like .homogenizeDEA) doesnt work.
Below, I give a edited code that allows me to produce the desired CDplots (its heavily reduced to use only by = "auto").
Hope this helps to debug your awesome analysis pipeline!

CDplotWrapper <- function (dea, sets, setName, k = 3, addN = FALSE, by = c("auto", 
    "sites", "score", "best_stype", "type"), sameFreq = NULL, 
    line.size = 1.2, point.size = 0.8, checkSynonyms = TRUE, 
    pvals = FALSE) {
    message("Preparing inputs...")
    dea <- enrichMiR:::.homogenizeDEA(dea)
    # if (checkSynonyms) 
    #     dea <- enrichMiR:::.applySynonyms(dea, sets)
    sets <- enrichMiR:::.list2DF(sets)
    sets <- sets[sets$set == setName, ]
    #if (is.null(sets$sites)) 
    #    sets$sites <- 1
   # by <- match.arg(by)
    #if (by == "auto" || by == "best_stype") 
        sets <- enrichMiR:::.addBestType(sets)
   # if (by == "auto") 
       by <- head(intersect(c("best_stype", "score", "sites"),
           colnames(sets)), 1)
  #  if (by != "type" && !(by %in% colnames(sets))) 
   #     stop("`by` not available in `sets`.")
   # if (nrow(sets) == 0) 
  #      stop("setName not found in `sets`.")
 #   if (is.null(dim(dea))) {
  #      if (!is.numeric(dea) || is.null(names(dea))) 
    #        stop("`dea` should be a named numeric vector or a data.frame containing ", 
   #             "the results of a differential expression analysis.")
  #  }
  #  else {
       dea <- enrichMiR:::.dea2sig(enrichMiR:::.homogenizeDEA(dea), "logFC")
  #  }
    # if (!any(sets$feature %in% names(dea))) 
    #     stop("There seems to be no overlap between the rows of `dea` and the ", 
    #         "features of `sets`.")
    # if (is.null(sameFreq)) 
    #     sameFreq <- by == "score"
    if (by == "best_stype" | by == "type") {
        if (by == "best_stype") {
            by <- as.character(sets[["best_stype"]])
            names(by) <- sets[["feature"]]
            by2 <- by[names(dea)]
            by2[is.na(by2)] <- "no site"
        }
        
        bylvls <- levels(as.factor(by2))
        defcols <- enrichMiR:::.siteTypeColors()
        if (all(bylvls %in% names(defcols))) {
            by2 <- factor(by2, intersect(names(defcols), bylvls))
        }
        # if (addN)
        #     bylvls <- levels(by2) <- paste0(levels(by2), " (n=",
        #         as.integer(table(by2)), ")")
        p <- CDplot(dea, by = by2, k = length(bylvls), sameFreq = sameFreq,
            size = line.size, pvals = pvals)
        if (all(bylvls %in% names(defcols))) {
            p <- p + scale_colour_manual(values = defcols[levels(by2)])
        }}
    #     else {
    #         bylvls2 <- gsub(" \\(n=[0-9]+\\)", "", bylvls)
    #         if (all(bylvls2 %in% names(defcols))) {
    #             p <- p + scale_colour_manual(values = setNames(defcols[bylvls2],
    #               bylvls))
    #         }
    #     }
    # }
    # else{
    #     by <- rowsum(sets[[by]], sets$feature)[, 1]
    #     by2 <- by[names(dea)]
    #     by2[is.na(by2)] <- 0
    #     if (k == 2) {
    #         ll <- split(dea, by2 != 0)
    #         names(ll) <- c("non-targets", "targets")
    #         p <- CDplot(ll, size = line.size, pvals = pvals, 
    #             ...)
    #         p <- p + scale_colour_manual(values = c("#000004FF", 
    #             "#E65D2FFF"))
    #     }
    #     else {
    #         p <- CDplot(dea, by = by2, k = k, sameFreq = sameFreq, 
    #             size = line.size, pvals = pvals, ...)
    #         if (k == 3) {
    #             p <- p + scale_color_manual(values = c("#F5DB4BFF", 
    #               "#A92E5EFF", "#000004FF"))
    #         }
    #     }
    # }
    # if (point.size > 0) 
    #     p <- p + geom_point(size = point.size)
    p + xlab("logFC") + ggtitle(setName)
}

@plger
Copy link
Member

plger commented Dec 5, 2023

Hi,
Thanks for reporting.
Can you confirm that you're having trouble using the function via R, rather than with the shiny
app?
We'd need to reproduce the problem in the first place, since things run fine on our end. Could you share the data used? (You can shuffle the row.names of your DEA if you're concerned about data confidentiality)
The only circumstance where I can imagine the internal function calls not to work is if the package isn't installed, and simply loaded, but I'm assuming this isn't the case?
Pierre-Luc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants