LC-MS data simulation#

Utilities to simulate LC-MS data.

pydantic model tidyms2.simulation.lcms.RtSpec#

Bases: BaseModel

Define the retention time value in samples.

field mean: pydantic.PositiveFloat = 10.0#

The mean retention time across samples

field std: pydantic.NonNegativeFloat = 0.0#

The retention time standard deviation across samples

field width: pydantic.PositiveFloat = 3.0#

The peak width of the chromatogram

compute_sample_rt()#

Compute an observation of the retention time.

Return type:

float

pydantic model tidyms2.simulation.lcms.SimulatedLCMSAdductSpec#

Bases: BaseChemicalSpeciesSpec

Define a set of isotopologue feature created from an adduct.

field abundance: dict[str, AbundanceSpec] | AbundanceSpec = AbundanceSpec(mean=100.0, std=0.0, prevalence=1.0)#

Define the abundance \(c\) of the chemical species that generates the ion. Multiple abundance specifications may be defined for different sample groups. In this case, the corresponding specification will be selected based on the simulated sample group. If the sample groups is not found a ValueError will be raised.

field formula: str [Required]#

The ion formula. Used as a tidyms.chem.Formula argument.

field n_isotopologues: pydantic.PositiveInt = 1#

The number of isotopologues to simulate.

field noise: MeasurementNoiseSpec = MeasurementNoiseSpec(base_snr=None, min_snr=10.0)#

Defines how the additive noise \(epsilon\) is computed

field response: InstrumentResponseSpec = InstrumentResponseSpec(base_response_factor=1.0, max_sensitivity_loss=0.0, sensitivity_decay=0.0, interbatch_variation=1.0)#

Define how the response factor \(f\) is computed

field rt: RtSpec = RtSpec(mean=10.0, std=0.0, width=3.0)#

The adduct retention time specification

compute_abundance(group=None)#

Compute a realization of the species abundance in the specified group.

Parameters:

group (str | None) – the group name if multiple groups where provided for the abundance specification. If not provided a default group is chosen.

Raises:

ValueError – if the group is not found in the specification

Return type:

float

compute_intensity(group=None, order=0, batch=0)#

Compute a realization of features intensity all isotopologues.

Return type:

list[float]

create_simulated_features(group=None, order=0)#

Create a list of simulated features used by a simulated sample.

Return type:

list[SimulatedLCMSFeature]

get_mz()#

Compute the m/z of features in the adduct.

Return type:

list[float]

class tidyms2.simulation.lcms.SimulatedLCMSDataReader(src)#

Bases: object

Read simulated LC-MS data files.

get_chromatogram(index)#

Retrieve a chromatogram from file.

Return type:

Chromatogram

get_n_chromatograms()#

Retrieve the total number of chromatograms.

Return type:

int

get_n_spectra()#

Retrieve the total number of spectra.

Return type:

int

get_spectrum(index)#

Retrieve a spectrum from file.

Return type:

MSSpectrum

pydantic model tidyms2.simulation.lcms.SimulatedLCMSFeature#

Bases: BaseModel

Store a simulated LC-MS peak information.

field int: pydantic.NonNegativeFloat [Required]#

the feature intensity.

field mz: pydantic.PositiveFloat [Required]#

The feature m/z.

field rt: pydantic.PositiveFloat [Required]#

The feature retention time.

field width: pydantic.PositiveFloat [Required]#

The peak width in the time domain

pydantic model tidyms2.simulation.lcms.SimulatedLCMSSample#

Bases: BaseModel

Create simulated LC-MS data files.

field config: DataAcquisitionSpec [Required]#

The sample configuration used to simulate data.

field features: list[SimulatedLCMSFeature] = []#

the list of features in the sample.

make_grid()#

Create a grid from features m/z values.

Return type:

ndarray[tuple[Any, ...], dtype[TypeVar(FloatDtype, bound= floating)]]

pydantic model tidyms2.simulation.lcms.SimulatedLCMSSampleFactory#

Bases: BaseModel

Utility that creates simulated data samples.

Refer to the Simulating data guide for a tutorial on how to use this class.

field adducts: list[SimulatedLCMSAdductSpec] = []#

the list of adducts to include in the simulated sample.

field data_acquisition: DataAcquisitionSpec = DataAcquisitionSpec(grid=None, mz_std=0.0, int_std=0.0, mz_width=0.005, n_scans=100, time_resolution=1.0, min_int=None, ms_level=1)#

The sample configuration used to simulate data.

create_features(group=None, order=0)#

Create the list of features in a sample using the spec.

Return type:

list[SimulatedLCMSFeature]

create_simulated_sample_spec(group=None, order=0)#

Create a simulated sample specification.

Return type:

SimulatedLCMSSample

tidyms2.simulation.lcms.simulate_data_matrix(specs, samples)#

Create a data matrix using LC-MS simulation specs.

Refer to the Data matrix simulation guide for a tutorial on how to use this function.

Parameters:
  • specs (list[SimulatedLCMSAdductSpec]) – a list of adduct specifications to simulate features.

  • samples (list[Sample]) – the list of samples to include in the matrix.

Return type:

DataMatrix

Returns:

the simulated data matrix