Which tools should I use to sort sam file by read name for raw read count using HTseq and How I can sort multiple sam file.
Picard SortSam or samtools sort
Which tools should I use to sort sam file by read name for raw read count using HTseq and How I can sort multiple sam file.
Picard SortSam or samtools sort
Recent versions of HTseq-count don't require files to be query sorted. If, for some reason, you really do want to bother, either tool will work fine. As noted in the comments, featureCounts is much faster. Note also that HTseq-count can use BAM files too, so you don't need to actually save SAM files.
HTSeq-count of FeatureCounts does not require sorted files. You can directly generate a matrix file containing all the read counts form different aligned files in one go using featureCounts.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
you may be able to convert to bam format while sorting
Do we also need to put -n in samtools sort in above loop.
because HTseq needs sam file which is sorted by read name. I am using samtools version samtools/1.4
Thanks
If you need the file sorted by read headers then yes.
Hi genomax:
I just found by running single command that I also need to specify -T in samtools to give names to tempory files:
Could you insert this command in the above loop to sort mutiple sam files.
And could you also explain the loop in breaks so that I can understand what exactly happening:
like:
what this command does:
ls -1 *.sam
and then what is the role of this:further loop structure I can understand, it going to every input file and generation the output files.
ls
command is listing*.sam
files one per line and piping/sending that tosed
command.sed
command is removing (technically replacing.sam
with nothing) the.sam
extension so you can use the filename (which generally would have sample ID) for parts of thesamtools
command where you need to use different extensions or add a word to indicate the resulting file is sorted. While unix does not need this/nor doessamtools
, I find it useful to have that information in the file name so at a glance one can tell if a file is trimmed (e.g.file_R1_trim.fq.gz
) or trimmed and sorted (e.g.file_trim_sort.bam
).-T $i.sort
to the command loop above, if you need to name the temp files with the name of file.Hi Genomax,
I want to run above loop on multiple amplicon sequencing pair-end read fastq files to generate cmd file:
I put bash script in same data folder and location for fastq-join is:
Pair end File name are:
Or you could use
featureCounts
( http://bioinf.wehi.edu.au/featureCounts/ ) and let it do the sorting as needed.It is easier to convert
sam
tobam
to do further analysis.