trommel
This is a collection of clean-up functions and small pipelines for morphological profiling.
A trommel is a revolving cylindrical sieve used for screening or sizing rock and ore, it helps separate the minerals from the waste. This tool aims to fulfill the same purpose for morphological profiling, and possibly many other high-throughput datasets.
Quick Start
import polars as pl
import polars.selectors as cs
from trommel.core import basic_cleanup
meta_selector = cs.by_dtype(pl.String)
profiles = pl.scan_parquet("https://cellpainting-gallery.s3.amazonaws.com/cpg0016-jump-assembled/source_all/workspace/profiles_assembled/CRISPR/v1.0a/profiles.parquet", n_rows=100).collect()
"""
shape: (100, 3_677)
┌─────────────────┬────────────────┬───────────────┬───┬─────────────────┬─────────────────┬────────────────┐
│ Metadata_Source ┆ Metadata_Plate ┆ Metadata_Well ┆ … ┆ Nuclei_Texture_ ┆ Nuclei_Texture_ ┆ Nuclei_Texture │
│ --- ┆ --- ┆ --- ┆ ┆ Variance_RNA_5_ ┆ Variance_RNA_5_ ┆ _Variance_RNA_ │
│ str ┆ str ┆ str ┆ ┆ … ┆ … ┆ 5_… │
│ ┆ ┆ ┆ ┆ --- ┆ --- ┆ --- │
│ ┆ ┆ ┆ ┆ f32 ┆ f32 ┆ f32 │
╞═════════════════╪════════════════╪═══════════════╪═══╪═════════════════╪═════════════════╪════════════════╡
│ source_13 ┆ CP-CC9-R1-01 ┆ A02 ┆ … ┆ 6.449576 ┆ 6.233986 ┆ 6.447817 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A03 ┆ … ┆ 7.359348 ┆ 7.119856 ┆ 7.359909 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A04 ┆ … ┆ 9.2922 ┆ 8.964124 ┆ 9.255968 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A05 ┆ … ┆ 8.243299 ┆ 7.974916 ┆ 8.25239 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A06 ┆ … ┆ 10.728938 ┆ 10.346541 ┆ 10.691082 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ source_13 ┆ CP-CC9-R1-01 ┆ E10 ┆ … ┆ 6.414464 ┆ 6.199627 ┆ 6.40822 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E11 ┆ … ┆ 5.445997 ┆ 5.277493 ┆ 5.447682 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E12 ┆ … ┆ 5.501099 ┆ 5.344191 ┆ 5.507084 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E13 ┆ … ┆ 7.312291 ┆ 7.087072 ┆ 7.332959 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E14 ┆ … ┆ 6.326293 ┆ 6.127594 ┆ 6.340693 │
└─────────────────┴────────────────┴───────────────┴───┴─────────────────┴─────────────────┴────────────────┘
"""
# the second argument is a dictionary indicating how many samples or columns were dropped at each step
preprocessed, _ = basic_cleanup(profiles, meta_selector = meta_selector)
preprocessed
"""
shape: (100, 554)
┌─────────────────┬────────────────┬───────────────┬───┬─────────────────┬─────────────────┬────────────────┐
│ Metadata_Source ┆ Metadata_Plate ┆ Metadata_Well ┆ … ┆ Nuclei_Texture_ ┆ Nuclei_Texture_ ┆ Nuclei_Texture │
│ --- ┆ --- ┆ --- ┆ ┆ SumAverage_ER_3 ┆ SumVariance_DNA ┆ _SumVariance_M │
│ str ┆ str ┆ str ┆ ┆ … ┆ … ┆ it… │
│ ┆ ┆ ┆ ┆ --- ┆ --- ┆ --- │
│ ┆ ┆ ┆ ┆ f32 ┆ f32 ┆ f32 │
╞═════════════════╪════════════════╪═══════════════╪═══╪═════════════════╪═════════════════╪════════════════╡
│ source_13 ┆ CP-CC9-R1-01 ┆ A02 ┆ … ┆ -0.577417 ┆ -0.138683 ┆ 17.711971 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A03 ┆ … ┆ 0.259718 ┆ -0.028451 ┆ 7.942208 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A04 ┆ … ┆ 0.682264 ┆ -0.001948 ┆ 3.534184 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A05 ┆ … ┆ 0.305402 ┆ -0.032553 ┆ 5.978285 │
│ source_13 ┆ CP-CC9-R1-01 ┆ A06 ┆ … ┆ 0.932589 ┆ 0.086287 ┆ 14.690929 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ source_13 ┆ CP-CC9-R1-01 ┆ E10 ┆ … ┆ 0.063227 ┆ 0.024047 ┆ -0.151976 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E11 ┆ … ┆ -0.168455 ┆ 0.045889 ┆ -0.012995 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E12 ┆ … ┆ -0.071743 ┆ 0.09979 ┆ -3.231946 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E13 ┆ … ┆ -0.124911 ┆ 0.163038 ┆ 4.087936 │
│ source_13 ┆ CP-CC9-R1-01 ┆ E14 ┆ … ┆ -0.806152 ┆ 0.055316 ┆ -2.082987 │
└─────────────────┴────────────────┴───────────────┴───┴─────────────────┴─────────────────┴────────────────┘
"""
The basic cleanup steps are:
- Remove NaNs
- First, remove rows with more than 50% NaNs.
- Second, remove columns with any NaNs.
- Calculate Robust Mean Average Deviation (following pycytominer's implementation)
- Remove outliers
- Remove redundant (highly correlated) features
Installation
Pip
Aimed towards users of the functions/pipelines.
pip install trommel
Poetry
Predominantly for developers who want to edit the code.
git clone git@github.com:broadinstitute/monorepo.git
cd monorepo/libs/trommel
poetry install
Additional information
Related projects
- pycytominer: The closest match, but with more complexity imbued and many of the math functions are pandas-centric.
- EFAAR: Much simpler implementation, but it commits similar hard-coding of cellprofiler features. We instead try to be agnostic to the way of the selectors, but we do commit to using
polars.
Future features
- Full separation of data + metadata
- Additional processing and clean-up functions
- Additional default pipelines
Metadata
Release files for trommel 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trommel-0.1.7.tar.gz | 5.7 kB | Without provenance | Details for trommel-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trommel-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for trommel-0.1.7-py3-none-any.whl |
Total release size: 11.8 kB
Release files / trommel-0.1.7.tar.gz
| Download URL | trommel-0.1.7.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
478cf851484377239f240be482ae183e8b0fe316a4d9bc20d79c7fc958961b91
|
|
BLAKE2b-256 checksum How to use checksums |
44df1936a632f61e76069d9919046045e4a628794cc4d76a8ed41e7c1a882aeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.30
|
Release files / trommel-0.1.7-py3-none-any.whl
| Download URL | trommel-0.1.7-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ac52484a19a96842d343853efffef218d14972819c40efb4adad780ca96a5cb
|
|
BLAKE2b-256 checksum How to use checksums |
bef761861fa386ea0b1609c23776cbc8fde395c91b99e11d441361afbf145810
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.30
|
Security for trommel 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.