Output file of samtools flagstat empty
0
0
Entering edit mode
20 days ago

In my script with "Generate mapping statistics deleting "-O tsv" after flagstat

samtools flagstat -@ 20 $MAPPING/${i}.sorted.bam 

> $MAPPING/${i}.mapping_stats.txt", the output text file is empty.  Please suggest a solution.
samtools-flagstat • 245 views
ADD COMMENT
0
Entering edit mode

If you posted the entire command line then you did not include -O $MAPPING/${i}.mapping_stats.txt in that.

ADD REPLY
0
Entering edit mode

Hi,

In your samtools flagstat, -o specifies the output format. This can be set to 'default', 'json', or 'tsv'. If -o is not specified , the default format will be selected. However, based on the manpages, I cannot tell whether a txt file is the default format, but based on your question I would assume so.

Out of curiosity, if you set it to -o tsv, are those files empty as well? Is that why you removed it? Are those files called $MAPPING/${i}.mapping_stats.tsv? I am more asking these question for myself.

GenoMax suggested including -O $MAPPING/${i}.mapping_stats.txt. Indeed, in the SAMtools GitHub (https://github.com/bahlolab/bioinfotools/blob/master/SAMtools/flagstat.md), you can see the format of the output in their example code:

samtools flagstat $bamFile >> ${THIS_DIR}/${bamFile}_flagstat.txt

If this is simply not an issue with -o, I might suspect that samtools can't find your files.

In your code, $MAPPING is the variable that holds the directory path where your sorted BAM files are located. It probably stands for something like /path/to/mapping_files. Your ${i} is likely a variable used in a loop to represent the identifier of each sample. So, $MAPPING/${i}.sorted.bam represents the full path to your dataset. You might want to make sure all of your files exists within that path you specified. You can try doing

echo "MAPPING: $MAPPING"
echo "i: $i"

If there are any issues here, you can try using the absolute path rather than the relative path.

ADD REPLY

Login before adding your answer.

Traffic: 1222 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