Skip to content

Commit f42da66

Browse files
committed
feb 2025 update
1 parent 3d3e622 commit f42da66

27 files changed

+19042
-4780
lines changed

.bumpversion.cfg

-24
This file was deleted.

.bumpversion.toml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[tool.bumpversion]
2+
current_version = "1.5.2"
3+
search = "{current_version}"
4+
replace = "{new_version}"
5+
message = "Bump version: {current_version} → {new_version}"
6+
regex = false
7+
ignore_missing_version = false
8+
ignore_missing_files = false
9+
commit = true
10+
parse = """(?x)
11+
(?P<major>0|[1-9]\\d*)\\.
12+
(?P<minor>0|[1-9]\\d*)\\.
13+
(?P<patch>0|[1-9]\\d*)
14+
(?:\\.(?P<dev>\\d+))?
15+
"""
16+
17+
serialize = [
18+
"{major}.{minor}.{patch}.{dev}",
19+
"{major}.{minor}.{patch}",
20+
]
21+
22+
[[tool.bumpversion.files]]
23+
filename = "DESCRIPTION"
24+
search = "Version: {current_version}"
25+
replace = "Version: {new_version}"
26+
27+
[[tool.bumpversion.files]]
28+
filename = "README.md"
29+
search = "2F{current_version}"
30+
replace = "2F{new_version}"
31+
32+
[[tool.bumpversion.files]]
33+
filename = "pkgdown/index.md"
34+
search = "2F{current_version}"
35+
replace = "2F{new_version}"
36+
37+
[[tool.bumpversion.files]]
38+
filename = "vignettes/installation.Rmd"
39+
search = "{current_version}"
40+
replace = "{new_version}"
41+
42+
[[tool.bumpversion.files]]
43+
filename = ".github/workflows/pkgdown.yaml"
44+
search = "VERSION: '{current_version}'"
45+
replace = "VERSION: '{new_version}'"
46+

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ biocViews:
3030
Imports: dplyr,
3131
assertthat,
3232
assertable,
33-
clusterProfiler,
33+
clusterProfiler (>= 4.13),
3434
DT,
3535
gganatogram,
3636
ggpubr,

R/data.R

+7
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
#' @format A character vector of 24 color codes
55
#'
66
"tissue_colors"
7+
8+
#' Format (columns) for clusterProfiler enrichment output
9+
#'
10+
#'
11+
#' @format A character vector of 23 variables
12+
#'
13+
"cp_output_cols"

R/disease_drug.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' "refseq_transcript_id", "ensembl_protein", "refseq_protein")
1313
#' @param ignore_id_err logical indicating if analysis should
1414
#' continue when uknown query identifiers are encountered
15-
#' @param incude_gene_summary logical indicating if gene summary (NCBI/UniProt) should be included
15+
#' @param include_gene_summary logical indicating if gene summary (NCBI/UniProt) should be included
1616
#' in output data tables
1717
#' @param tumor_site character indicating primary tumor site of interest
1818
#'
@@ -118,9 +118,10 @@ cancer_association_rank <- function(
118118

119119
if(NROW(qgenes_match$found) > 2500){
120120
lgr::lgr$warn( paste0(
121-
"Query set must exceeds max limit of 2,500 valid entries - ",
121+
"Query set exceeds max limit of 2,500 valid entries - ",
122122
"limiting input to 2,500 entries"))
123-
qgenes_match[['found']] <- head(qgenes_match[['found']], 2500)
123+
qgenes_match[['found']] <-
124+
utils::head(qgenes_match[['found']], 2500)
124125
}
125126

126127
lgr::lgr$info( paste0(

R/enrich.R

+109-23
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ get_go_enrichment <- function(query_entrez,
5555
)
5656

5757
if (simplify == T) {
58-
ego <- clusterProfiler::simplify(ego, cutoff=0.8,
59-
by="p.adjust", select_fun=min)
58+
ego <- clusterProfiler::simplify(
59+
ego, cutoff=0.8,
60+
by="p.adjust", select_fun=min)
6061
}
6162

6263
df <- as.data.frame(utils::head(ego, 5000))
@@ -67,6 +68,12 @@ get_go_enrichment <- function(query_entrez,
6768
df <- df |> dplyr::mutate(db = ontology)
6869
}
6970
if (nrow(df) > 0) {
71+
assertable::assert_colnames(
72+
df, c("ID","Description","Count",
73+
"GeneRatio","BgRatio","pvalue",
74+
"qvalue","geneID"),
75+
only_colnames = F, quiet = T)
76+
7077
df <- suppressWarnings(
7178
df |>
7279
dplyr::mutate(db = paste0("GO_", .data$db)) |>
@@ -75,8 +82,6 @@ get_go_enrichment <- function(query_entrez,
7582
go_description = "Description",
7683
count = "Count",
7784
gene_ratio = "GeneRatio",
78-
rich_factor = "RichFactor",
79-
fold_enrichment = "FoldEnrichment",
8085
z_score = "zScore",
8186
background_ratio = "BgRatio",
8287
gene_id = "geneID") |>
@@ -85,9 +90,6 @@ get_go_enrichment <- function(query_entrez,
8590
paste0('<a href=\'http://amigo.geneontology.org/amigo/term/',
8691
.data$go_id,'\' target=\'_blank\'>',
8792
.data$go_description,'</a>')) |>
88-
tidyr::separate(.data$gene_ratio,
89-
c('num_query_hits','num_query_all'),
90-
sep = "/", remove = F, convert = T) |>
9193
dplyr::mutate(qvalue = as.numeric(.data$qvalue)) |>
9294
dplyr::mutate(pvalue = as.numeric(.data$pvalue)) |>
9395
dplyr::mutate(
@@ -103,20 +105,65 @@ get_go_enrichment <- function(query_entrez,
103105
!is.na(.data$pvalue),
104106
as.numeric(formatC(.data$pvalue, format = "e",
105107
digits = 1)),
108+
as.numeric(NA)))
109+
)
110+
111+
df <- suppressWarnings(
112+
df |>
113+
dplyr::mutate(qvalue = as.numeric(.data$qvalue)) |>
114+
dplyr::mutate(pvalue = as.numeric(.data$pvalue)) |>
115+
dplyr::mutate(
116+
qvalue =
117+
dplyr::if_else(
118+
!is.na(.data$qvalue),
119+
as.numeric(formatC(.data$qvalue, format = "e",
120+
digits = 1)),
106121
as.numeric(NA))) |>
107-
tidyr::separate(.data$background_ratio,
108-
c('num_background_hits','num_background_all'),
109-
sep = "/", remove = F, convert = T) |>
122+
dplyr::mutate(
123+
pvalue =
124+
dplyr::if_else(
125+
!is.na(.data$pvalue),
126+
as.numeric(formatC(.data$pvalue, format = "e",
127+
digits = 1)),
128+
as.numeric(NA)))
129+
)
130+
131+
df$enrichment_factor <- NA
132+
if("FoldEnrichment" %in% colnames(df)){
133+
df <- df |>
134+
dplyr::mutate(
135+
enrichment_factor = round(
136+
as.numeric(.data$FoldEnrichment), digits = 2)) |>
137+
dplyr::select(-c("FoldEnrichment"))
138+
}else{
139+
df <- df |>
140+
tidyr::separate(
141+
.data$gene_ratio,
142+
c('num_query_hits','num_query_all'),
143+
sep = "/", remove = F, convert = T) |>
144+
tidyr::separate(
145+
.data$background_ratio,
146+
c('num_background_hits','num_background_all'),
147+
sep = "/", remove = F, convert = T) |>
110148
dplyr::mutate(
111149
enrichment_factor =
112-
round(as.numeric((.data$num_query_hits / .data$num_query_all) /
113-
(.data$num_background_hits / .data$num_background_all)),
114-
digits = 1)) |>
150+
round(as.numeric((
151+
.data$num_query_hits / .data$num_query_all) /
152+
(.data$num_background_hits / .data$num_background_all)),
153+
digits = 2)) |>
115154
dplyr::select(-c("num_query_hits",
116155
"num_query_all",
117156
"num_background_hits",
118157
"num_background_all"))
119-
)
158+
159+
}
160+
df$rich_factor <- NA
161+
if("RichFactor" %in% colnames(df)){
162+
df <- df |>
163+
dplyr::mutate(
164+
rich_factor = as.numeric(.data$RichFactor)) |>
165+
dplyr::select(-c("RichFactor"))
166+
}
120167

121168
gene2id <- NULL
122169
if (!is.null(genedb)) {
@@ -164,6 +211,15 @@ get_go_enrichment <- function(query_entrez,
164211
df$setting_p_value_adj_method <- p_value_adjustment_method
165212
df$setting_min_geneset_size <- min_geneset_size
166213
df$setting_max_geneset_size <- max_geneset_size
214+
215+
for(c in oncoEnrichR::cp_output_cols){
216+
if(!(c %in% colnames(df))){
217+
df[,c] <- NA
218+
}
219+
}
220+
df <- df |>
221+
dplyr::select(
222+
dplyr::any_of(oncoEnrichR::cp_output_cols))
167223
}
168224
} else {
169225
df <- NULL
@@ -238,15 +294,18 @@ get_universal_enrichment <- function(query_entrez,
238294
df <- as.data.frame(utils::head(enr,5000))
239295
rownames(df) <- NULL
240296
if (nrow(df) > 0) {
297+
assertable::assert_colnames(
298+
df, c("ID","Description","Count",
299+
"GeneRatio","BgRatio","pvalue",
300+
"qvalue","geneID"),
301+
only_colnames = F, quiet = T)
241302
df <- suppressWarnings(
242303
df |>
243304
dplyr::rename(
244305
standard_name = "ID",
245306
description = "Description",
246307
count = "Count",
247308
gene_ratio = "GeneRatio",
248-
rich_factor = "RichFactor",
249-
fold_enrichment = "FoldEnrichment",
250309
z_score = "zScore",
251310
background_ratio = "BgRatio",
252311
gene_id = "geneID")
@@ -331,6 +390,21 @@ get_universal_enrichment <- function(query_entrez,
331390
as.numeric(formatC(.data$pvalue, format = "e",
332391
digits = 1)),
333392
as.numeric(NA))) |>
393+
dplyr::mutate(
394+
db = dplyr::if_else(is.na(.data$db) &
395+
nchar(dbsource) > 0,
396+
dbsource,
397+
as.character(.data$db)))
398+
)
399+
400+
if("FoldEnrichment" %in% colnames(df)){
401+
df <- df |>
402+
dplyr::mutate(
403+
enrichment_factor = round(
404+
as.numeric(.data$FoldEnrichment), digits = 2)) |>
405+
dplyr::select(-c("FoldEnrichment"))
406+
}else{
407+
df <- df |>
334408
tidyr::separate(
335409
.data$gene_ratio,
336410
c('num_query_hits','num_query_all'),
@@ -344,17 +418,20 @@ get_universal_enrichment <- function(query_entrez,
344418
round(as.numeric((
345419
.data$num_query_hits / .data$num_query_all) /
346420
(.data$num_background_hits / .data$num_background_all)),
347-
digits = 1)) |>
421+
digits = 2)) |>
348422
dplyr::select(-c("num_query_hits",
349423
"num_query_all",
350424
"num_background_hits",
351-
"num_background_all")) |>
425+
"num_background_all"))
426+
427+
}
428+
df$rich_factor <- NA
429+
if("RichFactor" %in% colnames(df)){
430+
df <- df |>
352431
dplyr::mutate(
353-
db = dplyr::if_else(is.na(.data$db) &
354-
nchar(dbsource) > 0,
355-
dbsource,
356-
as.character(.data$db)))
357-
)
432+
rich_factor = as.numeric(.data$RichFactor)) |>
433+
dplyr::select(-c("RichFactor"))
434+
}
358435

359436
gene2id <- NULL
360437
if (!is.null(genedb)) {
@@ -392,6 +469,15 @@ get_universal_enrichment <- function(query_entrez,
392469
df$setting_p_value_adj_method <- p_value_adjustment_method
393470
df$setting_min_geneset_size <- min_geneset_size
394471
df$setting_max_geneset_size <- max_geneset_size
472+
473+
for(c in oncoEnrichR::cp_output_cols){
474+
if(!(c %in% colnames(df))){
475+
df[,c] <- NA
476+
}
477+
}
478+
df <- df |>
479+
dplyr::select(
480+
dplyr::any_of(oncoEnrichR::cp_output_cols))
395481
}
396482
} else {
397483
df <- NULL

R/onco_enrichr.R

+8-3
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,7 @@ onco_enrich <- function(query = NULL,
17861786
#' @param file full filename for report output (e.g. "oe_report.html" or "oe_report.xlsx")
17871787
#' @param ignore_file_extension logical to accept any type of filaname extensions (for Galaxy integration)
17881788
#' @param overwrite logical indicating if existing output files may be overwritten
1789+
#' @param render_quarto_quiet logical indicating if Quarto rendering should be done quietly
17891790
#' @param format file format of output (html/excel)
17901791
#' @param ... options for Galaxy/non self-contained HTML. Only applicable for use in Galaxy
17911792
#'
@@ -1797,6 +1798,7 @@ write <- function(report,
17971798
file = "testReport.html",
17981799
ignore_file_extension = F,
17991800
overwrite = F,
1801+
render_quarto_quiet = T,
18001802
format = "html",
18011803
...) {
18021804

@@ -1868,7 +1870,8 @@ write <- function(report,
18681870
return()
18691871
}
18701872

1871-
output_directory <- dirname(file)
1873+
#output_directory <- dirname(file)
1874+
output_directory <- normalizePath(dirname(file))
18721875

18731876
if(is.na(html_extern_path) & !embed_resources){
18741877
html_extern_path <- output_directory
@@ -1885,6 +1888,9 @@ write <- function(report,
18851888
lgr::lgr$info(paste0("ERROR: ",val))
18861889
return()
18871890
}
1891+
}else{
1892+
lgr::lgr$info(paste0("ERROR: provide absolute (not relative) path to output file"))
1893+
return()
18881894
}
18891895

18901896
if (overwrite == F) {
@@ -1956,7 +1962,6 @@ write <- function(report,
19561962
system.file("templates", package = "oncoEnrichR")
19571963

19581964
## make temporary directory for quarto report rendering
1959-
#stringi::stri_rand_strings(10, 1)
19601965
tmp_quarto_dir <- file.path(
19611966
output_directory,
19621967
paste0('quarto_', stringi::stri_rand_strings(1, 15))
@@ -2018,7 +2023,7 @@ write <- function(report,
20182023
quarto::quarto_render(
20192024
input = quarto_main_template_sample,
20202025
execute_dir = tmp_quarto_dir,
2021-
quiet = T)
2026+
quiet = render_quarto_quiet)
20222027

20232028
## check that supporting libs do not exist in output directory (Galaxy)
20242029
if (galaxy_run == T & embed_resources == F){

R/ppi.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ get_network_hubs <- function(edges = NULL,
1919
d <- igraph::graph_from_data_frame(d = edges, directed = F)
2020

2121
## hub score (Kleinberg"s hub centrality)
22-
hscore <- igraph::hub_score(d)
22+
#hscore <- igraph::hub_score(d)
23+
hscore <- igraph::authority_score(d)
2324
hub_scores <- data.frame(
2425
symbol = names(sort(hscore$vector,decreasing = T)),
2526
hub_score = round(sort(hscore$vector,decreasing = T), digits = 3),

R/sysdata.rda

17 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)