What does "-Shu" do in samtools view
2
0
Entering edit mode
3.2 years ago
quiocarbajal ▴ 10

Hello everyone! I am getting started with chip-seq analysis so this is probably a very basic question. In the following command:

samtools view -Shu s1.sam > s1.bam

What does -Shu do/mean?

Thanks a lot!

PS: I couldn't find any reference or explanation anywhere....

samtools samtools view -Shu • 1.0k views
3
Entering edit mode

There's a lot of times where a specific setting/command is not easy to google, or you may not have access to a search engine at that time. In case you're often in that situation, my tip would be to try these steps in order:

1) man yourcommand # Opens up the manual/man pages if installed or if they exists
2) yourcommand --help # See if there's a help menu for the tool
3) yourcommand -h # Same as above. Can also try --h, -help
4) yourcommand # Run the command without any arguments, often the fallback is to show the help menu.

In this case, man samtools opens up the man pages for samtools (with a section for view), or samtools view without arguments prints out the help menu. If all these fail, look at the tool's official website or its github repository, if they have one.

1
Entering edit mode

Tools that follow unix philosophy of parameters can have their parameters clustered. For example, samtools -Shu is the same as samtools -S -h -u. This applies to almost all unix commands that don't take an argument after the parameter name. If the parameter takes an argument, it must not be combined with another such parameter and must ideally be placed at the end of the cluster.

For example, tar -c -z -v -f file.tar.gz -T files.list can also be written as tar -czvf file.tar.gz -T files.list, but not as tar -czvfT file.tar.gz files.list

1
Entering edit mode

That's what I was missing, didn't know that. Thanks a lot!

5
Entering edit mode
3.2 years ago
\$ samtools view

Usage: samtools view [options] <in.bam>|<in.sam>|<in.cram> [region ...]

Options:
(...)
-u       uncompressed BAM output (implies -b)
-h       include header in SAM output
-S       ignored (input format is auto-detected)
(...)

2
Entering edit mode
3.2 years ago
Ram 37k

I couldn't find any reference or explanation anywhere....

Did you look at the samtools manual?

-u Output uncompressed BAM. This option saves time spent on compression/decompression and is thus preferred when the output is piped to another samtools command.

-h Include the header in the output.

-S Ignored for compatibility with previous samtools versions. Previously this option was required if input was in SAM format, but now the correct format is automatically detected by examining the first few characters of input.