diff --git a/DESCRIPTION b/DESCRIPTION index 9012949..69128b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,6 +41,7 @@ Imports: progeny, easierData, dorothea (>= 1.6.0), + decoupleR, quantiseqr, ROCR, grDevices, @@ -51,12 +52,15 @@ Imports: DESeq2, utils, dplyr, + tidyr, + tibble, matrixStats, rlang, BiocParallel, reshape2, rstatix, ggrepel, + magrittr, coin Suggests: knitr, rmarkdown, BiocStyle, testthat, SummarizedExperiment @@ -64,5 +68,5 @@ biocViews: GeneExpression, Software, Transcription, SystemsBiology, Pathways, Ge VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 5da3218..b09d448 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ export(explore_biomarkers) export(predict_immune_response) export(retrieve_easier_score) import(ggplot2) +import(magrittr) importFrom(BiocParallel,MulticoreParam) importFrom(BiocParallel,bplapply) importFrom(BiocParallel,register) @@ -24,7 +25,7 @@ importFrom(ROCR,performance) importFrom(ROCR,plot) importFrom(ROCR,prediction) importFrom(coin,pvalue) -importFrom(dorothea,run_viper) +importFrom(decoupleR,run_viper) importFrom(dplyr,filter) importFrom(easierData,get_HGNC_annotation) importFrom(easierData,get_TCGA_mean_pancancer) @@ -64,6 +65,8 @@ importFrom(stats,prcomp) importFrom(stats,quantile) importFrom(stats,sd) importFrom(stats,var) +importFrom(tibble,column_to_rownames) +importFrom(tidyr,pivot_wider) importFrom(utils,View) importFrom(utils,combn) importFrom(utils,data) diff --git a/R/compute_LR_pairs.R b/R/compute_LR_pairs.R index 9b82e9e..adb8f79 100644 --- a/R/compute_LR_pairs.R +++ b/R/compute_LR_pairs.R @@ -166,6 +166,8 @@ compute_LR_pairs <- function(RNA_tpm = NULL, colnames(LR_pairs_computed)[pos_keep] <- combo_name LR_pairs_computed <- LR_pairs_computed[, -pos_remove] } + # Remove LR pairs with all NA values + LR_pairs_computed <- LR_pairs_computed[, !is.na(apply(LR_pairs_computed, 2, sum))] if (verbose) message("Ligand-Receptor pair weights computed \n") return(as.data.frame(LR_pairs_computed)) diff --git a/R/compute_TF_activity.R b/R/compute_TF_activity.R index 116bc6a..e583dc6 100644 --- a/R/compute_TF_activity.R +++ b/R/compute_TF_activity.R @@ -10,9 +10,12 @@ #' the estimation of human transcription factor activities." #' Genome Research. 2019. DOI: 10.1101/gr.240663.118. #' -#' @importFrom dorothea run_viper +#' @import magrittr #' @importFrom stats na.exclude #' @importFrom dplyr filter +#' @importFrom decoupleR run_viper +#' @importFrom tidyr pivot_wider +#' @importFrom tibble column_to_rownames #' @importFrom easierData get_TCGA_mean_pancancer get_TCGA_sd_pancancer #' #' @param RNA_tpm data.frame containing TPM values with HGNC symbols @@ -93,17 +96,25 @@ compute_TF_activity <- function(RNA_tpm = NULL, round(length(genes_kept) / length(all_regulated_transcripts), 3) * 100, "%)" ) } - # TF activity: run viper - tf_activity <- dorothea::run_viper( - input = E, regulons = regulons, - options = list( - method = "none", minsize = 4, eset.filter = FALSE, - cores = 1, verbose = FALSE - ) - ) - # Samples as rows, TFs as columns - tf_activity <- t(tf_activity) + # Remove genes with all NA/Inf values + E <- E[!is.na(apply(E, 1, sum)), ] + E <- E[!is.infinite(apply(E, 1, sum)), ] + + # TF activity: run viper + tf_activity_df <- decoupleR::run_viper(mat = E, + network = regulons, + .source = "tf", + minsize = 4, + eset.filter = FALSE, + method = "none", + verbose = FALSE) + # To matrix + tf_activity <- tf_activity_df %>% + tidyr::pivot_wider(id_cols = condition, + names_from = source, + values_from = score) %>% + tibble::column_to_rownames("condition") if (verbose) message("TF activity computed! \n") diff --git a/vignettes/easier_user_manual.Rmd b/vignettes/easier_user_manual.Rmd index 688f070..613fc29 100644 --- a/vignettes/easier_user_manual.Rmd +++ b/vignettes/easier_user_manual.Rmd @@ -59,7 +59,7 @@ knitr::opts_chunk$set( ``` ```{r setup, include = FALSE} -library("easier") +#library("easier") ``` # Introduction {#introduction}