skbio.metadata.PositionalMetadataMixin#

class skbio.metadata.PositionalMetadataMixin(positional_metadata=None)[source]#

Attributes

positional_metadata

pd.DataFrame containing metadata along an axis.

Methods

has_positional_metadata()

Determine if the object has positional metadata.

Special methods

__copy__()

__deepcopy__(memo)

__eq__(other)

Return self==value.

__ne__(other)

Return self!=value.

Special methods (inherited)

__ge__(value, /)

Return self>=value.

__getstate__(/)

Helper for pickle.

__gt__(value, /)

Return self>value.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__str__(/)

Return str(self).

Details

positional_metadata#

pd.DataFrame containing metadata along an axis.

Notes

This property can be set and deleted. When setting new positional metadata, a shallow copy is made and the pd.DataFrame index is set to pd.RangeIndex(start=0, stop=axis_len, step=1).

Examples

Note

scikit-bio objects with positional metadata share a common interface for accessing and manipulating their positional metadata. The following examples use scikit-bio’s DNA class to demonstrate positional metadata behavior. These examples apply to all other scikit-bio objects storing positional metadata.

Create a DNA sequence with positional metadata:

>>> from skbio import DNA
>>> seq = DNA(
...     'ACGT',
...     positional_metadata={'exons': [True, True, False, True],
...                          'quality': [3, 3, 20, 11]})
>>> seq
DNA
-----------------------------
Positional metadata:
    'exons': <dtype: bool>
    'quality': <dtype: int64>
Stats:
    length: 4
    has gaps: False
    has degenerates: False
    has definites: True
    GC-content: 50.00%
-----------------------------
0 ACGT

Retrieve positional metadata:

>>> seq.positional_metadata
   exons  quality
0   True        3
1   True        3
2  False       20
3   True       11

Update positional metadata:

>>> seq.positional_metadata['gaps'] = seq.gaps()
>>> seq.positional_metadata
   exons  quality   gaps
0   True        3  False
1   True        3  False
2  False       20  False
3   True       11  False

Set positional metadata:

>>> seq.positional_metadata = {'degenerates': seq.degenerates()}
>>> seq.positional_metadata 
  degenerates
0       False
1       False
2       False
3       False

Delete positional metadata:

>>> seq.has_positional_metadata()
True
>>> del seq.positional_metadata
>>> seq.positional_metadata
Empty DataFrame
Columns: []
Index: [0, 1, 2, 3]
>>> seq.has_positional_metadata()
False
abstract __copy__()[source]#
abstract __deepcopy__(memo)[source]#
abstract __eq__(other)[source]#

Return self==value.

abstract __ne__(other)[source]#

Return self!=value.