Skip to content

Commit

Permalink
Merge pull request #25 from yerkes-gencore/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
derrik-gratz authored Mar 22, 2024
2 parents 1e79806 + 57101da commit 5f9fa98
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: gencoreBulk
Title: NPRC Genomics Core Bulk RNA Analysis Utilities
Version: 0.2.0
Date: 2023-04-14
Version: 0.2.1
Date: 2024-03-22
Author: person("Derrik", "Gratz", email = "[email protected]", role =
c("aut", "cre"), comment = c(ORCID = "0009-0002-5934-576X"))
Maintainer: Derrik Gratz <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export(mappingBinsPlot)
export(parseReadPerGeneFiles)
export(plotFilterByExpr)
export(plotGeneExpression)
export(plotModelCoeffs)
export(plotPCAFromConfig)
export(plotVoomByGroup)
export(runfgsea)
Expand Down
2 changes: 1 addition & 1 deletion R/getTopNGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ getTopNGenes <- function(result,
tibble::rownames_to_column('Gene') %>%
dplyr::arrange(.data$pvalue)
if (exclude_ENS){
filtered_results <- filtered_results[grepl(pattern = ENS_pattern,
filtered_results <- filtered_results[!grepl(pattern = ENS_pattern,
filtered_results$Gene),]
}
if (direction == 'mixed') {
Expand Down
1 change: 1 addition & 0 deletions R/heatmapFromGenelist.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ heatmapFromGenelist <- function(geneList,
NULL
}),
column_gap = column_gap,
column_labels = column_labels,
col = circlize::colorRamp2(c(scale_min, 0, scale_max), colors),
...
)
Expand Down
21 changes: 12 additions & 9 deletions R/plotGeneExpression.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ plotGeneExpression <- function(gene,
stop('All groups not found in grouping variable of metadata')
}
plotdata$grouping <- factor(plotdata$grouping, levels = groups)
plotdata <- plotdata[!is.na(plotdata$grouping),]
}
ggplot2::ggplot(plotdata, aes(x=grouping, y=.data[['Gene']])) +
(if (boxplot) { ggplot2::geom_boxplot(outlier.color = if (jitter) {NA} else {'black'}) }) +
Expand Down Expand Up @@ -107,7 +108,7 @@ plotGeneExpression <- function(gene,
#' Default FALSE.
#'
#' @returns A ggplot2::geom_segment if data_only = FALSE, else a data.frame
#' @export
#'
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -164,15 +165,17 @@ plotModelCoeffs <- function(gene,
}

.substitute_terms <- function(formula, value_list) {
terms <- unlist(strsplit(as.character(formula), "[+-]"))
# terms <- unlist(strsplit(as.character(formula), "[+-]"))
term_dict <- list()
for (term in terms) {
term <- trimws(term)
if (term %in% names(value_list)) {
value <- value_list[[term]]
formula <- gsub(term, value, formula, fixed = TRUE)
term_dict[[term]] <- as.numeric(value)
expr <- formula
for (term in names(value_list)) {
value <- value_list[[term]]
# term_dict[[term]] <- as.numeric(value)
pattern <- paste0('\\s+',term,'\\s+')
if (grepl(pattern, expr)) {
term_dict[term] <- as.numeric(value)
}
expr <- gsub(pattern, paste0(' ',value,' '), expr)
}
return(list(expr = formula, dict = term_dict))
return(list(expr = expr, dict = term_dict))
}
9 changes: 7 additions & 2 deletions R/runfgsea.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#' @param result A DESeqResults result object
#' @param breakdown_pathway_names Attempt to split pathway names into source and
#' pathway for easier reading
#' @param na_omit Bool, exclude genes with missing data in results? This checks
#' all values for NAs so be mindful of modified `result` objects
#' @inheritParams fgsea::fgseaSimple
#'
#' @inherit fgsea::fgseaSimple return
Expand All @@ -25,8 +27,11 @@ runfgsea <- function(result,
nperm = 1000,
minSize = 10,
maxSize = 500,
breakdown_pathway_names = FALSE) {
# result <- result %>% na.omit()
breakdown_pathway_names = FALSE,
na_omit = TRUE) {
if (na_omit) {
result <- result %>% na.omit()
}
fgsea_data <- result$stat
names(fgsea_data) <- rownames(result)
fgsea_data <- fgsea_data[!is.na(fgsea_data)]
Expand Down
6 changes: 5 additions & 1 deletion man/runfgsea.Rd

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

0 comments on commit 5f9fa98

Please sign in to comment.