###### tags: `解析` `methylation` `InfiniumDiffMetMotR` `R`
NCBI GEO から病気に関係ありそうなデータを検索し、InfiniumDiffMetMotR で解析してみよう!
============
【NCBI GEO】
[GPL13534](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GPL13534) (HumanMethylation450)
[GPL21145](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GPL21145) (Infinium MethylationEPIC)
【解析に使用するパッケージ】
[InfiniumDiffMetMotR](https://github.com/takahirosuzuki1980/InfiniumDiffMetMotR)
## 1. InfiniumDiffMetMotRのインストール
RもしくはRstudio 起動し、
[InfiniumDiffMetMotR](https://github.com/takahirosuzuki1980/InfiniumDiffMetMotR)の**Install**の通りにインストールする。
## 2. データの取得(DL, 解凍)
GNU/Linux ターミナル にもどる。
今回は Platforms GPL21145 Infinium MethylationEPIC の [GSE100825](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE100825)を DL&解凍。
ページ下の方の *GSE100825_signal_intensities.txt.gz* を `wget` で取ってくる。
`gunzip`で解凍。
## 3. Normalization
データの整形
headerの名前を下記にする。(vi、sed、gsub、他でheader変更 )
- <font color="Blue">TargetID</font> ( Illumina ID )
- <font color="Blue">〇〇.Signal_A</font> (Unmethylated)
- <font color="Blue">〇〇.Signal_B</font> (Methylated)
- <font color="Blue">〇〇.Detection Pval</font> (Detection P value)
今回はsedを使ってheaderを変更する。
```
sed -e "s/ID_REF/TargetID/g" -e "s/ Unmethylated Signal/.Signal_A/g" -e "s/ Methylated Signal/.Signal_B/g" -e "s/ Detection Pval/.Detection Pval/g" GSE100825_signal_intensities.txt > GSE100825_Table_Control.txt
```
headerがすべてきちんと変更されたか確認する。

RもしくはRstudio 起動しパッケージの読み込み。
```{r}
library("InfiniumDiffMetMotR")
```
sample name を入れる (データの順番通りに)
```{r}
sample_names <-c("WS_1","CTR_1","WS_2","CTR_2","WS_3","CTR_3")
```
Normalization 走らせる
```{r}
lumiMethyNorm(fileName = "GSE100825_Table_Control.txt", sample_names = sample_names)
```
Normalization がうまくいくと、
*Process_Result* ディレクトリ、 *processed_Mval.txt*、*sel_processed_Mval.txt* が生成される。
###### Process_Result ディレクトリの中のPDF こんな感じ

## 4. モチーフ解析
###### (①もしくは②で行う)
### ① Rで行う。
RもしくはRstudio 起動し、
[InfiniumDiffMetMotR](https://github.com/takahirosuzuki1980/InfiniumDiffMetMotR) の、*3. motif database construction* の、*Example 2: IMAGE motif database* の通りにmotifDBListを指定する。
今回はIMAGEを使用する。
```{r}
motifDBList <- IMAGE_PWMlist
```
*Screening of enriched motifs* の MotScr 走らせる。
outname:好きな名前をつけられる
ControlColnum、TreatmentColnum:適宜変更
version:EPICは850(or EPIC), 450は450にする
```{r}
MotScr(infile="sel_processed_Mval.txt", motifDBList=motifDBList, cutoff=2, p.cutoff=0.001, outname="GSE100825", ControlColnum=c(2,4,6), TreatmentColnum=c(1,3,5), MethylDemethyl="Demethyl", sampling=1000, version ="850")
```
解析がうまくいくと、
*GSE100825_mot_analysis_result.txt* 、 *GSE100825_plot.pdf*、*GSE100825_result.RData*、*GSE100825_sig_plots* ディレクトリ が生成される。
*GSE100825_sig_plots* ディレクトリ の中にはsignificantだったピークのあるPDFのみが収納される。
### ② スクリプトで qsub 走らせる。
GNU/Linux ターミナルにもどる。
//osc-fs_home/s-maeda/8_NCBI_GEO_search に置いてある、
<font color="Blue">InfDiffMetMotR_para2.R</font>と、<font color="Blue">InfDiffMetMotR_para2.sh</font>をコピー。
vi で<font color="Blue">InfDiffMetMotR_para2.R</font> の中身のControlColnumとTreatmentColnumを変更。
```{r}
vi InfDiffMetMotR_para2.R
```
キーボードの `i` を押して INSERTモードにして下記のとおりに書き換える。
```{r}
ControlColnum = c(2,4,6)
TreatmentColnum = c(1,3,5)
```
キーボードの `esc` を押し、さらに`:wq` で 保存して終了。
qsub走らせる。
```{r}
qsub -q bigmem.q -N GSE100825 InfDiffMetMotR_para2.sh GSE100825_sh_ver Demethyl 850
```
###### qsub -q bigmem.q -N [job名] [.shファイル] [outname] [Memethyl or Demethyl] [EPIC or 450]
`qstat`でRUN確認。
`qdel job-ID`で停止可能。
*GSE100825_sh_ver.o job-ID*、*GSE100825_sh_ver.e job-ID*、に解析の状況やエラーなどが記録される。
###### GSE100825_mot_analysis_result.txt に significant があるとこんな感じ。

###### ピークがあるPDF とは こんな感じ。
