knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

M2D

The goal of M2D is to find Molecule(s) TO Disease by reverse trancsriptome.

Installation

You can install the development version of M2D from GitHub with:

# install.packages("devtools")
devtools::install_github("lishensuo/M2D")

Analysis pipeline

This is a basic analysis pipeline shows you how to use this package to find approprate molecule(s) for specific complex disease.

library(M2D)
## basic example code

Step1 : create m2d object

dir_disease = system.file("extdata",
                          "demo_BRCA_disease.csv",
                          package = "M2D")
disease = read.csv(dir_disease)
head(disease)
dir_molecule = system.file("extdata",
                           "demo_molecules_321_12320.csv",
                           package = "M2D")

molecules = data.table::fread(dir_molecule,
                              data.table = FALSE) %>%
  tibble::column_to_rownames("V1")
molecules[1:4,1:4]
m2dObj = list(disease=disease,
              molecule=molecules)

Step2 : find disease related (GOBP) pathway

# load pre-calculated result for saving time
#disease_pw_list <- find_disease_pw(m2dObj)
data("find_disease_pw_result")
disease_pw_list = find_disease_pw_result
disease_pw <- disease_pw_list$term_df
head(disease_pw)

#visualize pathways correlation
pwIDs <- unique(disease_pw$Term)
p = vis_pw_cor_ph(pwIDs)

#visualize weight of pathways
vis_pw_wt_radar(disease_pw_list)

Step2 : calculate RRS(Reverse Regulated Score) for each moleculs against above pathways

(1) merge degs of the disease and molecules

merge_pw_degs <- merge_pw_deg(m2dObj,
  disease_pw = disease_pw_list$term_df
)
head(merge_pw_degs)

# visualization of Trans gene distribution between a molecule and the disease
sle_pw <- "GO:0001501"
sle_mol <- "CGP-20712"
vis_bell_term(
  score_RRS = merge_pw_degs,
  sle_pw = sle_pw,
  sle_mol = sle_mol
)

(2) calculate RRS(Reverse Regulated Score)

scores_RRS <- score_RRS(merge_pw_degs)
head(scores_RRS)

#ternplot visualization of trans/cis/zero distribution
sle_pw <- "GO:0001501"
sle_mol <- "CGP-20712"
vis_tern_one(
  score_RRS = score_RRS_result,
  sle_pw = sle_pw,
  sle_mol = sle_mol
)

Step3 : disease up/down geneset GSEA enrichment to molecules' signature

enrich_double_list <- gsea_disease_set(
  m2dObj = m2dObj,
  demo = TRUE
)
enrich_signi <- enrich_double_list$gsea_sig
dim(enrich_signi)
enrich_signi[1:10,1:6]

#Barplot visualization: single/double gsea enrichment(Down geneset with negative NES or Up geneset with positive NES)
data("get_Formula_result") #see the follow  step
gsea_df <- enrich_double_list$gsea_sig
sle_mols <- get_Formula_result$formula1$molecule[1:10]
vis_bar_double_enrich(gsea_df = gsea_df, sle_mols = sle_mols)

Step4 : get 2 types of formula

formula_list <- get_Formula(
  score_RRS = scores_RRS,
  enrich_double = enrich_signi
)
#Type1: best global molecule rank for the disease
formula_1 = formula_list$formula1
head(formula_1)
#Type2: appropriate molecule formula against all disease related pathway
formula_2 = formula_list$formula2
head(formula_2)

# chord visualization:  formula molecule against disease related pathways
sle_mols <- unique(formula_list$formula2$molecule)
vis_formula_RRS_chord(score_RRS = scores_RRS, sle_mols = sle_mols)

# chord visualization:  formula molecule against disease up/down geneset
vis_formula_gsea_chord(gsea_df = enrich_signi, sle_mols = sle_mols)

What is special about using README.Rmd instead of just README.md? You can include R chunks like so: You'll still need to render README.Rmd regularly, to keep README.md up-to-date. devtools::build_readme() is handy for this. You could also use GitHub Actions to re-render README.Rmd every time you push. An example workflow can be found here: https://github.com/r-lib/actions/tree/v1/examples. In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.



lishensuo/M2D documentation built on Jan. 4, 2022, 9:44 a.m.