From dfcd960f4fcbc005ecc9f39714d187ddd77d4102 Mon Sep 17 00:00:00 2001 From: tetomonti Date: Fri, 20 Oct 2023 17:40:25 -0400 Subject: [PATCH 1/3] fixed dotplot by genesetsize --- R/hyp_dots.R | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/R/hyp_dots.R b/R/hyp_dots.R index 642152c..383e70a 100644 --- a/R/hyp_dots.R +++ b/R/hyp_dots.R @@ -20,7 +20,7 @@ .dots_multi_plot <- function(multihyp_data, top=20, abrv=50, - size_by=c("genesets", "significance", "none"), + size_by=c("genesets", "significance", "overlap", "none"), pval_cutoff=1, fdr_cutoff=1, val=c("fdr", "pval"), @@ -79,16 +79,29 @@ if (size_by == "significance") { df.melted$size <- df.melted$significance - } - - if (size_by == "genesets") { + } else if (size_by == "genesets") { geneset.sizes <- lapply(multihyp_data, function(hyp_obj) { hyp_obj$data[, c("label", "geneset")] }) %>% do.call(rbind, .) %>% dplyr::distinct(label, .keep_all=TRUE) %>% dplyr::pull(geneset, label) - df.melted$size <- geneset.sizes[df.melted$label] + #df.melted$size <- geneset.sizes[df.melted$label] + names(geneset.sizes) <- substr(names(geneset.sizes), 1, abrv) + stopifnot( all(!is.na(match_idx <- match(df.melted$label,names(geneset.sizes)))) ) + df.melted$size <- geneset.sizes[match_idx] + } else if (size == "overlap") { + stop( "size_by overlap not implemented yet") + overlap.sizes <- lapply(multihyp_data, function(hyp_obj) { + hyp_obj$data[, c("label", "overlap")] + }) %>% + do.call(rbind, .) %>% + dplyr::distinct(label, .keep_all=TRUE) %>% + dplyr::pull(overlap, label) + #df.melted$size <- overlap.sizes[df.melted$label] + names(overlap.sizes) <- substr(names(overlap.sizes), 1, abrv) + stopifnot( all(!is.na(match_idx <- match(df.melted$label,names(overlap.sizes)))) ) + df.melted$size <- overlap.sizes[match_idx] } p <- df.melted %>% @@ -104,14 +117,15 @@ if (size_by == "none") { p <- p + guides(size="none") - } - if (size_by == "significance") { + } else if (size_by == "significance") { p <- p + scale_size_continuous(trans=.reverselog_trans(10)) + labs(size="Significance") - } - if (size_by == "genesets") { + } else if (size_by == "genesets" ) { p <- p + scale_size_continuous(trans=scales::log10_trans()) + labs(size="Genesets\nSize") + } else if (size_by == "overlap" ) { + p <- p + scale_size_continuous(trans=scales::log10_trans()) + labs(size="Overlap\nSize") + } else { + stop("unrecognized 'size_by':", size_by) } - return(p) } From 66c2d2fa93f7741f50b18d9ceddbc4e1c78e22dd Mon Sep 17 00:00:00 2001 From: tetomonti Date: Fri, 20 Oct 2023 11:42:37 -0400 Subject: [PATCH 2/3] hits list modified to have space-comma-space as separator (it is now simply comma, which is often ambiguous) --- R/hyper_enrichment.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/hyper_enrichment.R b/R/hyper_enrichment.R index 87fcfce..cc33cc0 100644 --- a/R/hyper_enrichment.R +++ b/R/hyper_enrichment.R @@ -42,7 +42,8 @@ geneset=n.genesets, overlap=n.hits, background=background, - hits=sapply(genesets, function(x, y) paste(intersect(x, y), collapse=','), signature.found), + #hits=sapply(genesets, function(x, y) paste(intersect(x, y), collapse=','), signature.found), + hits=sapply(genesets, function(x, y) paste(intersect(x, y), collapse=' , '), signature.found), stringsAsFactors=FALSE) # Handle plots From f9a1b16ee61286f7e440ad02b2669dccc8509a85 Mon Sep 17 00:00:00 2001 From: Andrew Chen Date: Fri, 20 Oct 2023 18:07:53 -0400 Subject: [PATCH 3/3] Update Version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0697d53..6a42cc2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: hypeR Title: An R Package For Geneset Enrichment Workflows -Version: 1.99.0 +Version: 1.99.1 Authors@R: c(person(given="Anthony", family="Federico", email="anfed@bu.edu", role=c("aut", "cre")), person(given="Andrew", family="Chen", email="andrewdr@bu.edu",