본문 바로가기
Bioinformatics

[samtools] Downsampling bam with samtools 계산하기

by 코딩하는 미토콘드리아 bioinformatics 2023. 11. 27.
반응형

Downsampling Bam with samtools

 

samtools view [option] [sample.bam]

 

출처:https://www.htslib.org/doc/samtools-view.html

 

samtools-view(1) manual page

Manual page from samtools-1.18 released on 25 July 2023 samtools view – views and converts SAM/BAM/CRAM files samtools view [options] in.sam|in.bam|in.cram [region...] With no options or regions specified, prints all alignments in the specified input ali

www.htslib.org

 

Baseline command

#25% subsampling
samtools view -s 0.25 -b sample.bam > 25p_sample.bam
#50% subsampling
samtools view -s 0.5 -b sample.bam > 50p_sample.bam
#75% subsampling
samtools view -s 0.75 -b sample.bam > 75p_sample.bam

 

 

Downsampling specific region (ChrX only)

samtools view -bh sample.bam chrX > only_chrX.bam
samtools view -s 0.50 -b only_chrX.bam > 50p_chrX.bam
#합쳐주기
#samtools merge result_50p_chrX.bam -b exclude_chrX.bam 50p_chrX.bam
#samtools index result_50p_chrX.bam

 

 

 

 

samtools-merge(1) manual page

Manual page from samtools-1.18 released on 25 July 2023 samtools merge – merges multiple sorted files into a single file samtools merge [options] -o out.bam [options] in1.bam ... inN.bam samtools merge [options] out.bam in1.bam ... inN.bam Merge multiple

www.htslib.org

 

출처:https://www.htslib.org/doc/samtools-merge.html

 

samtools-index(1) manual page

Manual page from samtools-1.18 released on 25 July 2023 samtools index – indexes SAM/BAM/CRAM files samtools index -M [-bc] [-m INT] FILE FILE [FILE...] samtools index [-bc] [-m INT] aln.sam|aln.bam|aln.cram [out.index] Index coordinate-sorted BGZIP-comp

www.htslib.org

출처 :https://www.htslib.org/doc/samtools-index.html

반응형