-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
100 lines (76 loc) · 3.89 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# BSDMR
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/geneprophet/BSDMR?branch=master&svg=true)](https://ci.appveyor.com/project/geneprophet/BSDMR)
<!-- badges: end -->
The goal of BSDMR is to find DMRs or CMRs by high order methylation profiles between species.
## Installation
You can install the development version from [GitHub](https://github.com/geneprophet/BSDMR) with:
``` r
# install.packages("devtools")
devtools::install_github("geneprophet/BSDMR")
```
## Example
This is a basic example which shows you how to use the package:
```{r example}
#library the package
library(BSDMR)
#example pipeline
#step1. read files
##read methylation report (the result of bismark)
file <- system.file("extdata", "example_human_chr22_CpG_report.txt", package = "BSDMR")
human_met <- read_methylation_report(file,min_coverage=4,type = "CG")
file <- system.file("extdata", "example_mouse_chr15_CpG_report.txt", package = "BSDMR")
mouse_met <- read_methylation_report(file,min_coverage=4,type = "CG")
##read annotation file (customized region)
file <- system.file("extdata", "human_chr22_annotation.txt", package = "BSDMR")
human_anno <- read_annotation(file)
file <- system.file("extdata", "mouse_chr15_annotation.txt", package = "BSDMR")
mouse_anno <- read_annotation(file)
#step2. cluster_sites_to_region
human_region <- cluster_sites_to_region(methylation = human_met,
annotation = human_anno,
min_sites_number = 10,
max_distance_between_sites = 200,
is_parallel = TRUE)
#step3. liftOver map the human_region to the annotated region of another species(mouse)
filePath <- system.file("extdata", "hg38ToMm10.over.chain", package = "BSDMR")
mouse_region <- change_genomic_coordinate(human_region,filePath,mouse_anno)
#step4. create region object as the input of modeling
human_obj <- create_region_object(human_met, human_region)
mouse_obj <- create_region_object(mouse_met, mouse_region)
#step5. infer profiles of reion object
human_basis_profile <- create_rbf_object(M = 8)
human_fit_profiles <- infer_profiles_vb(X = human_obj$met, basis = human_basis_profile,
is_parallel = TRUE, vb_max_iter = 100)
human_basis_mean <- create_rbf_object(M = 0)
human_fit_mean <- infer_profiles_vb(X = human_obj$met, basis = human_basis_mean,
is_parallel = TRUE, vb_max_iter = 100)
mouse_basis_profile <- create_rbf_object(M = 8)
mouse_fit_profiles <- infer_profiles_vb(X = mouse_obj$met, basis = mouse_basis_profile,
is_parallel = TRUE, vb_max_iter = 100)
mouse_basis_mean <- create_rbf_object(M = 0)
mouse_fit_mean <- infer_profiles_vb(X = mouse_obj$met, basis = mouse_basis_mean,
is_parallel = TRUE, vb_max_iter = 100)
#step6. computer the adjusted consine distance of profiles and measure the similarity
similarity <- adjusted_cosine_similarity(queryProfiles = human_fit_profiles,subjectProfiles = mouse_fit_profiles)
#step7. visualization
which(similarity>0.9)
i=160
plot_infer_profiles(region = i, obj_prof = human_fit_profiles,obj_mean = human_fit_mean,
obs = human_obj, title = paste0("Gene ID ",human_obj$anno$id[i]))
plot_infer_profiles(region = i, obj_prof = mouse_fit_profiles,obj_mean = mouse_fit_mean,
obs = mouse_obj, title = paste0("Gene ID ",mouse_obj$anno$id[i]))
```