Does it also gives the number of reads for each reference and alternate allele over a SNP ?
I have more than 500 samples (or thier bam files). I also have more than 1000 snps in snp table as shown below. I need to get the number of reads (allelic depth) for reference allele and alternate allele from all the bam files. Is there any program to get that directly from bam files given the snp information below? I know pile up package in R samtools does that, but for some reason I often miss either positive strand read or - strand counts.
snp table:
chr position REF ALT TYPE
3 23322333 T C snp
2 22322223 A T snp
3 answers
Bam-readcount is ideal for this. Apart from raw read depth of every base present it gives you many useful information, inluding average quality mapping, average base quality etc. Its output is also used for variant filtering in fpfilter script - https://github.com/ckandoth/variant-filter.
In order to obtain information for every alleles present, you'll have to provide script with reference file in fasta format. The command looks like this:
bam-readcount -q1 -l sites_list -f reference.fasta your_file.bam > your_file.readcount
-q1 option means minimum mapping quality of 1.
Sites list is supposed to look like this (tab delimited):
chr1 56777 56777
Creators of the fpfilter script mentioned above provided a nice one-liner to convert your vcf file into sites_list file:
perl -ane 'print join("\t",@F[0,1,1])."\n" unless(m/^#/)' your.vcf > sites_list
I tested it on human and mice data and it worked fine in both cases. Sample output from mice data looks like this:
chr1 8816113 T 146 =:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 A:3:4.00:26.00:4.00:0:3:0.71:0.01:26.00:0:0.00:121.33:0.65 C:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 G:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 T:143:63.80:24.38:63.80:79:64:0.57:0.01:21.76:79:0.62:120.83:0.50 N:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00
chr1 8816178 G 121 =:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 A:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 C:120:71.14:26.27:71.14:68:52:0.44:0.02:28.25:68:0.24:122.28:0.48 G:1:73.00:22.00:73.00:0:1:0.31:0.03:8.00:0:0.00:116.00:0.84 T:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 N:0:0.00:0.00:0.00:0:0:0.00:0.00:0.00:0:0.00:0.00:0.00 .
Yes, exactly.
what would be the command if i have to calculate the reference and alternate allele reads counts for a bam file in.bam and a vcf file in.vcf ?
Yes what would be the command for that and If there is anythig to pipeline or loop through multiple bam files for multiple snp? I also could not get ALT base count using mock data. I am using their mock data and with the following command(which doesn't seem to work):
./bam-readcount -q 0 -l /Downloads/site_list.txt /Downloads/test.bam
Hi. I tried to use bam-readcount qith my data but it seams to have a problem with paired-end reads. Does the program work with paired-end reads?
Open a new post with your question, and add more detail, like the command you used. I am going to delete your answer, as it is not an answer, and likely no one will see it here.
Log in to answer this question.