Entering edit mode
20 days ago
ramendra.sarma
•
0
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.
If you posted the entire command line then you did not include
-O $MAPPING/${i}.mapping_stats.txt
in that.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: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
If there are any issues here, you can try using the absolute path rather than the relative path.