본문 바로가기

전체 글125

VCF 파일에서 filter 열 PASS 만 골라내기 VCF 파일에서 filter 열 PASS 만 골라내기 방법1: python script #extract.py cnt = 0 with open("sample1.vcf", "r") as fr: for line in fr: if line.startswith("#"): pass else: l = line.split() if l[6] == "PASS": cnt += 1 print(cnt) 방법2: linux command line awk -F '\t' '{if($0 ~ /\#/) print; else if($7 == "PASS") print}' sample1.vcf > sample1_pass.vcf #or awk '$7=="PASS" {print $0}' sample1.vcf > sample1_pass.vcf 방.. 2024. 3. 13.
VCF 파일에서 샘플 개수 세기 VCF 파일에서 샘플 개수 세기 방법1 : python script #count.py with open("sample1.vcf","r") as fr: for line in fr: if line.startswith("#CHROM"): print(len(line.split()) -9) 방법2: linux command line number of variants: zcat sample1.vcf.gz | grep -c '^[^#]' number of samples: zcat sample1.vcf.gz | grep -m1 "^#CHROM" | cut -f 10- | tr "\t" "\n" | wc -l 방법3: bcftools bcftools query -l sample1.vcf | wc -l #or bcftoo.. 2024. 3. 12.
VCF 파일에서 header 와 data 분리하기 VCF 파일 소개 VCF(variant call format) 파일은 서열의 변이 정보를 담은 파일 입니다. 텍스트 파일로 메모장과 같은 텍스트 뷰어로 열어 내용을 확인 할 수 있습니다. VCF 파일은 "##" 주석이 달려있는 meta-information ##fileformat=VCFv4.0 ##fileDate=20110705 ##reference=1000GenomesPilot-NCBI37 ##phasing=partial ##INFO= ##INFO= ##INFO= ##INFO= ##INFO= ##INFO= ##FILTER= ##FILTER= ##FORMAT= ##FORMAT= ##FORMAT= ##FORMAT= "#" 주석으로 시작하는 header line 과 data line 으로 구성 되어 있습니다.. 2024. 3. 12.
[bcftools] 사용 방법/명령어 총정리 -2 bcftools 사용법 GATK CombineVariants 에서 지정된 세트 확인하기 bcftools query -f out_combine.vcf.gz |sort |uniq VCF 에서 샘플 리스트 확인하기 bcftools query -l test.vcf 지정 파일에서 snps 확인하기 bcftools view -v snps sample.vcf.gz VCF 에서 변이정보(variants) 확인하기 (0|0 genotypes 제외) bcftools view -c1 input.vcf VCF 에서 non-variants 정보 확인하기 (AC=0) bcftools view -H -c0 input.vcf.gz FORMAT 영역 필터링 하기 bcftools filter -sFilterName -e'FORMAT/D.. 2023. 12. 13.
[bcftools] 사용 방법/명령어 총정리 -1 bcftools 사용법 지역별 변형 필터링( chr1 및 chr2에 mapping 된 변이) bcftools filter -r1,2 sample.snps.genotypes.hg38.vcf.gz 2개 샘플에 대한 정보 보기 bcftools view -s NA20818,NA20819 sample.vcf.gz 필터된 변이에 대한 통계 보기 bcftools view -f PASS sample.vcf.gz 해더 없이 변이 정보 보기 bcftools view -H sample.vcf.gz 특정 영역 (chr20:1-200000) 변이 정보 보기 bcftools view -r chr20:1-200000 -s NA20818,NA20819 sample.vcf.gz 특정 영역(chr20:1-200000 ) 제외하고 변이 .. 2023. 12. 5.
[samtools] Downsampling bam with samtools 계산하기 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 al.. 2023. 11. 27.