Skip to content

Commit

Permalink
0.9.7 release - survival associations
Browse files Browse the repository at this point in the history
  • Loading branch information
sigven committed Jun 4, 2021
1 parent ba4bc89 commit 8b49fa1
Show file tree
Hide file tree
Showing 46 changed files with 2,596 additions and 375 deletions.
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: oncoEnrichR
Type: Package
Title: Cancer-dedicated gene set interpretation
Version: 0.9.7
Date: 2021-05-27
Date: 2021-06-04
Authors@R:
c(person(given = "Sigve",
family = "Nakken",
Expand Down Expand Up @@ -30,13 +30,12 @@ Depends:
R (>= 4.0), SummarizedExperiment (>= 1.22.0), GSEABase (>= 1.54.0)
biocViews:
Imports: tidyverse (>= 1.3.1), visNetwork (>= 2.0.9), DT (>= 0.18), plotly (>= 4.9.3), pals (>= 1.7),
org.Hs.eg.db, magrittr (>= 2.0.1), clusterProfiler (>= 4.0.0), igraph (>= 1.2.6), reshape2 (>= 1.4.4), rlogging,
org.Hs.eg.db, magrittr (>= 2.0.1), clusterProfiler (>= 4.0.0), igraph (>= 1.2.6), reshape2 (>= 1.4.4), log4r (>= 0.3.2),
gganatogram, maftools (>= 2.8.0), SummarizedExperiment (>= 1.22.0), GSEABase (>= 1.54.0),
oncoPharmaDB (>= 0.3.1), assertable (>= 0.2.8), ggpubr (>= 0.4.0),
assertable (>= 0.2.8)
oncoPharmaDB (>= 0.3.1), ggpubr (>= 0.4.0), assertable (>= 0.2.8), TissueEnrich (>= 1.12.0)
License: MIT
Encoding: UTF-8
Remotes: mjkallen/rlogging, jespermaag/gganatogram, sigven/oncoPharmaDB
Remotes: jespermaag/gganatogram, sigven/oncoPharmaDB
LazyData: true
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
6 changes: 3 additions & 3 deletions R/annotate.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ target_disease_associations <-
dplyr::inner_join(genedb, by = "symbol") %>%
dplyr::distinct()

rlogging::message(paste0("Open Targets Platform: annotation of protein targets to disease phenotypes (minimum association score = ",min_association_score,")"))
oncoEnrichR:::log4r_info(paste0("Open Targets Platform: annotation of protein targets to disease phenotypes (minimum association score = ",min_association_score,")"))

target_assocs <- target_genes %>%
dplyr::left_join(oncoEnrichR::otdb$all, by=c("ensembl_gene_id","symbol"))
Expand Down Expand Up @@ -268,7 +268,7 @@ target_drug_associations <- function(qgenes,
dplyr::inner_join(genedb, by = "symbol") %>%
dplyr::distinct()

rlogging::message(paste0("Open Targets Platform: annotation of protein targets to targeted drugs"))
oncoEnrichR:::log4r_info(paste0("Open Targets Platform: annotation of protein targets to targeted drugs"))

result <- list()
result[['target_drugs']] <- data.frame()
Expand All @@ -282,7 +282,7 @@ target_drug_associations <- function(qgenes,
dplyr::filter(!is.na(targeted_cancer_drugs_lp) |
!is.na(targeted_cancer_drugs_ep))

rlogging::message(paste0("Open Targets Platform: annotation of target tractabilities (druggability)"))
oncoEnrichR:::log4r_info(paste0("Open Targets Platform: annotation of target tractabilities (druggability)"))

result[['tractability_ab']] <- target_genes %>%
dplyr::select(ensembl_gene_id) %>%
Expand Down
4 changes: 2 additions & 2 deletions R/cell_tissue.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gene_tissue_cell_spec_cat <-
etype <- "cell type"
edb <- "HPA"
}
rlogging::message(
oncoEnrichR:::log4r_info(
paste0("Retrieving ", etype,
" specificity (", edb,
") category of target genes")
Expand Down Expand Up @@ -157,7 +157,7 @@ gene_tissue_cell_enrichment <-
etype <- "cell types"
edb <- "HPA"
}
rlogging::message(
oncoEnrichR:::log4r_info(
paste0("Estimating enrichment of ", etype,
" (", edb,
") in target set with TissueEnrich"))
Expand Down
8 changes: 4 additions & 4 deletions R/crispr.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ get_crispr_lof_scores <- function(qgenes,
qsource = "symbol",
projectscoredb = NULL) {

rlogging::message("Project Score (CRISPR/Cas9 screen): retrieval of genes ",
"associated with loss-of-fitness in cancer cell lines")
oncoEnrichR:::log4r_info(paste0("Project Score (CRISPR/Cas9 screen): retrieval of genes ",
"associated with loss-of-fitness in cancer cell lines"))
stopifnot(is.character(qgenes))
stopifnot(!is.null(projectscoredb))
stopifnot(!is.null(projectscoredb[['fitness_scores']]))
Expand Down Expand Up @@ -62,9 +62,9 @@ get_target_priority_scores <-
qsource = "symbol",
projectscoredb = NULL){

rlogging::message("Project Score (CRISPR/Cas9 screen): retrieval of ",
oncoEnrichR:::log4r_info(paste0("Project Score (CRISPR/Cas9 screen): retrieval of ",
"prioritized targets from loss-of-fitness screens ",
"in cancer cell lines")
"in cancer cell lines"))
stopifnot(is.character(qgenes))
stopifnot(!is.null(projectscoredb))
stopifnot(!is.null(projectscoredb[['target_priority_scores']]))
Expand Down
20 changes: 10 additions & 10 deletions R/enrich.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ get_go_enrichment <- function(query_entrez,
simplify = F,
pool = F){

rlogging::message(
oncoEnrichR:::log4r_info(
paste0("Enrichment - GO: performing gene enrichment analysis of target set (subontology ",ontology,")"))
rlogging::message(paste0("Enrichment - GO: settings: p_value_cutoff = ",p_value_cutoff,", q_value_cutoff = ",q_value_cutoff))
rlogging::message(paste0("Enrichment - GO: settings: p_value_adjustment_method = ",p_value_adjustment_method))
rlogging::message(paste0("Enrichment - GO: settings: minGSSize = ",min_geneset_size))
rlogging::message(paste0("Enrichment - GO: settings: maxGSSize = ",max_geneset_size))
oncoEnrichR:::log4r_info(paste0("Enrichment - GO: settings: p_value_cutoff = ",p_value_cutoff,", q_value_cutoff = ",q_value_cutoff))
oncoEnrichR:::log4r_info(paste0("Enrichment - GO: settings: p_value_adjustment_method = ",p_value_adjustment_method))
oncoEnrichR:::log4r_info(paste0("Enrichment - GO: settings: minGSSize = ",min_geneset_size))
oncoEnrichR:::log4r_info(paste0("Enrichment - GO: settings: maxGSSize = ",max_geneset_size))


stopifnot(is.character(query_entrez))
Expand Down Expand Up @@ -155,11 +155,11 @@ get_universal_enrichment <- function(query_entrez,
TERM2SOURCE = NULL,
dbsource = ""){

rlogging::message(paste0("Enrichment - ",dbsource,": performing gene enrichment analysis of target set"))
rlogging::message(paste0("Enrichment - ",dbsource,": settings: p_value_cutoff = ",p_value_cutoff,", q_value_cutoff = ",q_value_cutoff))
rlogging::message(paste0("Enrichment - ",dbsource,": settings: p_value_adjustment_method = ",p_value_adjustment_method))
rlogging::message(paste0("Enrichment - ",dbsource,": settings: minGSSize = ",min_geneset_size))
rlogging::message(paste0("Enrichment - ",dbsource,": settings: maxGSSize = ",max_geneset_size))
oncoEnrichR:::log4r_info(paste0("Enrichment - ",dbsource,": performing gene enrichment analysis of target set"))
oncoEnrichR:::log4r_info(paste0("Enrichment - ",dbsource,": settings: p_value_cutoff = ",p_value_cutoff,", q_value_cutoff = ",q_value_cutoff))
oncoEnrichR:::log4r_info(paste0("Enrichment - ",dbsource,": settings: p_value_adjustment_method = ",p_value_adjustment_method))
oncoEnrichR:::log4r_info(paste0("Enrichment - ",dbsource,": settings: minGSSize = ",min_geneset_size))
oncoEnrichR:::log4r_info(paste0("Enrichment - ",dbsource,": settings: maxGSSize = ",max_geneset_size))

stopifnot(is.character(query_entrez))
stopifnot(!is.null(genedb) | !is.data.frame(genedb))
Expand Down
75 changes: 54 additions & 21 deletions R/onco_enrichr.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,15 @@ init_report <- function(project_title = "Project title",
rep[["data"]][["query"]][["validation_status"]] <- "perfect_go"

## prognosis/survival - gene expression (HPA)
rep[["data"]][["cancer_prognosis"]][['assocs']] <- data.frame()
rep[["data"]][["cancer_prognosis"]][['hpa']] <- list()
rep[["data"]][["cancer_prognosis"]][['hpa']][['assocs']] <- data.frame()

## prognosis/survival - gene expression, mutation, CNA (CSHL)
rep[["data"]][["cancer_prognosis"]][['km_cshl']] <- list()
rep[["data"]][["cancer_prognosis"]][['km_cshl']][['assocs']] <- list()
rep[["data"]][["cancer_prognosis"]][['km_cshl']][['assocs']][['cna']] <- data.frame()
rep[["data"]][["cancer_prognosis"]][['km_cshl']][['assocs']][['mut']] <- data.frame()
rep[["data"]][["cancer_prognosis"]][['km_cshl']][['assocs']][['exp']] <- data.frame()

## cancer hallmarks
rep[["data"]][["cancer_hallmark"]][["target"]] <- data.frame()
Expand Down Expand Up @@ -432,6 +440,16 @@ onco_enrich <- function(query,
show_crispr_lof = TRUE,
show_complex = TRUE) {

my_log4r_layout <- function(level, ...) {
paste0(format(Sys.time()), " - ", level, " - ", ..., "\n", collapse = "")
}
logger <- log4r::logger(threshold = "INFO", appenders = log4r::console_appender(my_log4r_layout))
if(!is.null(logger)){
assign("log4r_logger",
logger, envir = .GlobalEnv)
}


stopifnot(!is.null(query))
stopifnot(is.character(query))
stopifnot(length(query) >= 1)
Expand All @@ -444,7 +462,7 @@ onco_enrich <- function(query,
"fdr", "none"))

if (length(query) > 800) {
rlogging::message(
oncoEnrichR:::log4r_info(
paste0("WARNING: Due to size limitations, oncoEnrichR is limited to the analysis of n = 800 entries. Query contained n = ",
length(query), " identifiers, limiting to top 800 genes"))
query <- head(unique(query), 800)
Expand Down Expand Up @@ -477,6 +495,8 @@ onco_enrich <- function(query,
min_subcellcomp_confidence <= 6)
stopifnot(ppi_add_nodes <= 50)



onc_rep <- oncoEnrichR:::init_report(
project_title = project_title,
project_owner = project_owner,
Expand Down Expand Up @@ -555,7 +575,7 @@ onco_enrich <- function(query,

if(NROW(qgenes_match[["found"]]) < 5){
onc_rep[['config']][['show']][['enrichment']] <- F
rlogging::message(
oncoEnrichR:::log4r_info(
paste0("WARNING: Function and pathway enrichment is NOT performed for gene sets of size < 5. Query contained n = ",
NROW(qgenes_match[["found"]])," valid entries"))
}
Expand All @@ -577,8 +597,8 @@ onco_enrich <- function(query,
refseq_protein_xref = oncoEnrichR::genedb[['refseq_protein_xref']],
uniprot_xref = oncoEnrichR::genedb[['uniprot_xref']])
if (background_genes_match[["match_status"]] == "imperfect_stop") {
rlogging::message("WARNING: Background geneset not defined properly - ",
"using all protein-coding genes instead")
oncoEnrichR:::log4r_info(paste0("WARNING: Background geneset not defined properly - ",
"using all protein-coding genes instead"))
background_entrez <- unique(oncoEnrichR::genedb[['all']]$entrezgene)
}else{
background_entrez <- unique(background_genes_match[["found"]]$entrezgene)
Expand Down Expand Up @@ -718,7 +738,7 @@ onco_enrich <- function(query,
## TEST TO CHECK OMNIPATHDB IS LIVE IS NOT WORKING (NOT SURE WHY)
# service_is_down <- unique(is.na(pingr::ping("omnipathdb.org")))
# if(service_is_down){
# rlogging::message("EXCEPTION: https://omnipathdb.org is NOT responding - ",
# oncoEnrichR:::log4r_info("EXCEPTION: https://omnipathdb.org is NOT responding - ",
# "skipping retrievel of protein complexes")
#
# onc_rep[["config"]][["show"]][["protein_complex"]] <- FALSE
Expand Down Expand Up @@ -888,7 +908,7 @@ onco_enrich <- function(query,

if (show_cancer_hallmarks == T){

rlogging::message("Retrieving genes with evidence of cancer hallmark properties")
oncoEnrichR:::log4r_info("Retrieving genes with evidence of cancer hallmark properties")
onc_rep[["data"]][["cancer_hallmark"]][["target"]] <-
oncoEnrichR::genedb[["cancer_hallmark"]][["short"]] %>%
dplyr::inner_join(
Expand All @@ -902,7 +922,7 @@ onco_enrich <- function(query,
if(nrow(onc_rep[["data"]][["cancer_hallmark"]][["target"]]) > 0){
n_genes_cancerhallmarks <- length(unique(onc_rep[["data"]][["cancer_hallmark"]][["target"]]$symbol))
}
rlogging::message(paste0("Number of query genes attributed with cancer hallmark properties: ",
oncoEnrichR:::log4r_info(paste0("Number of query genes attributed with cancer hallmark properties: ",
n_genes_cancerhallmarks))

}
Expand All @@ -915,11 +935,18 @@ onco_enrich <- function(query,
}

if(show_prognostic_cancer_assoc == T){
onc_rep[["data"]][["cancer_prognosis"]][['assocs']] <-
onc_rep[["data"]][["cancer_prognosis"]][['hpa']][['assocs']] <-
oncoEnrichR:::hpa_prognostic_genes(
query_symbol,
genedb = oncoEnrichR::genedb[['all']])

for(feature in c('exp', 'mut', 'cna')){
onc_rep[["data"]][["cancer_prognosis"]][['km_cshl']][['assocs']][[feature]] <-
oncoEnrichR:::km_cshl_survival_genes(
query_symbol,
projectsurvivaldb = oncoEnrichR::projectsurvivaldb[[feature]])
}

}

if(show_cell_tissue == T){
Expand Down Expand Up @@ -1024,7 +1051,6 @@ write <- function(report,
}

## TODO: check that report parameter is a valid oncoEnrichR result object

if(!is.null(report)){
assign("onc_enrich_report",
report, envir = .GlobalEnv)
Expand All @@ -1039,30 +1065,33 @@ write <- function(report,
package = "oncoEnrichR")
report_theme <- "default"

rlogging::message("------")
rlogging::message("Writing HTML file with report contents")
oncoEnrichR:::log4r_info("------")
oncoEnrichR:::log4r_info("Writing HTML file with report contents")
markdown_input <- system.file("templates", "onco_enrich_report.Rmd",
package = "oncoEnrichR")
rmarkdown::render(
markdown_input,
output_format = rmarkdown::html_document(
theme = report_theme, toc = T, toc_depth = 3,
toc_float = T, number_sections = F,
theme = report_theme,
toc = T,
toc_depth = 3,
toc_float = T,
number_sections = F,
includes = rmarkdown::includes(after_body = disclaimer)),
output_file = file_basename,
output_dir = output_directory,
clean = T,
intermediates_dir = output_directory,
quiet = T)
rlogging::message(paste0("Output file: ",
oncoEnrichR:::log4r_info(paste0("Output file: ",
file))
rlogging::message("------")
oncoEnrichR:::log4r_info("------")
}
if (format == "excel") {

wb <- openxlsx::createWorkbook()
rlogging::message("------")
rlogging::message("Writing Excel workbook with report contents")
oncoEnrichR:::log4r_info("------")
oncoEnrichR:::log4r_info("Writing Excel workbook with report contents")

table_style_index <- 15
for(elem in c("query",
Expand All @@ -1079,6 +1108,7 @@ write <- function(report,
"aberration",
"coexpression",
"prognostic_association",
"survival_association",
"crispr_ps_fitness",
"crispr_ps_prioritized"
)){
Expand All @@ -1090,6 +1120,9 @@ write <- function(report,
if(elem == "prognostic_association"){
show_elem <- "cancer_prognosis"
}
if(elem == "survival_association"){
show_elem <- "cancer_prognosis"
}
if(elem == "drug_known"){
show_elem <- "drug"
}
Expand Down Expand Up @@ -1122,12 +1155,12 @@ write <- function(report,
}

openxlsx::saveWorkbook(wb, file, overwrite = TRUE)
rlogging::message(paste0("Output file: ",file))
rlogging::message("------")
oncoEnrichR:::log4r_info(paste0("Output file: ",file))
oncoEnrichR:::log4r_info("------")
}
else{
if(format == "json"){
rlogging::message("JSON output not yet implemented")
oncoEnrichR:::log4r_info("JSON output not yet implemented")
}
}
}
4 changes: 2 additions & 2 deletions R/ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ get_ppi_network <- function(qgenes,
dplyr::mutate(query_node = T) %>%
dplyr::distinct()

rlogging::message("STRINGdb: retrieving protein-protein interaction network from (v11.0b)")
rlogging::message(paste0("STRINGdb: Settings - required_score = ",
oncoEnrichR:::log4r_info("STRINGdb: retrieving protein-protein interaction network from (v11.0b)")
oncoEnrichR:::log4r_info(paste0("STRINGdb: Settings - required_score = ",
settings$minimum_score,", add_nodes = ",settings$add_nodes))

all_edges <- data.frame()
Expand Down
Loading

0 comments on commit 8b49fa1

Please sign in to comment.