bedtools 使用速查表
Last updated
Last updated
# 找出 A 與 B 有重疊的區間 (輸出 A)
bedtools intersect -a A.bed -b B.bed -u
# 找出 A 中完全沒有重疊的區間
bedtools intersect -a A.bed -b B.bed -v
# 同時輸出 A 與 B 的原始欄位
bedtools intersect -a A.bed -b B.bed -wa -wb
# 輸出 A、B 原始欄位並加上重疊長度
bedtools intersect -a A.bed -b B.bed -wo
# 保留所有 A,若無重疊則 overlap=0
bedtools intersect -a A.bed -b B.bed -wao
# Left outer join,若無重疊則 B 欄位為 .
bedtools intersect -a A.bed -b B.bed -loj
# 計算每個 A 與 B 的重疊次數
bedtools intersect -a A.bed -b B.bed -c
# 與上相同,但若無重疊則輸出 0
bedtools intersect -a A.bed -b B.bed -C
# 要求至少 50% 的 A 被 B 覆蓋
bedtools intersect -a A.bed -b B.bed -f 0.5 -u
# 要求 A 與 B 互相至少有 50% 的重疊比例
bedtools intersect -a A.bed -b B.bed -f 0.5 -F 0.5 -r
# 只保留同股的重疊
bedtools intersect -a A.bed -b B.bed -s
# 對 BED12 格式,以 exon 為單位計算交集
bedtools intersect -a A.bed -b B.bed -wo -split
# 使用多個 B 檔並輸出來源檔名
bedtools intersect -a A.bed -b B1.bed B2.bed -wa -wb -filenames# 轉換 BAM 為 BED,並將 CIGAR 字串放在第七欄
bedtools bamtobed -i sample.bam -cigar > sample.bed
# 將有剪接的比對拆分為 exon 區段
bedtools bamtobed -i sample.bam -split > sample_split.bed# 使用 genome header 檔 (染色體長度) 轉換為 BAM
bedtools bedtobam -i sample.bed -g genome_header.txt > sample.bam
# 保留 BED12 的 exon 結構並轉為 BAM
bedtools bedtobam -i sample.bed -g genome_header.txt -bed12 > sample_exon.bam# 從 BED 區間提取 FASTA 序列
bedtools getfasta -fi genome.fa -bed regions.bed -fo output.fasta
# 將 exon 區段擷取並合併為一條序列
bedtools getfasta -fi genome.fa -bed exons.bed -fo exons_output.fasta -split