glyphs

Contains the Glyph class used to define the different type of glyphs that can be used to represent features, as well the basic plotting functions for GenomeBrowser

source

Glyph

 Glyph (glyph_type:str='arrow', colors:tuple=('purple', 'orange'),
        alpha:float=0.8, show_name:bool=True, height:float=1)

A class used to define the different types of glyphs shown for different feature types.

Type Default Details
glyph_type str arrow type of the Glyph (arrow or box)
colors tuple (‘purple’, ‘orange’) can be a single color or a tuple of two colors, one for each strand
alpha float 0.8 transparency
show_name bool True
height float 1 height of the feature relative to other features (between 0 and 1)

source

get_default_glyphs

 get_default_glyphs ()

Returns a dictionnary with:

  • keys: feature types (str)
  • values: a Glyph object
default_glyphs['CDS']
Glyph object with attributes:
    glyph_type: arrow
    colors: ('purple', 'orange')
    height: 1
    alpha: 0.8
    show_name: True

source

get_patch_coordinates

 get_patch_coordinates (feature, glyphs_dict, feature_height=0.15)
data_path = get_example_data_dir()
gff_path = os.path.join(data_path, "MG1655_U00096.gff3")
features=parse_gff(gff_path, 
                   feature_types=default_types, 
                   seq_id="U00096.3")

features.head().apply(get_patch_coordinates,glyphs_dict=default_glyphs, axis=1)
0    (((190, 190, 190, 255, 190), (0.05, 0.2, 0.2, ...
1    (((337, 337, 2699, 2799, 2699), (0.05, 0.2, 0....
2    (((2801, 2801, 3633, 3733, 3633), (0.05, 0.2, ...
3    (((3734, 3734, 4920, 5020, 4920), (0.05, 0.2, ...
4    (((5234, 5234, 5430, 5530, 5430), (0.05, 0.2, ...
dtype: object

source

get_feature_name

 get_feature_name (feature, glyphs_dict, name='gene',
                   attributes:list=['gene', 'locus_tag', 'product'])

Gets the name of the feature to be displayed. If the Glyph for the feature type has the attribute show_name=False then an empty string is returned. If name is not an attribute of the feature, then the first attribute in the attributes list is used.

features.head().apply(get_feature_name,name="gene",glyphs_dict=default_glyphs, axis=1)
0    thrL
1    thrA
2    thrB
3    thrC
4    yaaX
dtype: object

source

get_feature_patches

 get_feature_patches (features:pandas.core.frame.DataFrame, left:int,
                      right:int, glyphs_dict:dict,
                      attributes:list=['gene', 'locus_tag', 'product'],
                      name:str='gene', feature_height:float=0.15)
Type Default Details
features DataFrame DataFrame of the features
left int left limit
right int right limit
glyphs_dict dict a dictionnary of glyphs to use for each feature type
attributes list [‘gene’, ‘locus_tag’, ‘product’] list of attributes to display when hovering
name str gene attribute to be displayed as the feature name
feature_height float 0.15 fraction of the annotation track height occupied by the features
Returns DataFrame
get_feature_patches(features,8000,12000, glyphs_dict=default_glyphs, name="gene")
names xs ys color alpha pos gene locus_tag product
0 talB (8238, 8238, 9091, 9191, 9091) (0.05, 0.2, 0.2, 0.125, 0.05) purple 0.8 8714.5 talB b0008 transaldolase B
1 mog (9306, 9306, 9793, 9893, 9793) (0.05, 0.2, 0.2, 0.125, 0.05) purple 0.8 9599.5 mog b0009 molybdopterin adenylyltransferase
2 satP (10494, 10494, 10028, 9928, 10028) (0.05, 0.2, 0.2, 0.125, 0.05) orange 0.8 10211.0 satP b0010 acetate/succinate:H(+) symporter
3 yaaW (11356, 11356, 10743, 10643, 10743) (0.05, 0.2, 0.2, 0.125, 0.05) orange 0.8 10999.5 yaaW b0011 putative enzyme-specific chaperone YaaW
4 mbiA (10830, 10830, 11215, 11315, 11215) (0.05, 0.2, 0.2, 0.125, 0.05) purple 0.8 11072.5 mbiA b0012 uncharacterized protein MbiA
5 yaaI (11786, 11786, 11482, 11382, 11482) (0.05, 0.2, 0.2, 0.125, 0.05) orange 0.8 11584.0 yaaI b0013 DUF2541 domain-containing protein YaaI