#' get two types of Formula for disease
#'
#' @param score_RRS result of score_RRS()
#' @param enrich_double result of gsea_disease_set()
#'
#' @return two types of Formula for disease
#' @export
#'
#' @examples
#' library(M2D)
#' data("score_RRS_result")
#' data("gsea_disease_set_result")
#' formula_list <- get_Formula(
#' score_RRS = score_RRS_result,
#' enrich_double = gsea_disease_set_result$gsea_sig
#' )
#' formula_1 <- formula_list$formula1
#' head(formula_1)
#' formula_2 <- formula_list$formula2
get_Formula <- function(score_RRS,
enrich_double) {
# idea1: best single molecule
## 根据method1的逆向调控总分,计算小分子排名;
## 再取method2 significant molecule 交集
formula1 <- score_RRS %>%
dplyr::select(molecule, RRS_sum) %>%
dplyr::distinct(molecule, .keep_all = T) %>%
dplyr::arrange(dplyr::desc(RRS_sum)) %>%
dplyr::mutate(Rank = 1:length(unique(score_RRS$molecule))) %>%
dplyr::inner_join(enrich_double[, c("molecule", "Type")]) %>%
dplyr::distinct(molecule, .keep_all = T)
# idea2: formula molecules for as many as possible pathways
## step1: 挑选出每个通路的候选小分子(score>0)
## step2: 针对每个通路的候选小分子,根据总调控分数,选取最佳小分子
formula2 <- score_RRS %>%
dplyr::select(Term, molecule, RRS, RRS_sum) %>%
dplyr::filter(
RRS > 0,
molecule %in% enrich_double$molecule
) %>%
dplyr::arrange(Term, RRS_sum) %>%
dplyr::distinct(Term, .keep_all = T)
return(list(
formula1 = formula1,
formula2 = formula2
))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.