Hello all. I am new to bioinformatics and needing some help. I have a Bam file generated from fastq, In the command I used, a sorted bam file is supposed to be created but I keep getting errors. I am trying to split the BAM file (about 50GB) into several Bam files so I can sort it separately. But I don't know how to go about this. (I am a beginner ).
Any help would be appreciated,
Thanks
(Peter).
Please provide details of exactly what programs you have run, what error messages you are getting, and what you have attempted. It is very difficult to assist without details.
the error message I can't recall exactly but it always can't sort the bam when it gets to that step.
ADD REPLY
• link
updated 5.6 years ago by
Ram
44k
•
written 7.0 years ago by
jaqx008
▴
110
0
Entering edit mode
Hi,
As recommended by Cameron, you should also provide the details of the error message you gets during your process.
You can look for this SAM to BAM conversion command, I believe that your bowtie2 process is generating SAM file in proper format. The command mentioned below should generate a proper BAM file for your sorting process.
Thank you samantha. all this is still new to me. so if I run the command
$ samtools view -bS dustMapping.sam -o dustMapping.bam
will the sorted bam file be generated? or just the BAM?
another thing is that my sam file is huge (100+ GB) and this might not be good for generating the sorted BAM file.
please suggest a command I can use to split the SAM into smaller sam files and also a command to convert all sam files into sorted bam and merge this into one BAM file. please if this is not too much trouble for you, help me.
Thanks
My bad. I was referring to a reader above named Samarth. Do you mean I should use the .BAM I have? and if yes, the command above don't specify input. and thats a little confusing. (Im a beginner).
Thanks Wouter.
Hi, You can also explore BamTools toolkit with "split" option.
usage: bamtools [--help] COMMAND [ARGS]
Available bamtools commands:
convert Converts between BAM and a number of other formats
count Prints number of alignments in BAM file(s)
coverage Prints coverage statistics from the input BAM file
filter Filters BAM file(s) by user-specified criteria
header Prints BAM header information
index Generates index for BAM file
merge Merge multiple BAM files into single file
random Select random alignments from existing BAM file(s), intended more as a testing tool.
resolve Resolves paired-end reads (marking the IsProperPair flag as needed)
revert Removes duplicate marks and restores original base qualities
sort Sorts the BAM file according to some criteria
***split Splits a BAM file on user-specified property, creating a new BAM output file for each value found***
stats Prints some basic statistics from input BAM file(s)
Please provide details of exactly what programs you have run, what error messages you are getting, and what you have attempted. It is very difficult to assist without details.
Thanks Samantha. here is the command I Ran.
the error message I can't recall exactly but it always can't sort the bam when it gets to that step.
Hi,
As recommended by Cameron, you should also provide the details of the error message you gets during your process.
You can look for this SAM to BAM conversion command, I believe that your bowtie2 process is generating SAM file in proper format. The command mentioned below should generate a proper BAM file for your sorting process.
Thanks
Thank you samantha. all this is still new to me. so if I run the command $ samtools view -bS dustMapping.sam -o dustMapping.bam will the sorted bam file be generated? or just the BAM? another thing is that my sam file is huge (100+ GB) and this might not be good for generating the sorted BAM file. please suggest a command I can use to split the SAM into smaller sam files and also a command to convert all sam files into sorted bam and merge this into one BAM file. please if this is not too much trouble for you, help me. Thanks
the
-S
of samtools is not necessary: input type is detected automatically.To generate a sorted bam from the file alignment.bam:
Samfiles are pretty big, but that shouldn't be a problem.
And who is Samantha?
My bad. I was referring to a reader above named Samarth. Do you mean I should use the .BAM I have? and if yes, the command above don't specify input. and thats a little confusing. (Im a beginner). Thanks Wouter.
I don't understand what you mean with command doesn't specify input.
There are introductions to bam-files and SAM-tools:
https://www.ncbi.nlm.nih.gov/tools/gbench/tutorial6/
http://samtools.github.io/hts-specs/SAMv1.pdf
Here you will find how to split your file (read the whole post and pay attention to the right panel - there may be similar
posts there ):
How Can I Split Bam Into Chromosome (In A Loop) Using Samtools?
A post about sorting:
Is My Bam File Sorted ?
Thank you Natasha. will look and get back with you if it helped.