memo_ms package
- class memo_ms.FeatureTable(path: str, software: str)[source]
Bases:
object
Create a FeatureTable dataclass object from a feature table
- Args:
path (str): Path to a feature table file (.csv) software (str): One of [mzmine, xcms, msdial, memo]: the software used for feature detection.
- Returns:
self.feature_table (DataFrame): A cleaned feature quantification table
- export_matrix(path, sep=',')[source]
Export a given matrix
- Args:
path (str): path to export sep (str): separator
- Returns:
None
- filter(samples_pattern, max_occurence=None)[source]
Filter a feature table: remove samples matching samples_pattern AND remove features occuring in more than n = max_occurence samples matched by samples_pattern
- Args:
samples_pattern (str): the str pattern to match in samples to filter max_occurence (int): maximal number of occurence allowed in matched samples before removing a feature/word
- Returns:
self.filtered_feature_table (DataFrame): A filtered feature table
- class memo_ms.MemoMatrix[source]
Bases:
object
Create an empty MemoMatrix dataclass object
- export_matrix(path, sep=',')[source]
Export a given matrix
- Args:
path (str): path to export sep (str): separator
- Returns:
None
- filter(samples_pattern, max_occurence=None)[source]
Filter a MEMO matrix: remove samples matching samples_pattern AND remove features occuring in more than n = max_occurence samples matched by samples_pattern
- Args:
samples_pattern (str): the str pattern to match in samples to filter max_occurence (int): maximal number of occurence allowed in matched samples before removing a feature/word
- Returns:
self.memo_matrix (DataFrame): A filtered feature table matrix
- memo_from_aligned_samples(featuretable, spectradocuments) pandas.core.frame.DataFrame [source]
Use a featuretable and a spectradocuments to generate a MEMO matrix. Returns a pd.DataFrame MEMO matrix.
- Args:
featuretable (FeatureTable): a FeatureTable dataclass object spectradocuments (SpectraDocuments): a SpectraDocuments dataclass oject
- Returns:
self.memo_matrix (DataFrame): A MEMO matrix
- memo_from_unaligned_samples(path_to_samples_dir, min_relative_intensity=0.01, max_relative_intensity=1.0, min_peaks_required=10, losses_from=10, losses_to=200, n_decimals=2)[source]
Generate a Memo matrix from a list of individual .mgf files
- Args:
path_to_samples_dir (str): Path to the directory where individual .mgf files are gathered min_relative_intensity (float): Minimal relative intensity to keep a peak max_relative_intensity (float): Maximal relative intensity to keep a peak min_peaks_required (int): Minimum number of peaks to keep a spectrum losses_from (int): minimal m/z value for losses losses_to (int): maximal m/z value for losses n_decimals (int): number of decimal when translating peaks/losses into words
- Returns:
self.memo_matrix (DataFrame): A MEMO matrix
- merge_memo(memomatrix_2, drop_not_in_common=False)[source]
Merge 2 MEMO matrix
- Args:
memocontainer2 (MemoContainer): MemoMatrix dataclass object containing the 2nd MEMO matrix to merge drop_not_in_common (bool): Drop peaks/losses not in common
- Returns:
MemoContainer (MemoContainer): A MemoMatrix dataclass object containing the merged MEMO matrix
- class memo_ms.SpectraDocuments(path: str, min_relative_intensity: float = 0.01, max_relative_intensity: float = 1.0, min_peaks_required: int = 10, losses_from: int = 10, losses_to: int = 200, n_decimals: int = 2)[source]
Bases:
object
Create a SpectraDocuments dataclass object containing spectra documents and metadata from an MzMine 2 spectra file (.mgf)
- Args:
path (str): Path to spectra file (.mgf) min_relative_intensity (float): Minimal relative intensity to keep a peak max_relative_intensity (float): Maximal relative intensity to keep a peak min_peaks_required (int): Minimum number of peaks to keep a spectrum losses_from (int): minimal m/z value for losses losses_to (int): maximal m/z value for losses n_decimals (int): number of decimal when translating peaks/losses into words
- Returns:
self.document (DataFrame): A table containing spectra documents and metadata