API Reference
Track
Functions:
|
Compose BEDPE, Pairs track automatically based on type of file extension.(.bedpe, .pairs) |
|
Compose DotHic or Cool track automatically based on tpye of file extension (.cool, .mcool, .hic) |
|
Compose BigWig, BedGraph, SNP, BAMCov track automatically based on type of file extension.(.bw, .bigwig, .snp, .vcf, .bedgraph, .bam, .sam) |
Classes:
|
Arcs(link) track. |
|
BAM alignment track for plotting reads. |
|
Alignment reads coverage track. |
|
Bed Track for plotting 1d intervals data from .bed file. |
|
Arcs track from .bedpe file. |
|
BED Base track. |
|
BedGraph track. |
|
BigWig track |
|
Track for show chromosome name. |
|
Cool track from .cool, .mcool file. |
|
Directionnality index track. |
|
HicMat track from .hic file. |
|
GTF gene annotation track. |
|
Horizontal line track. |
|
Track for express the comparison between two HiC Track. |
|
Hi-C Peaks(Loops) from .bedpe file. |
|
HicMatBase class for all track plotting matrix-like data. |
|
HistBase track class |
|
The chromosome ideograme track. |
|
Insulation score track. |
|
Arcs track from .pairs file. |
|
Track for show SNPs Manhattan plot. |
|
Differential chromatin interaction. |
|
The spacer track Does not have any real content, just used to split two tracks. |
|
Tad tack from bed file |
|
Track base class. |
|
Track for view virtual 4C related to a certain genome position, and a HiC Track (include Cool and DotHiC). |
|
The x axis track. |
- coolbox.core.track.Arcs(file_, *args, **kwargs) ArcsBase
Compose BEDPE, Pairs track automatically based on type of file extension.(.bedpe, .pairs)
- class coolbox.core.track.ArcsBase(*args, **kwargs)
Arcs(link) track.
- Parameters:
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr[, gr2])plot(ax, gr, **kwargs)Plot arc connecting two positions on a linear scale representing interactions between bins.
- fetch_data(gr: GenomeRange, gr2: GenomeRange | None = None, **kwargs) DataFrame
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- intervalspandas.core.frame.DataFrame
Can be two types: 1: with columns: [‘pos1’, ‘pos2’, ‘score’] ‘score’ is optional 2: with columns: [‘start1’, ‘end1’, ‘start2’, ‘end2’, ‘score’] ‘score’ is optional
- plot(ax, gr: GenomeRange, **kwargs)
Plot arc connecting two positions on a linear scale representing interactions between bins.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.BAM(*args, **kwargs)
BAM alignment track for plotting reads.
- Parameters:
- filestr
Path to .bam .sam file.
- length_ratio_threshfloat
Length ratio threshold of show alignments. (Default 0.01)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs) DataFrame
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- intervalspandas.core.frame.DataFrame
Sam interval table. The DataFrame table should has columns like:
- columns = [“qname”, “flag”, “rname”, “pos”, “mapq”, “cigar”,
“rnext”, “pnext”, “tlen”, “seq”, “qual”, “options”]
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.BAMCov(*args, **kwargs)
Alignment reads coverage track.
- Parameters:
- file: str
File path of bam file.
- num_bins: int, optional
Number of bins to plot hist fig.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
- fetch_data(gr: GenomeRange, **kwargs) Tuple[ndarray, ndarray] | DataFrame | ndarray
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.BED(*args, **kwargs)
Bed Track for plotting 1d intervals data from .bed file. The input bed file can be bed3/bed6/bed9/bed12
- Parameters:
- gene_style: {‘flybase’, ‘normal’}
- display{‘stacked’, ‘interlaced’, ‘collapsed’}, optional
Display mode. (Default: ‘stacked’)
- fontsizeint, optional
Font size. (Default: BED.DEFAULT_FONTSIZE)
- labels{True, False, ‘auto’}, optional
Draw bed name or not. ‘auto’ for automate decision according to density. (Default: ‘auto’)
- interval_heightint, optional
The height of the interval. (Default: 100)
- num_rowsint, optional
Set the max interval rows. (Default: unlimited interval rows)
- row_heightfloat
Height of a row. default 0.5
- file: str
The file path of .bed file.
- colorstr, optional
Track color, ‘rgb’ for auto specify color according to bed record. (Default: ‘rgb’)
- border_colorstr, optional
Border_color of gene. (Default: ‘black’)
- max_valuefloat, optional
Max score. (Default: inf)
- min_valuefloat, optional
Min score. (Default: -inf)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.BEDPE(*args, **kwargs)
Arcs track from .bedpe file.
- Parameters:
- file: str
Path of .bedpe file
- posstr, optional
Method for choosing arch anchor for bedpe data: ‘start’, ‘end’, ‘mid’, default ‘mid’
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_plot_data(gr, **kwargs)Fetch the plot data for the given GenomeRange.
- fetch_plot_data(gr: GenomeRange, **kwargs) DataFrame
Fetch the plot data for the given GenomeRange. The returned data would be used in plot function, the default implementation directly return fetch_data.
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.BedBase(*args, **kwargs)
BED Base track.
- Parameters:
- file: str
The file path of .bed file.
- colorstr, optional
Track color, ‘rgb’ for auto specify color according to bed record. (Default: ‘rgb’)
- border_colorstr, optional
Border_color of gene. (Default: ‘black’)
- max_valuefloat, optional
Max score. (Default: inf)
- min_valuefloat, optional
Min score. (Default: -inf)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)fetch_intervals(gr)Fetch intervals within input chromosome range.
set_colormap(df)As min_score and max_score change every plot, we compute them for every plot
- fetch_data(gr: GenomeRange, **kwargs) DataFrame
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- intervalspandas.core.frame.DataFrame
BED interval table. The table should be in format like:
bed_fields = ['chromosome', 'start', 'end', 'name', 'score', 'strand', 'thick_start', 'thick_end', 'rgb', 'block_count', 'block_sizes', 'block_starts']
The table can be in bed6/bed9/bed12 format and the trailing columns can be omited.
- fetch_intervals(gr: GenomeRange) DataFrame
Fetch intervals within input chromosome range.
- set_colormap(df)
As min_score and max_score change every plot, we compute them for every plot
- class coolbox.core.track.BedGraph(*args, **kwargs)
BedGraph track.
- Parameters:
- filestr
File path of bedgraph file.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
fetch_plot_data(gr, **kwargs)- fetch_data(gr: GenomeRange, **kwargs) DataFrame
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- fetch_plot_data(gr: GenomeRange, **kwargs) DataFrame
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- hist_data: Union[Tuple[np.ndarray, np.ndarray], pd.DataFrame, np.ndarray]
data used for plotting.
- class coolbox.core.track.BigWig(*args, **kwargs)
BigWig track
- Parameters:
- filestr
File path of bigwig file.
- num_binsint, optional
Number of bins to plot the hist in current range, default 700.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)fetch_plot_data(gr, **kwargs)- fetch_data(gr: GenomeRange, **kwargs)
- Parameters:
- grGenomeRange
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- intervalspandas.core.frame.DataFrame
BigWig interval table.
- fetch_plot_data(gr: GenomeRange, **kwargs)
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- hist_data: Union[Tuple[np.ndarray, np.ndarray], pd.DataFrame, np.ndarray]
data used for plotting.
- class coolbox.core.track.ChromName(*args, **kwargs)
Track for show chromosome name.
- Parameters:
- fontsizefloat
Font name to show.
- offsetfloat
Offset ratio to the start position.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.Cool(*args, **kwargs)
Cool track from .cool, .mcool file.
- Parameters:
- file: str
The file path of .cool, .mcool file
- balance: bool
If use the balanced contact matrix.
- style{‘triangular’, ‘window’, ‘matrix’}, optional
Matrix style, default ‘window’.
- cmapstr, optional
Color map of hic matrix, default “JuiceBoxLike”.
- color_bar{‘vertical’, ‘horizontal’, ‘no’}, optional
Color bar style. default ‘vertical’.
- depth_ratiofloat, optional
Depth ratio of triangular matrix, use ‘full’ for full depth. default ‘full’.
- max_value{float, ‘auto’}, optional
Max value of hic matrix, use ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of hic matrix, use ‘auto’ for specify min value automatically, default ‘auto’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- resolution{int, ‘auto’}, optional
Matrix resolution, default ‘auto’.
- transform{str, bool}, optional
Transform for matrix, like ‘log2’, ‘log10’, default False.
- normalize{‘zscore’, ‘expect’, ‘total’, False}
Normalization method, default False.
- norm: {‘log’, ‘no’}
Method used when normalizing. default ‘no’
- gaussian_sigma{float, False}, optional
Do gaussian filter(with sigma, for example 1.0) on matrix if specified. default False.
- process_func{callable, str, False}, optional
Process matrix with a user-defined function(receive a matrix, return a processed matrix). default False.
- aspect_ratio{‘equal’, ‘auto’}, optional
When set to ‘equal’, it ensures that matrix pixels are actually squares. When set to ‘auto’, it allows matrix pixels to be stretched to completely fill the subplot. Ignored when height parameter is provided. default ‘equal’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr[, gr2])Fetch the raw matrix should be plotted.
fetch_pixels(gr[, gr2])Fetch the pixels table of upper triangle of the original contact matrix(not processed).
- fetch_data(gr: GenomeRange, gr2=None, **kwargs) ndarray
Fetch the raw matrix should be plotted. Normally it’s a matrix with raw contacts
- Parameters:
- gr2GenomeRange, optional, keyword argument
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Hi-C raw contact matrix.
- fetch_pixels(gr: GenomeRange, gr2=None, **kwargs)
Fetch the pixels table of upper triangle of the original contact matrix(not processed).
- Parameters:
- gr2GenomeRange, optional.
- balancebool, optional
balance matrix or not, default self.is_balance.
- resolution{‘auto’, int}
resolution of the data. for example 5000. ‘auto’ for calculate resolution automatically. default ‘auto’
- joinbool
whether to expand the bin ID columns into (chrom, start, end). default True
- Returns:
- pixelspandas.core.frame.DataFrame
Hi-C pixels table. The pixel table contains the non-zero upper triangle entries of the contact map.
- class coolbox.core.track.DiScore(*args, **kwargs)
Directionnality index track.
- Parameters:
- hicmat: {str, HicMatBase}
The input hicmat file or HicMatBase object used to calculate di score.
- window_size: int, optional
Width of the diamond region along the matrix used to calculate di. default: 40
- method: {‘standard’, ‘adaptive’}, optional
Method used for calculating di. default: ‘adaptive’
- args_hicdict, optional
Key words arguments used to create Cool/DotHic tack when the input hicmat is a file path
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
- fetch_data(gr: GenomeRange, **kwargs) ndarray
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.DotHiC(*args, **kwargs)
HicMat track from .hic file.
- Parameters:
- file: str
The file path of .hic file.
- balance{bool, ‘KR’, ‘VC’, ‘VC_SQRT’}, optional
Matrix balance method, default True(‘KR’ balance)
- style{‘triangular’, ‘window’, ‘matrix’}, optional
Matrix style, default ‘window’.
- cmapstr, optional
Color map of hic matrix, default “JuiceBoxLike”.
- color_bar{‘vertical’, ‘horizontal’, ‘no’}, optional
Color bar style. default ‘vertical’.
- depth_ratiofloat, optional
Depth ratio of triangular matrix, use ‘full’ for full depth. default ‘full’.
- max_value{float, ‘auto’}, optional
Max value of hic matrix, use ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of hic matrix, use ‘auto’ for specify min value automatically, default ‘auto’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- resolution{int, ‘auto’}, optional
Matrix resolution, default ‘auto’.
- transform{str, bool}, optional
Transform for matrix, like ‘log2’, ‘log10’, default False.
- normalize{‘zscore’, ‘expect’, ‘total’, False}
Normalization method, default False.
- norm: {‘log’, ‘no’}
Method used when normalizing. default ‘no’
- gaussian_sigma{float, False}, optional
Do gaussian filter(with sigma, for example 1.0) on matrix if specified. default False.
- process_func{callable, str, False}, optional
Process matrix with a user-defined function(receive a matrix, return a processed matrix). default False.
- aspect_ratio{‘equal’, ‘auto’}, optional
When set to ‘equal’, it ensures that matrix pixels are actually squares. When set to ‘auto’, it allows matrix pixels to be stretched to completely fill the subplot. Ignored when height parameter is provided. default ‘equal’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr[, gr2])Fetch the raw matrix should be plotted.
fetch_pixels(gr[, gr2, balance])- fetch_data(gr, gr2=None, **kwargs) ndarray
Fetch the raw matrix should be plotted. Normally it’s a matrix with raw contacts
- Parameters:
- gr2GenomeRange, optional, keyword argument
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Hi-C raw contact matrix.
- fetch_pixels(gr, gr2=None, balance=None, **kwargs)
- Parameters:
- gr{str, GenomeRange}
Intervals within input chromosome range.
- gr2{str, GenomeRange}
Intervals within input chromsome range2.
- balance{bool, ‘KR’, ‘VC’, ‘VC_SQRT’}, optional
matrix balance method, default self.balance.
- resolution{‘auto’, int}
resolution of the data. for example 5000. ‘auto’ for calculate resolution automatically. default ‘auto’
- Returns:
- pixelspandas.core.frame.DataFrame
Hi-C pixels table. The pixel table contains the non-zero upper triangle entries of the contact map.
- class coolbox.core.track.GTF(*args, **kwargs)
GTF gene annotation track.
- Parameters:
- filestr
Path to .gtf(or .gtf.bgz) file.
- row_filterstr, optional
Row filter expression, only keep the rows for draw. (Default ‘type == “gene”’)
- length_ratio_threshfloat
Length ratio threshold of features, (Default 0.01)
- color{str, ‘random’}, optional
When the color is random, color for each gene will be randomly selected.
- name_attr{‘auto’, ‘gene_name’, ‘gene_id’, str}, optional
Use which attribute to show feature’s name. Default use ‘auto’(try ‘gene_name’ -> ‘gene_id’ -> ‘position_string’)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)fetch_intervals(gr)plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- df: pandas.DataFrame
should be with the format like:
- columns = [‘seqname’, ‘source’, ‘type’, ‘start’, ‘end’,
‘score’, ‘strand’, ‘frame’, ‘attributes’, ‘feature_name’]
- fetch_intervals(gr: GenomeRange)
- Parameters:
- gr{str, GenomeRange}
- Returns:
- intervalspandas.core.frame.DataFrame
Annotation interval table.
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.HLine(*args, **kwargs)
Horizontal line track. Used for add a horizontal line between two tracks.
- Parameters:
- line_widthfloat, optional
(Default: HLine.DEFAULT_LINE_WIDTH)
- line_stylestr, optional
(Default: HLine.DEFAULT_LINE_STYLE)
- colorstr, optional
(Default: HLine.DEFAULT_COLOR)
- alphafloat, optional
(Default: HLine.DEFAULT_ALPHA)
- heightfloat, optional
The height of Spacer track. (Default: HLine.DEFAULT_HEIGHT)
- namestr, optional
Track’s name.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- titlestr, optional
Title of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.HiCDiff(*args, **kwargs)
Track for express the comparison between two HiC Track.
- Parameters:
- hic1coolbox.api.track.Cool
First HiC Track or hic file path(.cool, .mcool, .hic).
- hic2coolbox.api.track.Cool
Second HiC Track or hic file path(.cool, .mcool, .hic).
- args_hic: dict
Key word arguments send to create Cool/DoctHic instance if the input hic1/hic2 is file.
- diff_methodstr
Difference method (‘diff’, ‘log2fc’), default ‘diff’
- style{‘triangular’, ‘window’, ‘matrix’}, optional
Matrix style, default ‘window’.
- cmapstr, optional
Color map of hic matrix, default “JuiceBoxLike”.
- color_bar{‘vertical’, ‘horizontal’, ‘no’}, optional
Color bar style. default ‘vertical’.
- depth_ratiofloat, optional
Depth ratio of triangular matrix, use ‘full’ for full depth. default ‘full’.
- max_value{float, ‘auto’}, optional
Max value of hic matrix, use ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of hic matrix, use ‘auto’ for specify min value automatically, default ‘auto’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- resolution{int, ‘auto’}, optional
Matrix resolution, default ‘auto’.
- transform{str, bool}, optional
Transform for matrix, like ‘log2’, ‘log10’, default False.
- normalize{‘zscore’, ‘expect’, ‘total’, False}
Normalization method, default False.
- norm: {‘log’, ‘no’}
Method used when normalizing. default ‘no’
- gaussian_sigma{float, False}, optional
Do gaussian filter(with sigma, for example 1.0) on matrix if specified. default False.
- process_func{callable, str, False}, optional
Process matrix with a user-defined function(receive a matrix, return a processed matrix). default False.
- aspect_ratio{‘equal’, ‘auto’}, optional
When set to ‘equal’, it ensures that matrix pixels are actually squares. When set to ‘auto’, it allows matrix pixels to be stretched to completely fill the subplot. Ignored when height parameter is provided. default ‘equal’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw matrix should be plotted.
- fetch_data(gr: GenomeRange, **kwargs) ndarray
Fetch the raw matrix should be plotted. Normally it’s a matrix with raw contacts
- Parameters:
- gr2GenomeRange, optional, keyword argument
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Hi-C raw contact matrix.
- coolbox.core.track.HiCMat(file: str | HicMatBase, *args, **kwargs) HicMatBase
Compose DotHic or Cool track automatically based on tpye of file extension (.cool, .mcool, .hic)
- class coolbox.core.track.HiCPeaks(*args, **kwargs)
Hi-C Peaks(Loops) from .bedpe file. Used to show the peaks on the Hi-C interaction map.
- Parameters:
- file: str
Path of .bedpe file
- posstr, optional
Method for choosing arch anchor for bedpe data: ‘start’, ‘end’, ‘mid’, default ‘mid’
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.track.HicMatBase(*args, **kwargs)
HicMatBase class for all track plotting matrix-like data.
- Parameters:
- style{‘triangular’, ‘window’, ‘matrix’}, optional
Matrix style, default ‘window’.
- cmapstr, optional
Color map of hic matrix, default “JuiceBoxLike”.
- color_bar{‘vertical’, ‘horizontal’, ‘no’}, optional
Color bar style. default ‘vertical’.
- depth_ratiofloat, optional
Depth ratio of triangular matrix, use ‘full’ for full depth. default ‘full’.
- max_value{float, ‘auto’}, optional
Max value of hic matrix, use ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of hic matrix, use ‘auto’ for specify min value automatically, default ‘auto’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- resolution{int, ‘auto’}, optional
Matrix resolution, default ‘auto’.
- transform{str, bool}, optional
Transform for matrix, like ‘log2’, ‘log10’, default False.
- normalize{‘zscore’, ‘expect’, ‘total’, False}
Normalization method, default False.
- norm: {‘log’, ‘no’}
Method used when normalizing. default ‘no’
- gaussian_sigma{float, False}, optional
Do gaussian filter(with sigma, for example 1.0) on matrix if specified. default False.
- process_func{callable, str, False}, optional
Process matrix with a user-defined function(receive a matrix, return a processed matrix). default False.
- aspect_ratio{‘equal’, ‘auto’}, optional
When set to ‘equal’, it ensures that matrix pixels are actually squares. When set to ‘auto’, it allows matrix pixels to be stretched to completely fill the subplot. Ignored when height parameter is provided. default ‘equal’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr[, gr2])Fetch the raw matrix should be plotted.
fetch_plot_data(gr[, gr2])Fetch 2d contact matrix, the matrix may be processed in case 'transform', 'normalize', 'gaussian_sigma', 'process_func' exits in properties.
plot(ax, gr[, gr2])Plot matrix
- fetch_data(gr: GenomeRange, gr2=None, **kwargs) ndarray
Fetch the raw matrix should be plotted. Normally it’s a matrix with raw contacts
- Parameters:
- gr2GenomeRange, optional, keyword argument
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Hi-C raw contact matrix.
- fetch_plot_data(gr: GenomeRange, gr2=None, **kwargs) ndarray
Fetch 2d contact matrix, the matrix may be processed in case ‘transform’, ‘normalize’, ‘gaussian_sigma’, ‘process_func’ exits in properties.
- Parameters:
- gr2GenomeRange, optional
- gr_updated: bool, optional
If the input GenomeRange has been updated. default False Default False means that the input gr will be expanded in window mode
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Processed hic matrix used for plotting.
- plot(ax, gr: GenomeRange, gr2=None, **kwargs)
Plot matrix
- Parameters:
- ax
- gr2GenomeRange, optional
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- coolbox.core.track.Hist(file, *args, **kwargs) HistBase
Compose BigWig, BedGraph, SNP, BAMCov track automatically based on type of file extension.(.bw, .bigwig, .snp, .vcf, .bedgraph, .bam, .sam)
- class coolbox.core.track.HistBase(*args, **kwargs)
HistBase track class
- Parameters:
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
fetch_plot_data(gr, **kwargs)plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs) Tuple[ndarray, ndarray] | DataFrame | ndarray
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- fetch_plot_data(gr: GenomeRange, **kwargs) Tuple[ndarray, ndarray] | DataFrame | ndarray
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- hist_data: Union[Tuple[np.ndarray, np.ndarray], pd.DataFrame, np.ndarray]
data used for plotting.
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.Ideogram(*args, **kwargs)
The chromosome ideograme track.
- Parameters:
- file_str
Path to chromosome ideogram txt file, ideogram file is download from the UCSC Table Browser CytoBandIdeo table (in “all table” group). see: http://genome.ucsc.edu/cgi-bin/hgTables?hgta_group=allTables&hgta_table=cytoBandIdeo
- color_schemedict, optional
Color scheme of ideogram, default: Ideogram.DEFAULT_COLOR_SCHEME
- show_band_namebool, optional
Show band name or not. default True.
- font_sizeint, optional
Band name font size.
- border_colorstr, optional
Border color. default: ‘#000000’
- border_widthfloat, optional
Border width. default: 1.2
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.InsuScore(*args, **kwargs)
Insulation score track.
- Parameters:
- hicmat: {str, HicMatBase}
The input hicmat file or HicMatBase object used to calculate di score.
- window_size: {int, str}, optional
Width of the diamond region along the matrix used to calculate di. default: 20 window_size can also be a str with format like “20-40” representing a range of window_sizes.
- normalize: bool, optional
Weather to log-nomalize the insulation score array. default: true
- method: {‘standard’, ‘adaptive’}, optional
Method used for calculating di. default: ‘adaptive’
- args_hicdict, optional
Key words arguments used to create Cool/DotHic tack when the input hicmat is a file path
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
- fetch_data(gr: GenomeRange, **kwargs) ndarray
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.Pairs(*args, **kwargs)
Arcs track from .pairs file.
- Parameters:
- file: str
Path of .pairs file
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.track.SNP(*args, **kwargs)
Track for show SNPs Manhattan plot.
Input file is a tab-split file contains SNP’s chrom, position, pvalue information. You should specify it’s column indexes by col_chrom, col_pos, col_pval arguments.
- Parameters:
- filestr
Path to input .snp/.vcf file.
- col_chromint
Column index of seqname(chromosome).
- col_posint
Column index of snp position.
- col_pvalint
Column index of snp p-value.
- pval_transform{‘-log2’, ‘-log10’}
Transform the p value. Default ‘-log10’.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
fetch_plot_data(gr, **kwargs)- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- fetch_plot_data(gr: GenomeRange, **kwargs)
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- hist_data: Union[Tuple[np.ndarray, np.ndarray], pd.DataFrame, np.ndarray]
data used for plotting.
- class coolbox.core.track.Selfish(*args, **kwargs)
Differential chromatin interaction.
- Parameters:
- hic1coolbox.api.track.Cool
First HiC Track or hic file path(.cool, .mcool, .hic).
- hic2coolbox.api.track.Cool
Second HiC Track or hic file path(.cool, .mcool, .hic).
- hic_argsdict, optional
Argument to create Hi-C instance, only in use when first or second argument is a path.
- sigma0float, optional
Initial sigma, parameter of SELFISH method. Default: 1.6
- sint, optional
Iteration count parameter of SELFISH method. Default: 10
- style{‘triangular’, ‘window’, ‘matrix’}, optional
Matrix style, default ‘window’.
- cmapstr, optional
Color map of hic matrix, default “JuiceBoxLike”.
- color_bar{‘vertical’, ‘horizontal’, ‘no’}, optional
Color bar style. default ‘vertical’.
- depth_ratiofloat, optional
Depth ratio of triangular matrix, use ‘full’ for full depth. default ‘full’.
- max_value{float, ‘auto’}, optional
Max value of hic matrix, use ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of hic matrix, use ‘auto’ for specify min value automatically, default ‘auto’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- resolution{int, ‘auto’}, optional
Matrix resolution, default ‘auto’.
- transform{str, bool}, optional
Transform for matrix, like ‘log2’, ‘log10’, default False.
- normalize{‘zscore’, ‘expect’, ‘total’, False}
Normalization method, default False.
- norm: {‘log’, ‘no’}
Method used when normalizing. default ‘no’
- gaussian_sigma{float, False}, optional
Do gaussian filter(with sigma, for example 1.0) on matrix if specified. default False.
- process_func{callable, str, False}, optional
Process matrix with a user-defined function(receive a matrix, return a processed matrix). default False.
- aspect_ratio{‘equal’, ‘auto’}, optional
When set to ‘equal’, it ensures that matrix pixels are actually squares. When set to ‘auto’, it allows matrix pixels to be stretched to completely fill the subplot. Ignored when height parameter is provided. default ‘equal’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
References
Abbas Roayaei Ardakany, Ferhat Ay, Stefano Lonardi, Selfish: discovery of differential chromatin interactions via a self-similarity measure, Bioinformatics, Volume 35, Issue 14, July 2019, Pages i145–i153, https://doi.org/10.1093/bioinformatics/btz362
Methods:
fetch_data(gr, **kwargs)Fetch the raw matrix should be plotted.
- fetch_data(gr: GenomeRange, **kwargs) ndarray
Fetch the raw matrix should be plotted. Normally it’s a matrix with raw contacts
- Parameters:
- gr2GenomeRange, optional, keyword argument
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- matrixnp.array
Hi-C raw contact matrix.
- class coolbox.core.track.Spacer(*args, **kwargs)
The spacer track Does not have any real content, just used to split two tracks.
- Parameters:
- heightfloat, optional
The height of Spacer track. (Default: Spacer.DEFAULT_HEIGHT)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.TAD(*args, **kwargs)
Tad tack from bed file
- Parameters:
- border_style: str, optional
Border style of tad. (Default: ‘solid’)
- border_width: int, optional
Border width of tad. (Default: ‘2.0’)
- show_scorebool
Show bed score or not. default False.
- score_font_size{‘auto’, int}
Score text font size. default ‘auto’
- score_font_colorstr
Score text color. default ‘#000000’
- score_height_ratiofloat
(text tag height) / (TAD height). used for adjust the position of Score text. default 0.5
- border_onlybool
Only show border, default False
- depth_ratio{float, ‘auto’, ‘full’}
Depth ratio of triangular, use ‘full’ for full depth, use ‘auto’ for calculate depth by current genome_range. default ‘auto’.
- orientation{‘normal’, ‘inverted’}
Invert y-axis or not, default ‘normal’
- file: str
The file path of .bed file.
- colorstr, optional
Track color, ‘rgb’ for auto specify color according to bed record. (Default: ‘rgb’)
- border_colorstr, optional
Border_color of gene. (Default: ‘black’)
- max_valuefloat, optional
Max score. (Default: inf)
- min_valuefloat, optional
Min score. (Default: -inf)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.Track(*args, **kwargs)
Track base class.
- Parameters:
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
append_coverage(coverage[, pos])Append coverage to this track.
check_chrom_name(gr, valid)Check if the chromosome name is valid.
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
fetch_plot_data(gr, **kwargs)Fetch the plot data for the given GenomeRange.
pile_coverages(coverages[, pos])Pile a stack of coverages with self's coverages
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
plot_coverages(ax, gr, gr2)Plot all coverages on given axes.
- append_coverage(coverage, pos='top')
Append coverage to this track.
- Parameters:
- coveragecoolbox.api.coverage.Coverage
Coverage object to be piled.
- pos{‘top’, ‘bottom’}, optional
Add coverages to top or bottom. (Default: ‘top’)
- check_chrom_name(gr: GenomeRange, valid: Iterable[str]) GenomeRange
Check if the chromosome name is valid. If not, change the chromosome name to the valid name.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- fetch_plot_data(gr: GenomeRange, **kwargs)
Fetch the plot data for the given GenomeRange. The returned data would be used in plot function, the default implementation directly return fetch_data.
- Parameters:
- gr: GenomeRange
GenomeRange is an object with properties of [chrom, start, end].
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- pile_coverages(coverages, pos='top')
Pile a stack of coverages with self’s coverages
- Parameters:
- coverageslist of coolbox.api.coverage.Coverage or coolbox.api.coverage.CoverageStack
Coverage objects to be piled.
- pos{‘top’, ‘bottom’}, optional
Add coverages to top or bottom. (Default: ‘top’)
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot_coverages(ax, gr: GenomeRange, gr2: GenomeRange)
Plot all coverages on given axes.
- Parameters:
- grGenomeRange
First genome range.
- gr2GenomeRange
Second genome range.
- class coolbox.core.track.Virtual4C(*args, **kwargs)
Track for view virtual 4C related to a certain genome position, and a HiC Track (include Cool and DotHiC).
- Parameters:
- hicmat{str, Cool, DotHiC}
Related hic track or Hi-C file path.
- genome_positionstr
related genome position, like: ‘chr1:2000000-2000000’
- bin_widthint, optional
How many bin used for calculate the mean value. default 3
- args_hicdict, optional
Argument for create hic track, needed only if first argument is a path.
- hicmat: {str, HicMatBase}
The input hicmat file or HicMatBase object used to calculate di score.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
- fetch_data(gr: GenomeRange, **kwargs) ndarray
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- class coolbox.core.track.XAxis(*args, **kwargs)
The x axis track.
- Parameters:
- heightfloat, optional
Height of Spacer track. (Default: XAxis.DEFAULT_HEIGHT)
- fontsizeint, optional
Font size of XAxis. (Default: XAxis.DEFAULT_FONTSIZE)
- where{‘top’, ‘bottom’}, optional
The position of tick labels relative to the axis. (Default: ‘bottom’)
- name (str, optional):
Track’s name.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
Methods:
fetch_data(gr, **kwargs)Fetch the raw data for the given GenomeRange.
plot(ax, gr, **kwargs)Plot figure based on data returned by fetch_plot_data.
- fetch_data(gr: GenomeRange, **kwargs)
Fetch the raw data for the given GenomeRange.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
- plot(ax, gr: GenomeRange, **kwargs)
Plot figure based on data returned by fetch_plot_data.
- Parameters:
- gr: GenomeRange
- kwargs: dict
Other optional parameters including gr2, resolution for some tracks.
- Returns:
Coverage
Classes:
|
Compose BEDPE, Pairs track automatically based on type of file extension.(.bedpe, .pairs) |
|
Arcs track from .bedpe file. |
|
BedGraph track. |
|
BigWig track |
|
Horizontal line coverage, for show threshold. |
|
Hi-C Peaks(Loops) from .bedpe file. |
|
High light region. |
|
High light regions coverage, read the regions from the file. |
|
Compose BigWig, BedGraph, SNP, BAMCov track automatically based on type of file extension.(.bw, .bigwig, .snp, .vcf, .bedgraph, .bam, .sam) |
|
Arcs track from .pairs file. |
|
Tad tack from bed file |
|
Vertical lines. |
|
Vertical lines from the file. |
- class coolbox.core.coverage.ArcsCoverage(*args, **kwargs)
Compose BEDPE, Pairs track automatically based on type of file extension.(.bedpe, .pairs)
- class coolbox.core.coverage.BEDPECoverage(*args, **kwargs)
Arcs track from .bedpe file.
- Parameters:
- file: str
Path of .bedpe file
- posstr, optional
Method for choosing arch anchor for bedpe data: ‘start’, ‘end’, ‘mid’, default ‘mid’
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.BedGraphCoverage(*args, **kwargs)
BedGraph track.
- Parameters:
- filestr
File path of bedgraph file.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.BigWigCoverage(*args, **kwargs)
BigWig track
- Parameters:
- filestr
File path of bigwig file.
- num_binsint, optional
Number of bins to plot the hist in current range, default 700.
- stylestr, optional
Track graph type, format {‘line’, ‘fill’, ‘heatmap’, ‘scatter’}
- fmtstr, optional
Line styles used when the plot style is line, will be passed as fmt parameter in matplotlib.pyplot.plot
- line_widthint, optional
Value used when the plot style is line, will be passed as linewidth parameter in matplotlib.pyplot.plot
- sizeint, optional
Value used when the plot style is scatter, will be passed as s parameter in matplotlib.pyplot.scatter
- colorstr, optional
Main color
- threshold_colorstr, optional
Track’s color for values greater than specified threshold.
- thresholdfloat, optional
Threshold used when the plot style is line or scatter, values greater than this thresh will be plotted with color = threshold_color
- cmap: str, optional
Cmap used when the plot type is heatmap, will be passed as cmap paramerter in matplotlib.pyplot.matshow
- alphafloat, optional
Alpha value of plot, default 1.0
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot.
- data_range_style{bool, ‘text’, ‘y-axis’}, optional
Show_data_range or not, default True.
- max_value{float, ‘auto’}, optional
Max value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- min_value{float, ‘auto’}, optional
Min value of track. ‘auto’ for specify max value automatically, default ‘auto’.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.HLines(*args, **kwargs)
Horizontal line coverage, for show threshold.
- Parameters:
- valuesfloat
Y position. A list of y value or a single value.
- percent_modebool
If in percent mode, y position will equal to ymin + (ymax - ymin) * val.
- colorstr, optional
Line color, default ‘#1e1e1e’.
- alphafloat, optional
Line alpha value, default 0.8.
- line_stylestr, optional
Line style, default ‘dashed’.
- line_widthfloat, optional
Line width, default 0.5.
- namestr, optional
The name of thr Coverage.
- class coolbox.core.coverage.HiCPeaksCoverage(*args, **kwargs)
Hi-C Peaks(Loops) from .bedpe file. Used to show the peaks on the Hi-C interaction map.
- Parameters:
- file: str
Path of .bedpe file
- posstr, optional
Method for choosing arch anchor for bedpe data: ‘start’, ‘end’, ‘mid’, default ‘mid’
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.HighLights(*args, **kwargs)
High light region.
- Parameters:
- highlight_regionslist of {str, tuple}
A list of regions for highlights, region can be expressed as a tuple or string. region tuple like: [(‘chr1’, 100000, 120000), (‘chr2’, 130000, 150000)] region string format: chr:start-end like: [‘chr1:100000-120000’, ‘chr2:130000-150000’].
- colorstr, optional
High light region color, default HighLights.DEFAULT_COLOR.
- alphafloat, optional
High light region alpha value, default 0.5
- border_linebool, optional
Plot border line or not, default True.
- border_line_stylestr, optional
Border line style, default ‘dashed’
- border_line_widthfloat, optional
Border line width, default 1.0
- border_line_colorstr, optional
Border line color, default ‘#000000’
- border_line_alphafloat, optional
Border line alpha value, default 0.8
- namestr, optional
The name of thr Coverage.
- class coolbox.core.coverage.HighLightsFromFile(*args, **kwargs)
High light regions coverage, read the regions from the file.
- Parameters:
- file_str
Path to the file. Contains columns: chrom, start, end, color
- colorstr, optional
High light region color, use ‘rgb’ for specify color from the file, default ‘rgb’.
- alphafloat, optional
High light region alpha value, default 0.1.
- border_linebool, optional
Plot border line or not, default True.
- border_line_stylestr, optional
Border line style, default ‘dashed’.
- border_line_widthfloat, optional
Border line width, default 1.0.
- border_line_colorstr, optional
Border line color, default ‘#000000’
- border_line_alphafloat, optional
Border line alpha value, default 0.8
- namestr, optional
The name of thr Coverage.
- class coolbox.core.coverage.HistCoverage(*args, **kwargs)
Compose BigWig, BedGraph, SNP, BAMCov track automatically based on type of file extension.(.bw, .bigwig, .snp, .vcf, .bedgraph, .bam, .sam)
- class coolbox.core.coverage.PairsCoverage(*args, **kwargs)
Arcs track from .pairs file.
- Parameters:
- file: str
Path of .pairs file
- stylestr, optional
Style of arcs plot: ‘arcs’, ‘hicpeaks’, default ‘arcs’
- score_to_widthstr, optional
Mapping function of score to width, default: ‘0.5 + math.sqrt(score)’
- line_widthfloat, optional
Width of arc line.
- open_regionbool, optional
If specified to True, will fetch the contacts on side in the region, default True
- diameter_to_heightstr, optional
Mapping function of arc diameter(interval end - start) to height. You can specify to ‘max_diameter’ let all arcs has same height. default ‘max_height * diameter / max_diameter’.
- orientationstr, optional
Track orientation, use ‘inverted’ for inverted track plot. default None
- line_stylestr, optional
Border line style, default ‘solid’
- fillbool, optional
Fill center or not, default False.
- fill_colorstr, optional
Fill color, use ‘rgb’ for specify color in file, default ‘rgb’.
- fill_alphafloat, optional
Alpha value of fill region. default 0.2
- side{‘upper’, ‘lower’, ‘both’}
Plot peak in which side of the matrix. NOTE: This parameters is useful only if the Cool track in matrix format.
- alphafloat, optional
Alpha value of track, default 0.8.
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- colorstr, optional;
Color of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.TADCoverage(*args, **kwargs)
Tad tack from bed file
- Parameters:
- border_style: str, optional
Border style of tad. (Default: ‘solid’)
- border_width: int, optional
Border width of tad. (Default: ‘2.0’)
- show_scorebool
Show bed score or not. default False.
- score_font_size{‘auto’, int}
Score text font size. default ‘auto’
- score_font_colorstr
Score text color. default ‘#000000’
- score_height_ratiofloat
(text tag height) / (TAD height). used for adjust the position of Score text. default 0.5
- border_onlybool
Only show border, default False
- depth_ratio{float, ‘auto’, ‘full’}
Depth ratio of triangular, use ‘full’ for full depth, use ‘auto’ for calculate depth by current genome_range. default ‘auto’.
- orientation{‘normal’, ‘inverted’}
Invert y-axis or not, default ‘normal’
- file: str
The file path of .bed file.
- colorstr, optional
Track color, ‘rgb’ for auto specify color according to bed record. (Default: ‘rgb’)
- border_colorstr, optional
Border_color of gene. (Default: ‘black’)
- max_valuefloat, optional
Max score. (Default: inf)
- min_valuefloat, optional
Min score. (Default: -inf)
- properties_dictdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr, optional
The name of Track. (Default: “{self.__class__.__name__}.{self.__class__._counts}”)
- titlestr, optional
Title of ax
- heightint, optional
Height of ax
- Attributes:
- propertiesdict
The properties(features) of this track. For example ‘height’, ‘color’…
- namestr
The name of Track.
- coverageslist of coolbox.api.coverage.Coverage
Coverages on this Track.
- class coolbox.core.coverage.Vlines(*args, **kwargs)
Vertical lines.
- Parameters:
- vlineslist of {int, str}
A list of vline positions. position can be expressed as a tuple like: [(‘chr1’, 10000), (‘chr2’, 50000)] or a genome range string like: [‘chr1:10000-10000’, ‘chr2:50000-50000’]
- colorstr, optional
Line color, default ‘#1e1e1e’.
- alphafloat, optional
Line alpha value, default 0.8.
- line_stylestr, optional
Line style, default ‘dashed’.
- line_widthfloat, optional
Line width, default 0.5.
- namestr, optional
The name of thr Coverage.
- class coolbox.core.coverage.VlinesFromFile(*args, **kwargs)
Vertical lines from the file.
- Parameters:
- file_str
Path to file.
- colorstr, optional
Line color, default ‘#1e1e1e’.
- alphafloat, optional
Line alpha value, default 0.8.
- line_stylestr, optional
Line style, default ‘dashed’.
- line_widthfloat, optional
Line width, default 0.5.
- namestr, optional
The name of thr Coverage.
Feature
Classes:
|
Track color. |
|
Track color map. |
|
Control Cool track's style. |
|
Control Cool track's depth ratio. |
|
Feature base class. |
|
FrameFeature base class. |
|
Frame title. |
|
Style of BigWig or BedGraph. |
|
Invert the orientation of track. |
|
Max value of track. |
|
Min value of track. |
|
Show color bar or not. |
|
Show data range or not. |
|
Track title. |
|
Track height. |
- class coolbox.core.feature.Color(value)
Track color.
- class coolbox.core.feature.ColorMap(value)
Track color map.
- class coolbox.core.feature.CoolStyle(style='triangular')
Control Cool track’s style.
- class coolbox.core.feature.DepthRatio(depth_ratio)
Control Cool track’s depth ratio.
- class coolbox.core.feature.Feature(**kwargs)
Feature base class.
- class coolbox.core.feature.FrameFeature(**kwargs)
FrameFeature base class.
- class coolbox.core.feature.FrameTitle(value)
Frame title.
- class coolbox.core.feature.HistStyle(style='fill', fmt='-', size=10, line_width=2.0)
Style of BigWig or BedGraph.
- class coolbox.core.feature.Inverted
Invert the orientation of track.
- class coolbox.core.feature.MaxValue(value)
Max value of track.
- class coolbox.core.feature.MinValue(value)
Min value of track.
- class coolbox.core.feature.ShowColorBar(show=True)
Show color bar or not.
- class coolbox.core.feature.ShowDataRange(data_range_style='y-axis')
Show data range or not.
- class coolbox.core.feature.Title(value)
Track title.
- class coolbox.core.feature.TrackHeight(value)
Track height.
Frame
Classes:
|
Frame for arrange and group plots. |
- class coolbox.core.frame.Frame(*args, **kwargs)
Frame for arrange and group plots.
- Parameters:
- genome_range{GenomeRange, str}, optional
The init genome range.
- width{int, float}, optional
Width of frame, the unit is in ‘cm’, 1cm = 2.54inch, default Frame.DEFAULT_WIDTH.
- width_ratiostuple, optional
Width ratios of track and track title, like (0.9, 0.1). default Frame.DEFAULT_WIDTH_RATIOS.
- marginsdict, optional
Margins of frame, default Frame.DEFAULT_MARGINS.
- titlestr, optional
The title of this frame, default ‘’.
- Attributes:
- propertiesdict
Frame properties dict.
- tracksOrderedDict
Container of all tracks.
- current_rangeGenomeRange, optional
Current frame range.
Examples
>>> frame_1 = Frame() >>> frame_2 = Frame(gr="chr1:1000-2000") >>> str(frame_2.current_range) 'chr1:1000-2000' >>> frame_3 = Frame(gr=GenomeRange("chr1", 1000, 2000)) >>> str(frame_3.current_range) 'chr1:1000-2000'
Methods:
add_track(track[, pos])Add Track object to self.
get_tracks_height([default_height])Get heights of all tracks.
plot(*args[, close_fig])Plot all tracks.
show()Display self's elements on screen.
- add_track(track, pos='tail')
Add Track object to self.
- Parameters:
- trackTrack
The track need to be added to self.tracks
- pos{‘tail’, ‘head’}
Add track to tail or head. default ‘tail’
Examples
>>> from coolbox.core.track import XAxis, BigWig >>> frame = Frame() >>> frame.add_track(XAxis()) >>> frame.add_track(BigWig("tests/test_data/bigwig_chrx_2e6_5e6.bw")) >>> len(frame.tracks) 2
- get_tracks_height(default_height=3)
Get heights of all tracks.
- Returns:
- heightslist of float
heights of all tracks.
- plot(*args, close_fig=True)
Plot all tracks.
>>> from coolbox.api import * >>> frame = XAxis() + XAxis() >>> frame.plot("chr1", 100000, 200000) >>> frame.plot("chr1:100000-200000")
- show()
Display self’s elements on screen.
JointView
Classes:
|
Compose two track and a center matrix. |
- class coolbox.core.frame.superframe.JointView(center: Track, top: Frame | Track = None, right: Frame | Track = None, bottom: Frame | Track = None, left: Frame | Track = None, **kwargs)
Compose two track and a center matrix.
https://github.com/GangCaoLab/CoolBox/issues/12
- Parameters:
- centerTrack
Center track for show ‘contact map-like’ plot, should support for plotting images with 2d GenomeRanges.
- topFrame, optional
Frame plot in the top of the center track.
- rightFrame, optional
- bottomFrame, optional
- leftFrame, optional
- center_widthfloat
The width of center track, unit in cm. default 20.
- trblstr
sub-frames(top right bottom left) use which genome range(first or second), default ‘1212’, which means: top -> 1, right -> 2, bottom -> 1, left -> 2
- spacefloat
Space between frame and center, unit in cm. default 0.5
Methods:
fetch_data([gr1, gr2])plot([gr1, gr2])- fetch_data(gr1=None, gr2=None) dict
- Parameters:
- gr1{str, GenomeRange}, optional
First genome range
- gr2{str, GenomeRange}, optional
Second genome range
- plot(gr1=None, gr2=None)
- Parameters:
- gr1{str, GenomeRange}
First genome range
- gr2{str, GenomeRange}, optional
Second genome range
Browser
Classes:
|
Browser base class. |
|
Widgets container. |
- class coolbox.core.browser.Browser(frame, reference_genome='hg19', init_range=None, widgets_box='simple', dpi=None, img_format='svg')
Browser base class.
Methods:
Clear the fig cache.
get_init_range([chrom])Generate an initial range within a chromosome.
preload_imgs(directions)Preloading images to self.fig_cache.
refresh([hard])Refresh the image display.
save(path[, dpi])Save current frame's image to file.
show(*args, **kwargs)Show widgets and frame.
- clear_fig_cache()
Clear the fig cache.
- get_init_range(chrom=None)
Generate an initial range within a chromosome.
- Args:
chrom (str, optional): initial choromosome.
- Return:
(
GenomeRange)
- preload_imgs(directions)
Preloading images to self.fig_cache.
Can load image in one of 4 directions:
left, right, zoom-in, zoom-out
or load all directions.
- refresh(hard=False)
Refresh the image display.
- save(path, dpi=None)
Save current frame’s image to file. The suffix of the path will changing the saving format. For example: bsr.save(“fig.png”) will save file to ‘png’ format.
- show(*args, **kwargs)
Show widgets and frame.
- class coolbox.core.browser.WidgetsPanel(type='simple', reference_genome='hg19')
Widgets container.
- Parameters:
- type{‘simple’, ‘full’}, optional
Widgets type ‘simple’ or ‘full’, default ‘simple’
- reference_genomestr, optional
Reference genome, built-in references:(‘hg19’, ‘hg38’, ‘mm9’, ‘mm10’) if you want use other genome, you can specify the “chromosome length file”, that is a tab splited file, first column is the chromosomes, and second column is the length of correspond chromosome. default ‘hg19’
Utilities
Functions:
|
Search track by it's name. |
|
Convert bool value to 'yes' or 'no', for compatible with pyGenomeTracks Convert string to float if possible |
|
Generate the error message of error operand type. |
- coolbox.utilities.correspond_track(track_or_name: Track | str)
Search track by it’s name. For mark corresponding track in a element definition, allow pass track name to find related object in CLI mode.
- coolbox.utilities.format_properties(properties)
Convert bool value to ‘yes’ or ‘no’, for compatible with pyGenomeTracks Convert string to float if possible
- coolbox.utilities.op_err_msg(a, b, op='+')
Generate the error message of error operand type.