This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools view for selecting the unmapped reads

Hi there,

I used Interactive Genome Viewer (IGV), to visualization of produced sam file from bowtie2, after loading of sorted-sam in IGV..from where and how I can select and identify the unmapped reads? Because by rolling mouse cursor around the each read, in box saying that mapped..

Don't be silent please and help me

Thank you in advance

rna-seq

I went across the link you suggested, then what I should type for flag?

As Devon suggested below.

You mean, in cmd I should type the command Devon suggested?

Yes.

It would be better to switch to linux or something like Cygwin ( if you intended to use Windows only ) rather than trying out to do it on windows,

Yes you are right but I have internet connection problem in linux, that's why I'm using Windows

Anyway I typed this command but told failed to open foo.bam

I copied the eg1.sam produced in bowtie2 folder in samtools folder and typed the command but got error

If you have sam file, specify that input is sam using -S option. By default, samtools expects bam file

samtools view -S -f 4 foo.sam

Thank you, the same error

Can you give exact command, the folder path where the file is and error?

Sorry,

I extracted samtools.zip to samtools, copied eg1.sam produced in bowtie2 folder to samtools folder and I typed in cmd:

cd D:\samtools
samtools view -S -f 4 foo.sam

It's saying that:

main_samview failed to open "foo sam" for reading

Does it actually say foo sam or instead foo.sam? In the former case try specifying the correct name. In the latter case check the file permissions.

You are right, saying foo.sam

Sorry, what is file permissions?

Given that you're in Berlin, perhaps you're more familiar with "Datei-Zugriffsrechte". Normally one right clicks on a file/directory and goes to "Preferences" (something along the lines of "Einstellungen" in the German version of Windows, if I remember correctly).

thank you, I am going to check

1 answer

You won't see unmapped reads in IGV. If you want to extract them from a SAM/BAM/CRAM file, then use samtools (samtools view -f 4 foo.bam)

Sorry Devon,

Do you mean I should type this command in cmd? I am on Windows

Devon,

I entered samtools view -f 4 file.bam > unmapped.sam and I got result

the best

Log in to answer this question.