ConsensusMap#
- class pyopenms.ConsensusMap(*args, **kwargs)#
Bases:
ConsensusMap- __init__(*args, **kwargs)#
Overload:
- __init__(self) None
Overload:
- __init__(self, in_0: ConsensusMap) None
Methods
__init__(*args, **kwargs)appendColumns(self, in_0)Add consensus map entries as new columns
appendRows(self, in_0)Add consensus map entries as new rows
clearMetaInfo(self)Removes all meta values
clearRanges(self)Resets all range dimensions as empty
clearUniqueId(self)Clear the unique id.
empty(self)ensureUniqueId(self)Assigns a valid unique id, but only if the present one is invalid.
getDataProcessing(self)Returns a const reference to the description of the applied data processing
getExperimentType(self)Non-mutable access to the experiment type
getIdentifier(self)Retrieve document identifier (e.g. an LSID).
getKeys(self, keys)Fills the given vector with a list of all keys for which a value is set
getLoadedFilePath(self)Returns the file_name which is the absolute path to the file loaded
getLoadedFileType(self)Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, ...) of the file loaded.
getMaxIntensity(self)Returns the maximum intensity
getMaxMZ(self)Returns the maximum m/z
getMaxRT(self)Returns the maximum RT
getMetaValue(self, in_0)Returns the value corresponding to a string, or
getMinIntensity(self)Returns the minimum intensity
getMinMZ(self)Returns the minimum m/z
getMinRT(self)Returns the minimum RT
getPrimaryMSRunPath(self, toFill)Returns the MS run path (stored in ColumnHeaders)
getUniqueId(self)Returns the unique id
get_df([columns])Generates a pandas DataFrame with both consensus feature meta data and intensities from each sample.
get_df_columns([columns])Returns a list of column names that get_df() would produce.
Generates a pandas DataFrame with feature intensities from each sample in long format (over files).
Generates a pandas DataFrame with feature meta data.
hasInvalidUniqueId(self)Returns whether the unique id is invalid.
hasValidUniqueId(self)Returns whether the unique id is valid.
isMetaEmpty(self)Returns if the MetaInfo is empty
isValid(self, unique_id)Returns true if the unique_id is valid, false otherwise
metaRegistry(self)Returns a reference to the MetaInfoRegistry
metaValueExists(self, in_0)Returns whether an entry with the given name exists
push_back(self, spec)removeMetaValue(self, in_0)Removes the DataValue corresponding to name if it exists
reserve(self, s)setDataProcessing(self, in_0)Sets the description of the applied data processing
setExperimentType(self, experiment_type)Mutable access to the experiment type
setIdentifier(self, id)Sets document identifier (e.g. an LSID).
setLoadedFilePath(self, file_name)Sets the file_name according to absolute path of the file loaded, preferably done whilst loading
setLoadedFileType(self, file_name)Sets the file_type according to the type of the file loaded from, preferably done whilst loading
setMetaValue(self, in_0, in_1)Sets the DataValue corresponding to a name
setProteinIdentifications(self, in_0)Sets the protein identifications
setUnassignedPeptideIdentifications(self, ...)Sets the unassigned PeptideIdentificationList
setUniqueId(self, rhs)Assigns a new, valid unique id.
size(self)sortByMZ(self)Sorts the peaks according to m/z position
sortByMaps(self)Sorts with respect to the sets of maps covered by the consensus features (lexicographically)
sortByPosition(self)Lexicographically sorts the peaks by their position (First RT then m/z)
sortByRT(self)Sorts the peaks according to RT position
sortBySize(self)Sorts with respect to the size (number of elements)
Sorts PeptideIdentifications of consensus features with respect to their map index.
updateRanges(self)- appendColumns(self, in_0: ConsensusMap) ConsensusMap#
Add consensus map entries as new columns
- appendRows(self, in_0: ConsensusMap) ConsensusMap#
Add consensus map entries as new rows
- clear()#
Overload:
- clear(self, clear_meta_data: bool) None
Clears all data and meta data
Overload:
- clear(self) None
- clearMetaInfo(self) None#
Removes all meta values
- clearRanges(self) None#
Resets all range dimensions as empty
- clearUniqueId(self) int#
Clear the unique id. The new unique id will be invalid. Returns 1 if the unique id was changed, 0 otherwise
- empty(self) bool#
- ensureUniqueId(self) int#
Assigns a valid unique id, but only if the present one is invalid. Returns 1 if the unique id was changed, 0 otherwise
- getColumnHeaders()#
- getDataProcessing(self) List[DataProcessing]#
Returns a const reference to the description of the applied data processing
- getKeys(self, keys: List[bytes]) None#
Fills the given vector with a list of all keys for which a value is set
- getLoadedFilePath(self) bytes | str | String#
Returns the file_name which is the absolute path to the file loaded
- getLoadedFileType(self) int#
Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, …) of the file loaded
- getMaxIntensity(self) float#
Returns the maximum intensity
- getMaxMZ(self) float#
Returns the maximum m/z
- getMaxRT(self) float#
Returns the maximum RT
- getMetaValue(self, in_0: bytes | str | String) int | float | bytes | str | List[int] | List[float] | List[bytes]#
Returns the value corresponding to a string, or
- getMinIntensity(self) float#
Returns the minimum intensity
- getMinMZ(self) float#
Returns the minimum m/z
- getMinRT(self) float#
Returns the minimum RT
- getPrimaryMSRunPath(self, toFill: List[bytes]) None#
Returns the MS run path (stored in ColumnHeaders)
- getProteinIdentifications(self) List[ProteinIdentification]#
- getUnassignedPeptideIdentifications(self) PeptideIdentificationList#
- getUniqueId(self) int#
Returns the unique id
- get_df(columns: None | List[str] = None)#
Generates a pandas DataFrame with both consensus feature meta data and intensities from each sample.
- Args:
- columns (list or None): List of column names to include. If None,
includes all columns. Use get_df_columns() to discover available columns.
- Returns:
pandas.DataFrame: meta data and intensity DataFrame
- Example:
>>> # Get all columns >>> df = cmap.get_df()
>>> # Discover available columns >>> print(cmap.get_df_columns())
>>> # Get only specific columns >>> df = cmap.get_df(columns=['sequence', 'mz', 'intensity'])
- get_df_columns(columns: str = 'default') List[str]#
Returns a list of column names that get_df() would produce.
Useful for discovering available columns before export.
- Args:
columns (str): ‘default’ for standard columns, ‘all’ for all available columns.
- Returns:
list: List of column name strings.
- Example:
>>> cmap.get_df_columns() ['sequence', 'charge', 'rt', 'mz', 'quality', 'intensity_file1', ...]
- get_intensity_df()#
Generates a pandas DataFrame with feature intensities from each sample in long format (over files).
For labelled analyses channel intensities will be in one row, therefore resulting in a semi-long/block format. Resulting DataFrame can be joined with result from get_metadata_df by their index ‘id’.
Returns: pandas.DataFrame: intensity DataFrame
- get_metadata_df()#
Generates a pandas DataFrame with feature meta data.
Columns: sequence, charge, rt, mz, quality (indexed by ‘id’).
Resulting DataFrame can be joined with result from get_intensity_df by their index ‘id’.
- Returns:
- pandas.DataFrame: DataFrame with metadata for each feature (sequence, charge,
rt, mz, quality). All column names are lowercase snake_case.
- hasInvalidUniqueId(self) int#
Returns whether the unique id is invalid. Returns 1 if the unique id is invalid, 0 otherwise
- hasValidUniqueId(self) int#
Returns whether the unique id is valid. Returns 1 if the unique id is valid, 0 otherwise
- isMetaEmpty(self) bool#
Returns if the MetaInfo is empty
- isValid(self, unique_id: int) bool#
Returns true if the unique_id is valid, false otherwise
- metaRegistry(self) MetaInfoRegistry#
Returns a reference to the MetaInfoRegistry
- metaValueExists(self, in_0: bytes | str | String) bool#
Returns whether an entry with the given name exists
- push_back(self, spec: ConsensusFeature) None#
- removeMetaValue(self, in_0: bytes | str | String) None#
Removes the DataValue corresponding to name if it exists
- reserve(self, s: int) None#
- setColumnHeaders()#
- setDataProcessing(self, in_0: List[DataProcessing]) None#
Sets the description of the applied data processing
- setExperimentType(self, experiment_type: bytes | str | String) None#
Mutable access to the experiment type
- setLoadedFilePath(self, file_name: bytes | str | String) None#
Sets the file_name according to absolute path of the file loaded, preferably done whilst loading
- setLoadedFileType(self, file_name: bytes | str | String) None#
Sets the file_type according to the type of the file loaded from, preferably done whilst loading
- setMetaValue(self, in_0: bytes | str | String, in_1: int | float | bytes | str | List[int] | List[float] | List[bytes]) None#
Sets the DataValue corresponding to a name
- setPrimaryMSRunPath()#
Overload:
- setPrimaryMSRunPath(self, s: List[bytes]) None
Sets the file paths to the primary MS run (stored in ColumnHeaders)
Overload:
- setPrimaryMSRunPath(self, s: List[bytes], e: MSExperiment) None
- setProteinIdentifications(self, in_0: List[ProteinIdentification]) None#
Sets the protein identifications
- setUnassignedPeptideIdentifications(self, unassigned_peptide_identifications: PeptideIdentificationList) None#
Sets the unassigned PeptideIdentificationList
- setUniqueId(self, rhs: int) None#
Assigns a new, valid unique id. Always returns 1
- setUniqueIds()#
- size(self) int#
- sortByIntensity()#
Overload:
- sortByIntensity(self, reverse: bool) None
Sorts the peaks according to ascending intensity.
Overload:
- sortByIntensity(self) None
- sortByMZ(self) None#
Sorts the peaks according to m/z position
- sortByMaps(self) None#
Sorts with respect to the sets of maps covered by the consensus features (lexicographically)
- sortByPosition(self) None#
Lexicographically sorts the peaks by their position (First RT then m/z)
- sortByQuality()#
Overload:
- sortByQuality(self, reverse: bool) None
Sorts the peaks according to ascending quality.
Overload:
- sortByQuality(self) None
- sortByRT(self) None#
Sorts the peaks according to RT position
- sortBySize(self) None#
Sorts with respect to the size (number of elements)
- sortPeptideIdentificationsByMapIndex(self) None#
Sorts PeptideIdentifications of consensus features with respect to their map index.
- updateRanges(self) None#