#' calculate RRS(reverse regulated score) of molecules against disease
#'
#' @param merge_pw_deg the result of merge_pw_deg()
#' @param wt_trans weight of trans gene
#' @param wt_cis weight of cis gene
#' @param wt_zero weight of zero gene
#'
#' @return RRS(reverse regulated score) statistics
#' @export
#'
#' @examples
#' library(M2D)
#' data("merge_pw_deg_result")
#' scores_RRS <- score_RRS(merge_pw_deg_result)
#' head(scores_RRS)
score_RRS <- function(merge_pw_deg,
wt_trans = 1,
wt_cis = -1,
wt_zero = -0.5) {
# data("merge_pw_deg_result")
# merge_pw_deg = merge_pw_deg_result
# wt_trans = 1
# wt_cis = -1
# wt_zero = -0.5
score_res <- merge_pw_deg %>%
dplyr::mutate(RRS = weight * (size_trans * wt_trans + size_cis * wt_cis + size_zero * wt_zero))
score_res2 <- score_res %>%
dplyr::distinct(Term,molecule, .keep_all = T) %>%
dplyr::group_by(molecule) %>%
dplyr::summarise(RRS_sum=sum(RRS))
score_res3 = score_res %>%
dplyr::left_join(.,score_res2) %>%
dplyr::select(
Term, molecule, Gene, disease_logFC, mol_logFC,
size, size_disease, size_trans, RRS, RRS_sum, dplyr::everything()
) %>%
dplyr::arrange(Term, molecule, Gene)
return(score_res3)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.