Miscellanea¶
-
allel.
plot_variant_locator
(pos, step=None, ax=None, start=None, stop=None, flip=False, line_kwargs=None)[source]¶ Plot lines indicating the physical genome location of variants from a single chromosome/contig. By default the top x axis is in variant index space, and the bottom x axis is in genome position space.
Parameters: - pos : array_like
A sorted 1-dimensional array of genomic positions from a single chromosome/contig.
- step : int, optional
Plot a line for every step variants.
- ax : axes, optional
The axes on which to draw. If not provided, a new figure will be created.
- start : int, optional
The start position for the region to draw.
- stop : int, optional
The stop position for the region to draw.
- flip : bool, optional
Flip the plot upside down.
- line_kwargs : dict-like
Additional keyword arguments passed through to plt.Line2D.
Returns: - ax : axes
The axes on which the plot was drawn
-
allel.
tabulate_state_transitions
(x, states, pos=None)[source]¶ Construct a dataframe where each row provides information about a state transition.
Parameters: - x : array_like, int
1-dimensional array of state values.
- states : set
Set of states of interest. Any state value not in this set will be ignored.
- pos : array_like, int, optional
Array of positions corresponding to values in x.
Returns: - df : DataFrame
Notes
The resulting dataframe includes one row at the start representing the first state observation and one row at the end representing the last state observation.
Examples
>>> import allel >>> x = [1, 1, 0, 1, 1, 2, 2, 0, 2, 1, 1] >>> df = allel.tabulate_state_transitions(x, states={1, 2}) >>> df lstate rstate lidx ridx 0 -1 1 -1 0 1 1 2 4 5 2 2 1 8 9 3 1 -1 10 -1 >>> pos = [2, 4, 7, 8, 10, 14, 19, 23, 28, 30, 31] >>> df = allel.tabulate_state_transitions(x, states={1, 2}, pos=pos) >>> df lstate rstate lidx ridx lpos rpos 0 -1 1 -1 0 -1 2 1 1 2 4 5 10 14 2 2 1 8 9 28 30 3 1 -1 10 -1 31 -1
-
allel.
tabulate_state_blocks
(x, states, pos=None)[source]¶ Construct a dataframe where each row provides information about continuous state blocks.
Parameters: - x : array_like, int
1-dimensional array of state values.
- states : set
Set of states of interest. Any state value not in this set will be ignored.
- pos : array_like, int, optional
Array of positions corresponding to values in x.
Returns: - df : DataFrame
Examples
>>> import allel >>> x = [1, 1, 0, 1, 1, 2, 2, 0, 2, 1, 1] >>> df = allel.tabulate_state_blocks(x, states={1, 2}) >>> df state support start_lidx ... size_min size_max is_marginal 0 1 4 -1 ... 5 -1 True 1 2 3 4 ... 4 4 False 2 1 2 8 ... 2 -1 True [3 rows x 9 columns] >>> pos = [2, 4, 7, 8, 10, 14, 19, 23, 28, 30, 31] >>> df = allel.tabulate_state_blocks(x, states={1, 2}, pos=pos) >>> df state support start_lidx ... stop_rpos length_min length_max 0 1 4 -1 ... 14 9 -1 1 2 3 4 ... 30 15 19 2 1 2 8 ... -1 2 -1 [3 rows x 15 columns]