Represent a chromosome with count information.
This is used to display information about counts along a chromosome.
The segments are expected to have different count information, which
will be displayed using a color scheme.
I envision using this class when you think that certain regions of
the chromosome will be especially abundant in the counts, and you
want to pick those out.
Methods
|
|
__init__
_color_from_count
add_count
add_label
fill_chromosome
get_segment_info
scale_segment_value
set_scale
|
|
__init__
|
__init__ (
self,
segment_names,
color_scheme=RAINBOW_COLORS,
)
Initialize a representation of chromosome counts.
Arguments:
segment_names - An ordered list of all segment names along
the chromosome. The count and other information will be added to
these.
color_scheme - A coloring scheme to use in the counts. This should
be a dictionary mapping count ranges to colors (specified in
reportlab.lib.colors).
|
|
_color_from_count
|
_color_from_count ( self, count )
Translate the given count into a color using the color scheme.
Exceptions
|
|
ValueError( "Count value %s was not found in the color scheme." % count )
|
|
|
add_count
|
add_count (
self,
segment_name,
count=1,
)
Add counts to the given segment name.
Arguments:
segment_name - The name of the segment we should add counts to.
If the name is not present, a KeyError will be raised.
count - The counts to add the current segment. This defaults to
a single count.
Exceptions
|
|
KeyError( "Segment name %s not found." % segment_name )
|
|
|
add_label
|
add_label (
self,
segment_name,
label,
)
Add a label to a specfic segment.
Raises a KeyError is the specified segment name is not found.
Exceptions
|
|
KeyError( "Segment name %s not found." % segment_name )
|
|
|
fill_chromosome
|
fill_chromosome ( self, chromosome )
Add the collected segment information to a chromosome for drawing.
Arguments:
This creates ChromosomeSegment (and TelomereSegment) objects to
fill in the chromosome. The information is derived from the
label and count information, with counts transformed to the
specified color map.
Returns the chromosome with all of the segments added.
|
|
get_segment_info
|
get_segment_info ( self )
Retrieve the color and label info about the segments.
Returns a list consiting of two tuples specifying the counts and
label name for each segment. The list is ordered according to the
original listing of names. Labels are set as None if no label
was specified.
|
|
scale_segment_value
|
scale_segment_value (
self,
segment_name,
scale_value=None,
)
Divide the counts for a segment by some kind of scale value.
This is useful if segments aren't represented by raw counts, but
are instead counts divided by some number.
Exceptions
|
|
KeyError( "Segment name %s not found." % segment_name )
|
|
|
set_scale
|
set_scale (
self,
segment_name,
scale,
)
Set the scale for a specific chromosome segment.
- By default all segments have the same scale
- this allows scaling
by the size of the segment.
Raises a KeyError is the specified segment name is not found.
Exceptions
|
|
KeyError( "Segment name %s not found." % segment_name )
|
|
|