Difference between revisions of "Preparing read data"

From GenomeView Manual
Jump to navigation Jump to search
Line 17: Line 17:
 
In this example we have a read alignment in BAM format called 'alignment.sam'. We use the program [http://picard.sourceforge.net/command-line-overview.shtml#SortSam SortSam] from Picard to sort the file by coordinates. This also works if your aligner gives you a BAM file as output, i.e. 'alignment.bam'
 
In this example we have a read alignment in BAM format called 'alignment.sam'. We use the program [http://picard.sourceforge.net/command-line-overview.shtml#SortSam SortSam] from Picard to sort the file by coordinates. This also works if your aligner gives you a BAM file as output, i.e. 'alignment.bam'
  
<code lang='bash'>
+
'''Sorting'''
  java -Xmx1g -jar SortSam.jar I=aligned.sam O=sorted.bam SO=coordinate
+
The instruction below will sort the SAM file by coordinate.
</code>
+
  java -Xmx500m -jar SortSam.jar I=aligned.sam O=sorted.bam SO=coordinate
 +
 
 +
Important:
 +
# You may need to put the full path for SortSam.jar to the location where you installed the Picard programs.
 +
# You may need to put the full path to where the aligned.sam file sits and where you want the sorted.bam file to end up.
 +
# You have to make sure to replace 'alignment.sam' with the actual name of you aligned SAM/BAM file.
 +
# You have to make sure to replace 'sorted.bam' with the actual name that you want your sorted file to have.
 +
 
 +
Sanity checks:
 +
# Make sure there are no errors reported on the console when running this instruction.
 +
# Make sure that you now have a file 'sorted.bam' and that it's not completely empty, i.e. it has a size > 0
 +
 
 +
'''Indexing'''
 +
After you have sorted the file, you can index the resulting BAM file with the instruction below:
 +
 
 +
java -Xmx500m -jar BuildBamIndex.jar I=sorted.bam
 +
 
 +
Important:
 +
# You may need to put the full path for BuildBamIndex.jar to the location where you installed the Picard programs.
 +
# You may need to put the full path to where the 'sorted.bam' file sits.
 +
 
 +
 
 +
Sanity checks:
 +
# Make sure there are no errors reported on the console when running this instruction.
 +
# Make sure that you now have a file 'sorted.bam.'''bai'''' and that it's not completely empty, i.e. it has a size > 0. This file will be created in the same directory as the 'sorted.bam' file.
  
 
=== Sorting and indexing with SAMtools (Mac OS and Linux) ===
 
=== Sorting and indexing with SAMtools (Mac OS and Linux) ===
Line 42: Line 66:
 
=== Variants ===
 
=== Variants ===
 
If you are investigating SNPs or other genetic variants, you also may want to [[Recipe variant calls|create variant calls]].
 
If you are investigating SNPs or other genetic variants, you also may want to [[Recipe variant calls|create variant calls]].
 +
 +
 +
[[Category:User]][[Category:Platform]]

Revision as of 00:12, 18 October 2013

The best format to present short read alignments to GenomeView is the BAM format. You need to have your read data in this format and it has to be aligned.

Aligning reads

GenomeView is a visualization tool and does not do the computationally intensive read alignment. There are however dozens of tools already available to do this job.

If you need help aligning your reads, you may want to have a look at the Recipe to align reads to get some ideas.

Preparing for visualization

To prepare a BAM file straight from the aligner there are a few more steps you may have to take to get your data in the right format.

  1. Sort reads based on genomic coordinates
  2. Index sorted reads.

Sorting and indexing with Picard (OS independent)

You need to have a local copy of Picard installed and you need to run these commands on the command-line.

In this example we have a read alignment in BAM format called 'alignment.sam'. We use the program SortSam from Picard to sort the file by coordinates. This also works if your aligner gives you a BAM file as output, i.e. 'alignment.bam'

Sorting The instruction below will sort the SAM file by coordinate.

java -Xmx500m -jar SortSam.jar I=aligned.sam O=sorted.bam SO=coordinate

Important:

  1. You may need to put the full path for SortSam.jar to the location where you installed the Picard programs.
  2. You may need to put the full path to where the aligned.sam file sits and where you want the sorted.bam file to end up.
  3. You have to make sure to replace 'alignment.sam' with the actual name of you aligned SAM/BAM file.
  4. You have to make sure to replace 'sorted.bam' with the actual name that you want your sorted file to have.

Sanity checks:

  1. Make sure there are no errors reported on the console when running this instruction.
  2. Make sure that you now have a file 'sorted.bam' and that it's not completely empty, i.e. it has a size > 0

Indexing After you have sorted the file, you can index the resulting BAM file with the instruction below:

java -Xmx500m -jar BuildBamIndex.jar I=sorted.bam

Important:

  1. You may need to put the full path for BuildBamIndex.jar to the location where you installed the Picard programs.
  2. You may need to put the full path to where the 'sorted.bam' file sits.


Sanity checks:

  1. Make sure there are no errors reported on the console when running this instruction.
  2. Make sure that you now have a file 'sorted.bam.bai' and that it's not completely empty, i.e. it has a size > 0. This file will be created in the same directory as the 'sorted.bam' file.

Sorting and indexing with SAMtools (Mac OS and Linux)

Steps to get from the various aligner formats to the SAM format are available on the SAMtools website.

Steps to go from SAM to indexed BAM.

samtools faidx reference.fasta (will create reference.fasta.fai for the next step)

samtools view -bS -t reference.fasta.fai alignment.sam -o alignment.bam

samtools sort alignment.bam sorted (will create sorted.bam)

samtools index sorted.bam (will create sorted.bam.bai, which is read by GenomeView together with the bam file)


Summary visualizations

Coverage plots

If you are primarily interested in the read coverage and not in individual reads, you may want to create coverage plots.

Variants

If you are investigating SNPs or other genetic variants, you also may want to create variant calls.