Skip to main content

Batch corrector plugin for TidyMS2.

Project description

TidyMS2 Batch corrector

A batch corrector plugin for TidyMS2.

Installation

pip install tidyms2-batch-corrector

Usage

This TidyMS2 plugin implements the BatchCorrector, a matrix operator that corrects time-dependent effects on data. It implements the correction described here.

The BatchCorrector can be tuned to fit your experimental design and desired data quality:

  • first_n_qc: Controls how many QC samples are used to estimate the intra-batch mean. Use a small value (e.g 1-3) if early QC samples best represent unbiased instrument response.
  • frac: Sets the LOESS smoothing parameter. If not specified, an optimal value is estimated for each feature. You can set a fixed value to control the degree of smoothing.
  • threshold: Sets the minimum intensity for QC samples to be considered in the correction. Increase this value to ignore low-quality or noisy reference measurements.
  • target_groups and ref_groups: Specify which sample groups are corrected and which are used as references. By default, experimental samples and technical QCs are used.
  • max_workers: Controls parallelism for batch correction, useful for large datasets.

Import it and use it as a regular matrix operator:

from tidyms2_batch_corrector import BatchCorrector

bc = BatchCorrector(max_workers=4)
bc.apply(matrix)

Below is a minimal example of how to use the BatchCorrector with simulated data:

from tidyms2.core.enums import SampleType
from tidyms2.core.operators.pipeline import Pipeline
from tidyms2.simulation.base import InstrumentResponseSpec
from tidyms2.simulation.lcms import SimulatedLCMSAdductSpec, simulate_data_matrix
from tidyms2.simulation.utils import create_sample_list

from tidyms2_batch_corrector import BatchCorrector

def create_example_matrix():
	"""Create a data matrix with time-dependent variation effects."""
	sample_types = [
		SampleType.TECHNICAL_QC,
		SampleType.SAMPLE,
		SampleType.TECHNICAL_QC,
		SampleType.SAMPLE,
		SampleType.TECHNICAL_QC,
		SampleType.SAMPLE,
		SampleType.TECHNICAL_QC,
	]
	samples = create_sample_list(sample_types, n_batches=3)
	adducts = [
		SimulatedLCMSAdductSpec(
			formula="[C10H20O4]+",
			n_isotopologues=1,
			response=InstrumentResponseSpec(max_sensitivity_loss=0.5, sensitivity_decay=0.25),
		)
	]
	return simulate_data_matrix(adducts, samples)

matrix = create_example_matrix()
matrix.check_status()
pipe = Pipeline("matrix_pipe")
bc = BatchCorrector(id="test-corrector", first_n_qc=1)
pipe.add_operator(bc)
pipe.apply(matrix)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tidyms2_batch_corrector-0.1.0.tar.gz (75.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tidyms2_batch_corrector-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file tidyms2_batch_corrector-0.1.0.tar.gz.

File metadata

  • Download URL: tidyms2_batch_corrector-0.1.0.tar.gz
  • Upload date:
  • Size: 75.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tidyms2_batch_corrector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63d9ec64020b157b577d492a89bc4a1f98a344e21ebdfff9b72402b638a9c959
MD5 a4b7c1a8eefd3055b6e448758c984a91
BLAKE2b-256 ba62a973e3a8d3e5e3d5551cc18b2aba6d863687c2ae377dcb020c6e16017036

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidyms2_batch_corrector-0.1.0.tar.gz:

Publisher: publish.yaml on griquelme/tidyms2-batch-corrector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tidyms2_batch_corrector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tidyms2_batch_corrector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cfc46bcaa63c04df3c3b1ae2ded0dc4f650c363c7cd7b055b26faac0d0f1548
MD5 6ec7ac6407e6fad2424a345cca1ac029
BLAKE2b-256 d4222ec717a5af5f3c8c8c6f3cd1984684e1cc77806291caeea529bccf7b2156

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidyms2_batch_corrector-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on griquelme/tidyms2-batch-corrector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page