MethylSomaticAnalysis 是一個用於分析甲基化與體細胞變異關聯性的高效工具,基於 C++17 和 htslib 實現。
- 整合分析體細胞變異與周圍甲基化位點的關聯性
- 支援單倍型(Haplotype)特異性甲基化分析
- 多層次分析結果:原始甲基化資料、變異摘要、單倍型聚合統計
- 針對高通量定序資料優化的記憶體管理和多執行緒處理
- 支援多個 VCF 檔案的批次處理
- Ubuntu 20.04+ 或相容 Linux 發行版
- C++17 相容的編譯器 (GCC 9.4.0+ 或 Clang 10+)
- htslib 1.17 或更高版本(處理 BAM/VCF 檔案)
- Boost 1.70.0+(用於記憶體管理)
- fmtlib 7.0.0+(用於日誌系統)
- CMake 3.16+ (建置系統)
# 基本開發工具
sudo apt update
sudo apt install -y build-essential cmake git
# htslib 相依
sudo apt install -y libhts-dev zlib1g-dev libbz2-dev liblzma-dev libcurl4-openssl-dev
# Boost 相依
sudo apt install -y libboost-dev libboost-system-dev libboost-thread-dev
# fmtlib
sudo apt install -y libfmt-devgit clone https://github.com/liaoyoyo/MethylSomaticAnalysis.git
cd MethylSomaticAnalysis# 創建並進入建置目錄
mkdir -p build && cd build
# 配置專案
cmake -DCMAKE_BUILD_TYPE=Release ..
# 編譯
make -j$(nproc)
# 安裝(可選)
sudo make install# 若已安裝至系統
msa --vcfs somatic.vcf.gz --ref reference.fa --tumor tumor.bam --normal normal.bam --outdir results
# 從建置目錄執行
./build/bin/msa --vcfs somatic.vcf.gz --ref reference.fa --tumor tumor.bam --normal normal.bam --outdir results| 參數 | 說明 |
|---|---|
--vcfs, -v |
Somatic VCF 檔案路徑(需有 .tbi 索引檔,可提供多個檔案) |
--ref, -r |
參考基因組檔案路徑(需有 .fai 索引) |
--tumor, -t |
腫瘤樣本 BAM 檔案路徑 |
--normal, -n |
正常樣本 BAM 檔案路徑 |
| 參數 | 預設值 | 說明 |
|---|---|---|
--window, -w |
2000 | 變異點擷取區域半徑 (bp) |
--bed, -b |
限定分析區域的 BED 檔案(可選) | |
--meth-high |
0.8 | 高甲基閾值 (0.01-1.0) |
--meth-low |
0.2 | 低甲基閾值 (0.01-1.0) |
--min-allele, -a |
0 | 每個變異至少需有此數量腫瘤 BAM 支持 ALT 讀數 |
--min-strand-reads |
1 | 每個 CpG 位點在正反鏈上各自至少需要的支持讀數 |
--threads, -j |
[自動] | 使用的執行緒數 |
--outdir, -o |
./results | 輸出目錄 |
--gzip-output |
true | 是否壓縮 Level 1/2 輸出 |
--log-level |
info | 日誌詳細程度 (trace/debug/info/warn/error/fatal) |
| 參數 | 預設值 | 說明 |
|---|---|---|
--max-read-depth |
10000 | 每個區域最大讀取深度 |
--max-ram-gb |
32 | 最大記憶體使用量 (GB) |
MethylSomaticAnalysis \
--vcfs /path/to/somatic_variants.vcf.gz \
--ref /path/to/hg38.fa \
--tumor /path/to/tumor.bam \
--normal /path/to/normal.bam \
--window 2000 \
--min-strand-reads 2 \
--threads 16 \
--outdir ./resultsMethylSomaticAnalysis \
--vcfs /path/to/tp.vcf.gz /path/to/fp.vcf.gz \
--ref /path/to/hg38.fa \
--tumor /path/to/tumor.bam \
--normal /path/to/normal.bam \
--bed /path/to/regions.bed \
--meth-high 0.8 \
--meth-low 0.2 \
--min-strand-reads 2 \
--log-level debug \
--threads 16 \
--outdir ./analysis_results# 從標準輸入讀取 BAM
samtools view -h /path/to/tumor.bam chr1:1000-2000 | \
MethylSomaticAnalysis \
--vcfs /path/to/chr1_variants.vcf.gz \
--ref /path/to/hg38.fa \
--tumor - \
--normal /path/to/normal.bam \
--outdir ./streamed_results每個輸入的 VCF 檔案會在輸出目錄中創建一個子目錄,包含以下檔案:
results/
└── {vcf_basename}/
├── global_summary_metrics.tsv # 全域參數與甲基化摘要
├── level1_raw_methylation_details.tsv.gz # 原始甲基化位點資料
├── level2_somatic_variant_methylation_summary.tsv.gz # 每個變異周圍甲基化統計
└── level3_haplotype_group_statistics.tsv # 單倍型群組統計比較
- global_summary_metrics.tsv:包含執行參數和全域統計資訊
- level1_raw_methylation_details.tsv.gz:每個甲基化位點的詳細資訊,包括染色體位置、甲基化比例、單倍型標籤等
- level2_somatic_variant_methylation_summary.tsv.gz:針對每個體細胞變異位點,彙總周圍甲基化位點的統計數據
- level3_haplotype_group_statistics.tsv:按單倍型和變異類型分組的聚合統計和比較
- 未定義的 htslib 函數:如遇到
undefined reference to 'bam_aux2array'或undefined reference to 'bcf_get_alleles'等錯誤,請確保安裝的 htslib 版本 ≥ 1.17。可使用以下命令檢查:若版本過低或使用系統庫路徑不正確,建議手動編譯安裝最新版 htslib:pkg-config --modversion htslib
然後重新配置 CMake 時指定 htslib 路徑:git clone https://github.com/samtools/htslib.git cd htslib git checkout 1.17 # 或更新版本 autoreconf -i ./configure --prefix=/usr/local make sudo make install
cmake -DCMAKE_BUILD_TYPE=Release -DHTSLIB_ROOT=/usr/local ..
- 確保 BAM 檔案已建立索引(.bai 檔案)
- 檢查 BAM 檔案是否包含甲基化標籤(MM/ML)和單倍型標籤(HP/PS)
- 若出現錯誤,可使用
--log-level debug獲取更詳細的診斷信息
- 大型基因組分析可使用
--max-read-depth限制每個區域的讀取深度 - 使用
--max-ram-gb限制最大記憶體使用量
- 增加
--threads參數可提高處理速度 - 使用
--bed參數限制分析區域,減少運算量 - 若僅關注特定變異類型,可先過濾 VCF 檔案
本專案遵循 C++17 標準和模組化設計原則。若要貢獻:
- Fork 專案並克隆至本地
- 建立功能分支:
git checkout -b feature/your-feature - 提交變更:
git commit -m 'Add some feature' - 推送到分支:
git push origin feature/your-feature - 提交 Pull Request
本專案採用 GNU GPLv3 授權條款發布。詳情請參閱 LICENSE 檔案。
若在學術研究中使用本工具,請引用:
MethylSomaticAnalysis: A tool for analyzing the association between DNA methylation and somatic variants.
(2025). GitHub repository, https://github.com/liaoyoyo/MethylSomaticAnalysis