determine sex ratio from the bam file
3
1
Entering edit mode
9 months ago
Sara ▴ 220

I have some bam files and want to determine sex ratio of each sample. I think I have 2 ways to do so.

1- getting the ratio of x and y chromosomes (if so, what ratio is the best).

2- give a fixed fraction of x chr and y chr in my bam files (based on read count). (if this method , what fraction would be the best).

what would be the best approach?

bam • 793 views
ADD COMMENT
1
Entering edit mode
9 months ago
Marco Pannone ▴ 680

I think you can simply run samtools idxstats on your .bam files of interest and you get the info you need regarding all chromosomes, including X and Y.

ADD COMMENT
1
Entering edit mode
9 months ago

What is the purpose of this and what kind of source data do you have?

If the purpose is the determination of the gender, and you happen to have RNA-seq data, just look for the expression of Xist, which only females express.

If you are interested in determination of copy number variations (local or whole chromosome), use a proper tool for it, e.g. AlleleCount, Ascat (which makes use of AlleleCount, but in R) or FREEC.

ADD COMMENT
1
Entering edit mode
8 months ago
helrick ▴ 30

This is the method I personally use in bash using samtools idxstats:

 #!/bin/bash

 x_map=$(samtools idxstats $1 | grep "chrX\s" | cut -f 3)
 x_len=$(samtools idxstats $1 | grep "chrX\s" | cut -f 2)
 x_cov=$(echo "scale=3; ${x_map}/${x_len}" | bc)

 y_map=$(samtools idxstats $1 | grep "chrY\s" | cut -f 3)
 y_len=$(samtools idxstats $1 | grep "chrY\s" | cut -f 2)
 y_cov=$(echo "scale=3; ${y_map}/${y_len}" | bc)

 ratio=$(echo "scale=2; ${x_cov}/${y_cov}" | bc)
 echo $ratio

 if (( $(echo "$ratio > 4.00" | bc -l) )); then
     echo "F"
 else
     echo "M"
 fi

If you save the above in a bash script, sex_samples.sh, you can get the ratio of X and Y and the predicted sex by running sex_samples.sh sample.bam (provided you have samtools installed).

I assume that if the ratio of x to y coverage is above 4, the sample is female, otherwise male

ADD COMMENT

Login before adding your answer.

Traffic: 811 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6