BigWig library for Java
3
3
Entering edit mode
10.1 years ago
bow ▴ 790

Does anybody have recommended Java or Scala library for writing BigWig / BedGraph files?

I am aware that there is a Java bigwig library that was developed by the IGV team. However, it seems to only provide BigWig / BedGraph reading functions; nothing on writing. After contacting the developers I was told that the library will not be further developed.

I am also aware that there are ways to make Java work with the C library (there are ways to make Java work with the C library). What I am looking for, however, is a pure Java (preferably Scala) library.

This feels like like something that could have been used by a number of people out there. So before I even attempt to reinvent the wheel, I feel like I should ask :).

Java BigWig BedGraph • 3.6k views
ADD COMMENT
2
Entering edit mode
6.1 years ago
holgerbrandl ▴ 30

There is a bigwig library for Kotlin https://github.com/JetBrains-Research/big which runs on the JVM. And since kotlin can be used from Java (see https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html) it might be an option for you.

ADD COMMENT
0
Entering edit mode
10.0 years ago

I suggest you avoid Wig and Bed formats; they're poorly designed. Are you sure you absolutely need them?

ADD COMMENT
0
Entering edit mode

Not wig and bed per se, but yes, I do need them. Unless there is a similar (or better) format that allows me to view tracks without uploading them to the track browser..

ADD REPLY
0
Entering edit mode
Can you suggest any replacements for wig and bed?
ADD REPLY
0
Entering edit mode

I don't know what IGV specifically requires for a track; personally, I find their coverage plot from bam+bai files to be sufficient for most uses. What exactly do you need that is not present in the bam files or IGV display of bam files? I might already be able to generate it.

ADD REPLY
0
Entering edit mode

I need to share data with other people and sometimes load them into the track browser myself. BAM files are not that suitable because wading through multiple BAM files in IGV slows it down quite a lot. This is not the case with BigWig files. It's also easier and more compact to share BigWig files given their size.

ADD REPLY
1
Entering edit mode

Other advantages of bigwig/tdf. 1) it keeps mean/median depth for different window lengths. When you zoom out to the entire chromosome, IGV can only display depth with bigwig/tdf. 2) The index of bigwig/tdf is integrated in data and the index can be retrieved partially. This is much more convenient for remote access.

ADD REPLY
0
Entering edit mode
10.0 years ago

If you want something manageable for IGV look at the TDF format which can be created with igvtools.

If you want to create bigwig from bam you could use bedtools genomeCoverageBed followed by bedGraphToBigWig (from UCSC utilities). So something on these lines:

genomeCoverageBed -bg -ibam aln.bam > tmp.bedGraph &&
  bedGraphToBigWig tmp.bedGraph chromInfo.txt out.bw &&
  rm tmp.bedGraph

This doesn't answer your question for Java libraries but from your comments I thought it could help...

ADD COMMENT
0
Entering edit mode

Hmm..the TDF format is usable only within IGV it seems?

And yes, I am aware of other ways to create BigWig files from BAM files. This is actually the way we are doing this now in-house. But we're trying to reduce external dependencies (that step, for example, requires 2 executables and 1 extra data file, not to mention unecessary disk space for the intermediate file), since this makes it more difficult to share things (also when we work on different environments). Not a new problem really. So we want to move this into our Scala-based toolkit. All the information to create the BigWig file is already present in the BAM file anyway, so I thought this should be doable via a single step without any extra data files.

ADD REPLY
1
Entering edit mode

I see... In fact I'm surprised myself that the bam -> bigwig conversion is somewhat clunky at the moment.

ADD REPLY

Login before adding your answer.

Traffic: 1204 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6