|
| 1 | +# JBrowse Genome Broser |
| 2 | + |
| 3 | +[JBrowse](https://jbrowse.org/jbrowse1.html) is a web-based genome browser for visualizing genomic features in common file formats, such as variants (VCF), genes (GFF3, BigBed) and gene expression (BigWig), and sequence alignments (BAM, CRAM, and GFF3). |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | +### 1. Place or link all files into one data folder |
| 8 | +```bash |
| 9 | +$ cd /path/to/data_directory |
| 10 | +$ ls |
| 11 | +alignments.sorted.bam |
| 12 | +alignments.sorted.bam.bai |
| 13 | +expression.bw |
| 14 | +genes.gff3 |
| 15 | +genes.gff3.tbi |
| 16 | +reference.fa. |
| 17 | +reference.fa.fai |
| 18 | +tracks.conf |
| 19 | +variants.sorted.vcf.gz |
| 20 | +variants.sorted.vcf.gz.tbi |
| 21 | +``` |
| 22 | +Commonly used genomic data sets are available from the [Shared Genome Resource](https://gencore.bio.nyu.edu/explore-the-new-shared-genome-resource/). The data is stored in a common location with the following naming convention: |
| 23 | +```bash |
| 24 | +/scratch/work/cgsb/genomes/Public/<KINGDOM>/<SPECIES>/<SOURCE>/<VERSION>/ |
| 25 | +``` |
| 26 | +:::tip |
| 27 | +There is no need to copy the reference or GFF3 to your data directory. This would just waste space. You should link the files you'd like to your data directory as shown below: |
| 28 | +```bash |
| 29 | +$ ln -s /scratch/work/cgsb/genomes/.../reference.fa reference.fa |
| 30 | +$ ln -s /scratch/work/cgsb/genomes/.../reference.fai reference.fai |
| 31 | +$ ln -s /scratch/work/cgsb/genomes/.../genes.gff3 genes.gff3 |
| 32 | +$ ln -s /scratch/work/cgsb/genomes/.../genes.gff3.tbi genes.gff3.tbi |
| 33 | +``` |
| 34 | +::: |
| 35 | + |
| 36 | +### 2. Verify data files are in a supported format |
| 37 | +For the commands listed below, `bgzip` and `tabix` are provided by the `htslib` module. `samtools` and `bcftools` are provided by the module of the same name. (use `module avail htslib samtools bcftools` to list the installed versions) |
| 38 | + |
| 39 | +#### FA |
| 40 | +If the reference and index are not available in the [Shared Genome Resource](https://gencore.bio.nyu.edu/explore-the-new-shared-genome-resource/), it should be compressed with `bgzip` and indexed with `samtools faidx`. |
| 41 | +```bash |
| 42 | +bgzip reference.fa |
| 43 | +samtools faidx reference.fa.gz |
| 44 | +``` |
| 45 | + |
| 46 | +#### GFF3 |
| 47 | +If the GFF3 is not available in the [Shared Genome Resource](https://gencore.bio.nyu.edu/explore-the-new-shared-genome-resource/), the file should first be sorted by `seqid` (column 1) and `start` (column 4), compressed with `bgzip`, and indexed with `tabix`. |
| 48 | +```bash |
| 49 | +awk -F '\t' 'NF == 9' genes.gff3 | sort -k 1,1 -k 4n,4n | bgzip > genes.sorted.gff3.gz |
| 50 | +tabix -p gff genes.sorted.gff3.gz |
| 51 | +``` |
| 52 | +The above command generates a GFF3 lacking directives/comments found in the original, but they not necessary for viewing in JBrowse. |
| 53 | + |
| 54 | +#### BED |
| 55 | +A number of BED file formats can be displayed after sorting by `chrom` (column 1) then `chromStart` (column 2), compressed with `bgzip`, and indexed with `tabix`. |
| 56 | +```bash |
| 57 | +sort -k 1,1 -k 2n,2n peaks.bed | bgzip > peaks.sorted.bed.gz |
| 58 | +tabix -p bed peaks.sorted.bed.gz |
| 59 | +``` |
| 60 | + |
| 61 | +#### BAM/CRAM |
| 62 | +BAM and CRAM files must be sorted with `samtools sort` and indexed with `samtools index`. |
| 63 | +```bash |
| 64 | +samtools sort -o alignments.sorted.bam my.bam |
| 65 | +samtools index alignments.sorted.bam |
| 66 | +``` |
| 67 | + |
| 68 | +For large BAM files, use the `--threads` option to set the number of threads for sorting, the `-m` option to specify the amount of memory per thread, and the `-l` option to set compression level for the resulting BAM file. |
| 69 | + |
| 70 | +#### VCF |
| 71 | +VCF files should be sorted with `bcftools` and indexed with `tabix`. |
| 72 | +```bash |
| 73 | +bcftools sort --output-type=z --output-file=variants.sorted.vcf.gz variants.vcf |
| 74 | +tabix -p vcf variants.sorted.vcf.gz |
| 75 | +``` |
| 76 | + |
| 77 | +For large VCF files (above ~768M), the bcftools `--max-mem` option may be used to allocate extra memory for sorting VCF records, avoiding the use of the file system for an [external merge sort](https://en.wikipedia.org/wiki/External_sorting#External_merge_sort). |
| 78 | + |
| 79 | +### 3. Create the configuration file, tracks.conf |
| 80 | + |
| 81 | +An example of a [minimal configuration](https://jbrowse.org/docs/minimal.html) |
| 82 | +```ini |
| 83 | +[GENERAL] |
| 84 | +refSeqs=reference.fa.gz.fai |
| 85 | +# reference sequence compressed with bgzip & indexed with "samtools faidx" |
| 86 | +## If using Shared Genome Resource where file is uncompressed |
| 87 | +## refSeqs=reference.fa.fai |
| 88 | + |
| 89 | +[tracks.reference] |
| 90 | +urlTemplate=reference.fa.gz |
| 91 | +# file specified as the refSeqs value without the ".fai" suffix |
| 92 | +## If using Shared Genome Resource where file is uncompressed |
| 93 | +## urlTemplate=reference.fa. |
| 94 | + |
| 95 | +[tracks.alignments] |
| 96 | +urlTemplate=alignments.sorted.bam |
| 97 | +# my.sorted.bam.bai (created by "samtools index") is assumed to exist |
| 98 | +## baiUrlTemplate=alignments.sorted.bai |
| 99 | +# custom name if corresponding .bai file isn't suffixed with .bam.bai |
| 100 | + |
| 101 | +[tracks.variants] |
| 102 | +urlTemplate=variants.sorted.vcf.gz |
| 103 | +# variants.sorted.vcf.gz.tbi assumed to exist |
| 104 | + |
| 105 | +[tracks.genes] |
| 106 | +urlTemplate=genes.sorted.gff3.gz |
| 107 | +# genes.sorted.gff3.gz.tbi assumed to exist |
| 108 | +## If using Shared Genome Resource where file is uncompressed |
| 109 | +## you must create the tbi index with tabix. |
| 110 | +## urlTemplate=genes.sorted.gff3 |
| 111 | + |
| 112 | +[tracks.expression] |
| 113 | +urlTemplate=expression.bw |
| 114 | + |
| 115 | +[tracks.peaks] |
| 116 | +urlTemplate=peaks.bed.gz |
| 117 | +# peaks.bed.gz.tbi assumed to exist |
| 118 | +``` |
| 119 | +Customizing Tracks: |
| 120 | +- [Reference Sequence Configuration](https://jbrowse.org/docs/reference_sequence.html) |
| 121 | +- [Alignment Tracks](https://jbrowse.org/docs/alignments.html) |
| 122 | +- [Wiggle/BigWig Tracks](https://jbrowse.org/docs/bigwig.html) |
| 123 | +- [VCF Tracks](https://jbrowse.org/docs/variants.html) |
| 124 | + |
| 125 | +### 4. Making feature names searchable in JBrowse (Optional) |
| 126 | + |
| 127 | +The JBrowse `generate-names.pl` script generates an index of feature names for searching and autocompletion when typed into the JBrowse search box, or the `View > search for features` menu option. |
| 128 | +```bash |
| 129 | +module load jbrowse/web/1.16.0 |
| 130 | +generate-names.pl --compress --out . |
| 131 | +``` |
| 132 | + |
| 133 | +## Configuration |
| 134 | + |
| 135 | +Enter the full path to the directory you created above in the `Data Folder Path` input, add any optional Slurm options and press the `Launch` button. |
| 136 | + |
| 137 | + |
| 138 | +## JBrowse running in OOD |
| 139 | + |
| 140 | +After a short pause while your job is in the Greene queue and then starts up, you'll see the JBrowse application. |
0 commit comments