[Biopython-dev] [Bug 2964] placing x-axis of graph track at the bottom or top of the track

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Mon Dec 7 09:48:11 UTC 2009


http://bugzilla.open-bio.org/show_bug.cgi?id=2964





------- Comment #1 from Daniel.Nicorici at gmail.com  2009-12-07 04:48 EST -------
This has feature has been added in:

http://github.com/ndaniel/biopython/tree/x-axis_GenomeDiagram/Bio/Graphics/GenomeDiagram/

Also, here a small additional bug has been fixed, i.e. the line/bar graphs are
drawn from the first element to the last element of the graph and not from the
origin to the end of the x-axis as it was original.

One can specify that the x-axis should be drawn at bottom of the track by
specifying the argument x_axis='bottom' for new_track, e.g.
gdt_features=gdd.new_track(2,x_axis='bottom').

Below one may find two examples where the x-axis is drawn in the middle (as it
is originally done by the GenomeDiagram) and bottom of the track (the new
feature added to GenomeDiagram).

====Example_1:_Using_Graph_from_GenomeDiagram_where_the_x-axis_is_at_the_middle_of_track(as_it_is_originally)=============================
import Bio.SeqFeature
import Bio.Graphics.GenomeDiagram
import random

gdd=Bio.Graphics.GenomeDiagram.Diagram('Test diagram')


gdt_features=gdd.new_track(1)
gds_features=gdt_features.new_set()

# Add three features
feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(25,125),strand=+1)
gds_features.add_feature(feature,name="Forward",label=True)

feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(150,250),strand=None)
gds_features.add_feature(feature,name="Forward",label=True)

feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(275,375),strand=-1)
gds_features.add_feature(feature,name="Forward",label=True)

# Add graph
gdt_features=gdd.new_track(2)
gds_features=gdt_features.new_set('graph')
# generate some random values for plotting
coverage=[]
coverage.append((50,float(0))) # this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.extend( [ (i, random.uniform(0,100)) for i in xrange(51,100)])
coverage.append((100,float(0))) # this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.append((250,float(0)))# this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.extend( [ (i, random.uniform(50,400)) for i in xrange(251,400)])
coverage.append((400,float(0)))# this is need in order skip the interpolation
done by GenomeDiagram for missing values
gds_features.new_graph(coverage, 'coverage', style='bar')

gdd.draw(format='linear',orientation='landscape',pagesize='A4',fragments=1,start=1,end=500)
gdd.write("Test_gaph.pdf","pdf")
============================================


====Example_2:_Using_Graph_from_GenomeDiagram_where_x-axis_is_at_the_bottom_of_track=============================
import Bio.SeqFeature
import Bio.Graphics.GenomeDiagram
import random

gdd=Bio.Graphics.GenomeDiagram.Diagram('Test diagram')


gdt_features=gdd.new_track(1)
gds_features=gdt_features.new_set()

# Add three features
feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(25,125),strand=+1)
gds_features.add_feature(feature,name="Forward",label=True)

feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(150,250),strand=None)
gds_features.add_feature(feature,name="Forward",label=True)

feature=Bio.SeqFeature.SeqFeature(Bio.SeqFeature.FeatureLocation(275,375),strand=-1)
gds_features.add_feature(feature,name="Forward",label=True)

# Add graph
gdt_features=gdd.new_track(2,x_axis='bottom')
gds_features=gdt_features.new_set('graph')
# generate some random values for plotting
coverage=[]
coverage.append((50,float(0))) # this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.extend( [ (i, random.uniform(0,100)) for i in xrange(51,100)])
coverage.append((100,float(0))) # this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.append((250,float(0)))# this is need in order skip the interpolation
done by GenomeDiagram for missing values
coverage.extend( [ (i, random.uniform(50,400)) for i in xrange(251,400)])
coverage.append((400,float(0)))# this is need in order skip the interpolation
done by GenomeDiagram for missing values
gds_features.new_graph(coverage, 'coverage', style='bar')

gdd.draw(format='linear',orientation='landscape',pagesize='A4',fragments=1,start=1,end=500)
gdd.write("Test_gaph.pdf","pdf")
============================================

Best Regards,
Daniel


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list