TrackData#
- class alphagenome.data.track_data.TrackData(values, metadata, resolution=1, interval=None, uns=None)[source]#
Container for storing track values and metadata.
TrackDatastores multiple genomic tracks at the same resolution, stacked into an N-dimensional array whose last axis isnum_tracks(for example, shape (positional_bins, num_tracks)). It also contains metadata information as a pandas DataFrame withnum_tracksrows.Metadata DataFrame has two main required columns:
name: The name of the track.
strand: The strand of the track (‘+’, ‘-’, or ‘.’).
Other columns are optional.
Valid shapes of
TrackData.valuesare:[num_tracks]
[positional_bins, num_tracks]
[positional_bins, positional_bins, num_tracks]
…
TrackDatacan store both model predictions and raw data. It can optionally hold information about thegenome.Intervalfrom which the data were derived and.unsfor storing additional unstructured data.In addition to being a container,
TrackDataprovides functionality for common aggregation and slicing operations.- values#
A numpy array of floats or integers representing the track values. Positional axes have the same length. Example valid shapes are: [num_tracks], [positional_bins, num_tracks], and [positional_bins, positional_bins, num_tracks].
- metadata#
A pandas DataFrame containing metadata for each track. The DataFrame must have at least two columns: ‘name’ and ‘strand’.
- resolution#
The resolution of the track data in base pairs.
- interval#
An optional
Intervalobject representing the genomic region.
- uns#
An optional dictionary to store additional unstructured data.
- positional_axes#
Tuple of positional dimension sizes in
values.
- num_tracks#
Total number of tracks along the last axis of
values.
- width#
Genomic width covered by the track bins (
positional_bins * resolution).
- names#
Array of track names from
metadata['name'].
- strands#
Array of track strands from
metadata['strand'].
- ontology_terms#
Optional list of
OntologyTermobjects parsed frommetadata['ontology_curie'].
- Raises:
ValueError – If the number of tracks in
valuesdoes not match the number of rows inmetadata, or ifmetadatacontains duplicate (name, strand) pairs, or if the positional axes have different lengths, or if the interval width does not match the expected width.
Methods
|
Returns the bin index for a relative position. |
|
Changes the resolution of the track data. |
|
Returns a deep copy of the |
|
Downsamples the track data to a lower resolution. |
Filters tracks to the negative DNA strand. |
|
Filters tracks to the non-negative DNA strands (positive and unstranded). |
|
Filters tracks to the non-positive DNA strands (negative and unstranded). |
|
Filters tracks to observed tracks. |
|
Filters tracks to the positive DNA strand. |
|
Filters tracks to stranded tracks (excluding unstranded). |
|
Filters tracks to unstranded tracks. |
|
|
Filters tracks by a boolean mask. |
|
Splits tracks into groups based on a metadata column. |
|
Pads the track data along positional axes. |
|
Resizes the track data by cropping or padding with a fixed center. |
Reverse complements the track data and interval if present. |
|
Selects tracks by numerical index. |
|
|
Selects tracks by name. |
|
Slices the track data using a |
|
Slices the track data along the positional axes. |
|
Upsamples the track data to a higher resolution. |
|
Returns a new |
|
Returns a new |