This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Extract Graphs In Batch In Igv?

Dear all,

I am using IGV to view our sequencing results. I need to take deeper views on ~ 200 positons. How to generate the track graphs for these 200 positions in batch in IGV? Thank you very much for your suggestions!

igv

3 answers

It is possible, you will need to run IGV and a java code which will make IGV to show a location and to write a screenshot into a file through an API.

// connect to IGV
Socket socket = new Socket("127.0.0.1", 60151);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

// Clear Screen
out.println("new");
String response = in.readLine();
System.out.println("reset status: " + response);

// Load the cow genome
out.println("genome bosTau6");
response = in.readLine();
System.out.println("load genome status: " + response);

// load all the needed tracks
// paramStr = "load " + PREFIX + gtfName + COMMA + PREFIX + alignmentName...
out.println(paramStr);
response = in.readLine();
System.out.println("load GTF and alignment status: " + response);

// move a viewport to the location
// private static final String REGION_OF_INTEREST = "chr3:120,307,601-120,340,000"
out.println("goto " + REGION_OF_INTEREST);
response = in.readLine();
System.out.println("Goto status: " + response);

// here you could load another track too
out.println("expand regions.gff");

// set a folder for a snapshot
// private static final String SNAPSHOT_FOLDER = "/media/project2";
out.println("snapshotDirectory " + SNAPSHOT_FOLDER);
response = in.readLine();
System.out.println("set snapshot folder status: " + response);

// write it down
out.println("snapshot " + snapshotFName);
response = in.readLine();
System.out.println("write snapshot status: " + response);

// close the socket communications
socket.close();

while doing bunches of screenshots, I faced another issue - IGV displays tracks as expanded by default, whether I needed those squished, you can fix that easily by adding a single line to the code

diff --git a/src/org/broad/igv/ui/IGV.java b/src/org/broad/igv/ui/IGV.java
index 8a8b6f0..3334e5e 100644
--- a/src/org/broad/igv/ui/IGV.java
+++ b/src/org/broad/igv/ui/IGV.java
@@ -1594,7 +1594,9 @@ public class IGV {
                 track.setAttributeValue("NAME", track.getName());
                 track.setAttributeValue("DATA FILE", fn);
                 track.setAttributeValue("DATA TYPE", track.getTrackType().toString());
-
+                                
+                track.setDisplayMode(Track.DisplayMode.SQUISHED);
+                
                 if (track instanceof TrackGroupEventListener) {
                     addGroupEventListener((TrackGroupEventListener) track);
                 }

Thank you very much! It is really helpful!

See my blog post: "Controlling IGV through a Port: my notebook." http://plindenbaum.blogspot.fr/2011/07/controlling-igv-through-port-my.html

If you are an R/bioconductor user, the SRAdb package offers some simple functionality that uses IGV's port interface, including scrolling and screen capture, all programmatically.

Log in to answer this question.