ConsensusMap#

class pyopenms.ConsensusMap(*args, **kwargs)#

Bases: object

A container for consensus elements. A ConsensusMap is a container holding 2-dimensional consensus elements (ConsensusFeature) which in turn represent analytes that have been quantified across multiple LC-MS/MS experiments. Each analyte in a ConsensusFeature is linked to its original LC-MS/MS run, the links are maintained by the ConsensusMap class. The map is implemented as a vector of elements of type ConsensusFeature. To be consistent, all maps who are referenced by ConsensusFeature objects (through a unique id) need to be registered in this class. This class supports direct iteration in Python.

__init__(self) → None#
__init__(self, arg: pyopenms._pyopenms_kernel.ConsensusMap, /) → None
__init__(self, arg: int, /) → None

Methods

consensus_feature_views()

Returns a list of live views of the consensus features (see consensus_feature_view).

df_columns([columns])

Returns a list of column names that to_df() would produce.

feature_columns()

Return list of column names that to_feature_arrow() and to_feature_qpx() produce.

get_df(*args, **kwargs)

Deprecated: Use to_df() instead.

get_df_columns(*args, **kwargs)

Deprecated: Use df_columns() instead.

get_intensity_df()

Generates a pandas DataFrame with feature intensities from each sample in long format.

get_metadata_df()

Generates a pandas DataFrame with feature meta data.

iter_consensus_feature_views()

Yields live views of the consensus features, one at a time (see consensus_feature_view).

to_arrow([columns])

Returns an Apache Arrow Table with consensus feature meta data and intensities.

to_df([columns])

Generates a pandas DataFrame with both consensus feature meta data and intensities.

to_feature_arrow([reference_file_name, ...])

Export consensus features as Apache Arrow Table following QPX feature schema.

to_feature_df(**kwargs)

Export consensus features as pandas DataFrame following QPX feature schema.

to_feature_parquet(filename[, compression])

Export consensus features to a Parquet file.

to_feature_qpx([qpx_version, creator, ...])

Export consensus features as QPX format (dict with file_metadata and features).

Attributes

append

Add a consensus feature to the map (alias for push_back)

appendColumns

Add consensus map entries as new columns

appendRows

Add consensus map entries as new rows

clear

Clears all data and meta data

clearMetaInfo

Removes all meta values

clearRanges

Clear all ranges

clearUniqueId

Clear the unique id.

consensus_feature_view

Returns a live view of the consensus feature at index i.

empty

Returns True if the map is empty

ensureUniqueId

Assigns a valid unique id, but only if the present one is invalid.

extend

Overloaded function.

getColumnHeaders

Returns the column headers

getDataProcessing

Returns a copy of the description of the applied data processing

getExperimentType

Non-mutable access to the experiment type

getIdentifier

Retrieve document identifier (e.g. an LSID).

getKeys

Overloaded function.

getLoadedFilePath

Returns the file_name which is the absolute path to the file loaded

getLoadedFileType

Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, ...) of the file loaded.

getMaxIntensity

Get the maximum intensity value

getMaxMZ

Get the maximum m/z value

getMaxRT

Get the maximum RT value

getMetaValue

Returns the value corresponding to a string, or DataValue::EMPTY if not found

getMinIntensity

Get the minimum intensity value

getMinMZ

Get the minimum m/z value

getMinRT

Get the minimum RT value

getPrimaryMSRunPath

Returns the MS run path (stored in ColumnHeaders)

getProteinIdentifications

Returns the protein identification runs stored in this map

getUnassignedPeptideIdentifications

Returns peptide identifications that are not assigned to any consensus feature

getUniqueId

Returns the unique id

hasInvalidUniqueId

Returns whether the unique id is invalid.

hasValidUniqueId

Returns whether the unique id is valid.

isMetaEmpty

Returns if the MetaInfo is empty

isValid

metaRegistry

metaValueExists

Returns whether an entry with the given name exists

push_back

Add a consensus feature to the map

removeMetaValue

Removes the DataValue corresponding to name if it exists

reserve

Reserves space for n consensus features

setColumnHeaders

Sets the column headers

setDataProcessing

Sets the description of the applied data processing

setExperimentType

Mutable access to the experiment type

setIdentifier

Sets document identifier (e.g. an LSID).

setLoadedFilePath

Sets the file_name according to absolute path of the file loaded, preferably done whilst loading

setLoadedFileType

Sets the file_type according to the type of the file loaded from, preferably done whilst loading

setMetaValue

Sets the DataValue corresponding to a name

setPrimaryMSRunPath

Overloaded function.

setProteinIdentifications

Sets the protein identifications

setUnassignedPeptideIdentifications

Sets the unassigned PeptideIdentificationList

setUniqueId

Overloaded function.

setUniqueIds

Sets unique IDs on the map and all its child consensus features

size

Returns the number of consensus features

sortByIntensity

Sorts the peaks according to ascending intensity.

sortByMZ

Sorts the peaks according to m/z position

sortByMaps

Sorts with respect to the sets of maps covered by the consensus features (lexicographically)

sortByPosition

Lexicographically sorts the peaks by their position (First RT then m/z)

sortByQuality

Sorts the peaks according to ascending quality.

sortByRT

Sorts the peaks according to RT position

sortBySize

Sorts with respect to the size (number of elements)

sortPeptideIdentificationsByMapIndex

Sorts PeptideIdentifications of consensus features with respect to their map index.

updateRanges

Updates the RT, m/z, and intensity ranges based on contained consensus features

append#

Add a consensus feature to the map (alias for push_back)

appendColumns#

Add consensus map entries as new columns

appendRows#

Add consensus map entries as new rows

clear#

Clears all data and meta data

clearMetaInfo#

Removes all meta values

clearRanges#

Clear all ranges

clearUniqueId#

Clear the unique id. The new unique id will be invalid. Returns 1 if the unique id was changed, 0 otherwise

consensus_feature_view#

Returns a live view of the consensus feature at index i. The view aliases this object’s storage: edits through it are visible immediately, and it stays valid only until the consensus feature list is resized or reordered. The parent object is kept alive automatically. For an owned copy use cm[i].

consensus_feature_views()#

Returns a list of live views of the consensus features (see consensus_feature_view).

df_columns(columns='default')#

Returns a list of column names that to_df() would produce.

empty#

Returns True if the map is empty

ensureUniqueId#

Assigns a valid unique id, but only if the present one is invalid. Returns 1 if the unique id was changed, 0 otherwise

extend#

Overloaded function.

  1. extend(self, items: list) -> None

Add multiple consensus features from a list

  1. extend(self, other: pyopenms._pyopenms_kernel.ConsensusMap) -> None

Add features from another ConsensusMap

feature_columns()#

Return list of column names that to_feature_arrow() and to_feature_qpx() produce.

Returns#

list

List of column name strings.

getColumnHeaders#

Returns the column headers

getDataProcessing#

Returns a copy of the description of the applied data processing

getExperimentType#

Non-mutable access to the experiment type

getIdentifier#

Retrieve document identifier (e.g. an LSID)

getKeys#

Overloaded function.

  1. getKeys(self, keys: list) -> None

Fills the given list with all meta value keys

  1. getKeys(self) -> list

Returns all meta value keys as a list

getLoadedFilePath#

Returns the file_name which is the absolute path to the file loaded

getLoadedFileType#

Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, …) of the file loaded

getMaxIntensity#

Get the maximum intensity value

getMaxMZ#

Get the maximum m/z value

getMaxRT#

Get the maximum RT value

getMetaValue#

Returns the value corresponding to a string, or DataValue::EMPTY if not found

getMinIntensity#

Get the minimum intensity value

getMinMZ#

Get the minimum m/z value

getMinRT#

Get the minimum RT value

getPrimaryMSRunPath#

Returns the MS run path (stored in ColumnHeaders)

getProteinIdentifications#

Returns the protein identification runs stored in this map

getUnassignedPeptideIdentifications#

Returns peptide identifications that are not assigned to any consensus feature

getUniqueId#

Returns the unique id

get_df(*args, **kwargs)#

Deprecated: Use to_df() instead.

get_df_columns(*args, **kwargs)#

Deprecated: Use df_columns() instead.

get_intensity_df()#

Generates a pandas DataFrame with feature intensities from each sample in long format.

get_metadata_df()#

Generates a pandas DataFrame with feature meta data.

hasInvalidUniqueId#

Returns whether the unique id is invalid. Returns 1 if the unique id is invalid, 0 otherwise

hasValidUniqueId#

Returns whether the unique id is valid. Returns 1 if the unique id is valid, 0 otherwise

isMetaEmpty#

Returns if the MetaInfo is empty

isValid = <nanobind.nb_func object>#
iter_consensus_feature_views()#

Yields live views of the consensus features, one at a time (see consensus_feature_view).

metaRegistry = <nanobind.nb_func object>#
metaValueExists#

Returns whether an entry with the given name exists

push_back#

Add a consensus feature to the map

removeMetaValue#

Removes the DataValue corresponding to name if it exists

reserve#

Reserves space for n consensus features

setColumnHeaders#

Sets the column headers

setDataProcessing#

Sets the description of the applied data processing

setExperimentType#

Mutable access to the experiment type

setIdentifier#

Sets document identifier (e.g. an LSID)

setLoadedFilePath#

Sets the file_name according to absolute path of the file loaded, preferably done whilst loading

setLoadedFileType#

Sets the file_type according to the type of the file loaded from, preferably done whilst loading

setMetaValue#

Sets the DataValue corresponding to a name

setPrimaryMSRunPath#

Overloaded function.

  1. setPrimaryMSRunPath(self, s: list[str]) -> None

Sets the file paths to the primary MS run (stored in ColumnHeaders)

  1. setPrimaryMSRunPath(self, s: list[str], e: pyopenms._pyopenms_experiment.MSExperiment) -> None

setProteinIdentifications#

Sets the protein identifications

setUnassignedPeptideIdentifications#

Sets the unassigned PeptideIdentificationList

setUniqueId#

Overloaded function.

  1. setUniqueId(self) -> int

Assigns a new, valid unique id. Always returns 1

  1. setUniqueId(self, rhs: int) -> None

Assigns the given unique id

  1. setUniqueId(self, rhs: str) -> None

Assigns a unique id from a string (extracts UInt64 after last underscore)

setUniqueIds#

Sets unique IDs on the map and all its child consensus features

size#

Returns the number of consensus features

sortByIntensity#

Sorts the peaks according to ascending intensity.

sortByMZ#

Sorts the peaks according to m/z position

sortByMaps#

Sorts with respect to the sets of maps covered by the consensus features (lexicographically)

sortByPosition#

Lexicographically sorts the peaks by their position (First RT then m/z)

sortByQuality#

Sorts the peaks according to ascending quality.

sortByRT#

Sorts the peaks according to RT position

sortBySize#

Sorts with respect to the size (number of elements)

sortPeptideIdentificationsByMapIndex#

Sorts PeptideIdentifications of consensus features with respect to their map index.

to_arrow(columns=None)#

Returns an Apache Arrow Table with consensus feature meta data and intensities.

to_df(columns=None)#

Generates a pandas DataFrame with both consensus feature meta data and intensities.

to_feature_arrow(reference_file_name=None, columns=None, include_modifications=True, scan_format='native_id')#

Export consensus features as Apache Arrow Table following QPX feature schema.

Parameters#

reference_file_namestr, optional

Reference file name to use for unmatched features.

columnslist, optional

Columns to include. If None, includes all.

include_modificationsbool

Include modification information (default: True).

scan_formatstr

Format for scan numbers (default: ‘native_id’).

Returns#

pyarrow.Table

Arrow table with feature data.

to_feature_df(**kwargs)#

Export consensus features as pandas DataFrame following QPX feature schema.

Parameters#

**kwargs

Passed to to_feature_arrow().

Returns#

pandas.DataFrame

DataFrame with feature data.

to_feature_parquet(filename, compression='snappy', **kwargs)#

Export consensus features to a Parquet file.

Parameters#

filenamestr

Output file path.

compressionstr

Compression codec (default: ‘snappy’).

**kwargs

Passed to to_feature_arrow().

to_feature_qpx(qpx_version='1.1', creator='pyopenms', software_provider='OpenMS', **kwargs)#

Export consensus features as QPX format (dict with file_metadata and features).

Parameters#

qpx_versionstr

QPX schema version.

creatorstr

Creator identifier.

software_providerstr

Software provider name.

**kwargs

Passed to to_feature_arrow().

Returns#

dict

Dictionary with ‘file_metadata’ and ‘features’ keys.

updateRanges#

Updates the RT, m/z, and intensity ranges based on contained consensus features