How to Open a bam file using Jbrowse?

How to Open a bam file using Jbrowse?

Please find the following steps to display a bam file using Jbrowse.

STEP – 1

Let’s take an example to download https://code.google.com/p/gasv/downloads/detail?name=Example.bam

Example.bam (80.2 MB)

STEP – 2

Sort and create an index for the downloaded bam file (Example.bam) using the following command from Samtools.

samtools sort Example.bam Example.sorted
samtools index Example.sorted.bam

(After issued the Command to generate an indexed file for Example.bam, samtools will create Example.bam.bai as its indexed file).

chr-bam-sam-300x163

(in the enclosed screen shot it’s showing for Chromosomes-21.bam file)

STEP – 3

Goto the sample_data folder of Jbroswe (/var/www/JBrowse/sample_data/)

sample _data is the folder that contains the Configuration file & the physical file to display using Jbrowse. Inside sample_data there is 2 more folders named as “json” & “raw”. Json contains the configuration settings in shape of json array. raw contains the physical file. Let us explore more in below.

STEP – 4

Go inside the raw (/var/www/JBrowse/sample_data/raw/) folder in sample_data. Create a new folder named as “example”.

STEP – 5

Copy the all the related files for Example.bam (i.e. Example.bam & Example.bam.bai) to /var/www/Jbrowse/sample_data/raw/example/ folder.

STEP – 6

Now we need to Configure json files to display our Example.bam file.

Goto /var/www/Jbrowse/sample_data/json folder. Copy the existing “volvox” folder in same location & rename it to “Example”. Now go inside /var/www/Jbrowse/sample_data/json/Example/ folder. Here you can see a configuration file named as “trackList.json”. Open this file using admin rights.

Keep a note this is the file responsible to display Jbrowse file types. Let us configure this file for specific types as listed below.

  1. bam

  2. bam SNPs/Coverage

by Default Jbrowse showing Reference Sequence at the top of canvas using the following track Configuration from trackList.json
{
“storeClass” : “JBrowse/Store/Sequence/StaticChunked”,
“chunkSize” : 20000,
“urlTemplate” : “seq/{refseq_dirpath}/{refseq}-“,
“label” : “DNA”,
“type” : “SequenceTrack”,
“key” : “Reference sequence”
}

then regarding the BAM file track Configuration. Please search “.bam” in trackList.json, it will take you to BAM Format Settings as shown in below.

{
“storeClass” : “JBrowse/Store/SeqFeature/BAM”,
“urlTemplate” : “../../raw/Example/example.bam”,
“style” : {
“height” : 7
},
“metadata” : {
“Description” : “BAM-format alignments of simulated resequencing reads on the example test ctgA reference.”
},
“type” : “JBrowse/View/Track/Alignments2”,
“label” : “Example.bam”,
“key” : “BAM – Example.bam”
}

Update the urlTemplate attribute to the correct physical path. Also you can configure styles, metadata descriptions, type of graph, label to display & key Charecters.

Let us also configured bam SNPs/ Coverage track settings as below.

{
“storeClass” : “JBrowse/Store/SeqFeature/BAM”,
“urlTemplate” : “../../raw/ Example/ example.bam”,
“type” : “JBrowse/View/Track/SNPCoverage”,
“label” : Example.bam_coverage”,
“metadata” : {
“Description” : “SNP/Coverage view of Chromosomes-21.bam, simulated resequencing alignments.”
},
“key” : “BAM – Example SNPs/Coverage”
}

Do the same Update the urlTemplate attribute to the correct physical path.

In the above code I configured track settings for Example.bam file.

STEP – 7

Now we need to Configure dataset id for our file Example.bam. Search dataset_id in trackList.json & update the dataset_id to example as shown below.

dataset_id” : “example”

STEP – 8

Goto the root folder of Jbrowse (/var/www/Jbrowse/).

Open the base configuration file jbrowse_conf.json. Jbrowse is accepting this configuration settings specially for dataset identification related to the physical folder.

Search “dataset”. It will navigate you to the following block of codes.

datasets: {
volvox: { url: ‘?data=sample_data/json/volvox’, name: ‘Volvox Example’ },
modencode: { url: ‘?data=sample_data/json/modencode’, name: ‘MODEncode Example’ },
yeast: { url: ‘?data=sample_data/json/yeast’, name: ‘Yeast Example’ },
example: { url: ‘?data=sample_data/json/example’, name: ‘Example’ }
}

Watch here in last line of code, I have added example related dataset physical path identification. From here Jbrowse will detect the correct physical folder of our bam file.

Let us open Jbrowse.

As shown in above figure update the Dropdownlist to you newly configured Example.

With this you can see 2 tabs in left pan. Drag it to the graph area. You can see the real data visual for Example.bam in 2 formats “Alignments 2” & “SNPs/Coverage”.