mantispy.tl.dose_direction#
- mantispy.tl.dose_direction(adata, compound_key='Metadata_Compound', dose_key='Metadata_Concentration', reference='negcon', split_by='Metadata_Plate', min_doses=4, count_key='Metadata_CellCount', site_key='Metadata_SiteCount', min_viability=0.5, reproducible=0.5, key_added='dose_direction', copy=False)#
Whether a compound’s phenotype only grows with concentration, or turns into a different one.
A dose series is usually summarised by one number per concentration, how far the wells sit from the controls. That number cannot tell a phenotype that is getting louder from a phenotype that is being replaced. This reads the direction as well as the distance: each concentration gets an
amplitude, itscosine_to_topagainst the highest concentration’s profile, and asplit_half_cosinethat says whether its direction reproduces across replicates at all.The three read together. A concentration whose
split_half_cosineis near zero has no direction to speak of, only noise, however large its amplitude. One that reproduces but sits at a lowcosine_to_topis a real phenotype, and a different one from the top concentration’s.phaseturns that reading into a label, so the stretch of the ladder worth analysing can be subset out rather than described. A concentration issilentwhile nothing reproducible is happening,respondingwhile the profile is still moving from the concentration below it,saturatedonce it has stopped, andcytotoxiconce the cells are gone and the profile is the morphology of dying cells. The label is broadcast toobs, soadata[adata.obs["dose_direction_phase"] == "responding"]is the window, anddose_features(),differential_features()and the rest work on it unchanged.- Parameters:
adata (
AnnData) – Object carrying a compound and a dose per row, at well resolution.compound_key (
str(default:'Metadata_Compound')) –obscolumn holding the compound identity.dose_key (
str(default:'Metadata_Concentration')) –obscolumn holding the concentration. Rows with a zero or missing dose are left out.reference (
str|None(default:'negcon')) – Rows that set each feature’s baseline and spread."negcon"readsMetadata_Control.split_by (
str|None(default:'Metadata_Plate')) –obscolumn whose levels split the replicates in two forsplit_half_cosine, normally the plate. It also lays out the control groupsamplitude_nullis drawn from.None, or a column with one level, splits the wells by position instead.min_doses (
int(default:4)) – Distinct doses below which a compound is left out of the table. One concentration says nothing about how a response changes with concentration.count_key (
str(default:'Metadata_CellCount')) –obscolumn holding the cell count, which setsviability. Without it no concentration is marked cytotoxic.site_key (
str|None(default:'Metadata_SiteCount')) –obscolumn holding the number of fields that count covers, so a well missing a field does not read as cell loss.Nonecompares the counts as they are.min_viability (
float(default:0.5)) – Fraction of its own plate’s control cell count below which a concentration iscytotoxic. The US EPA’s phenotypic pipeline drops a concentration that has lost more than half its cells before fitting anything.reproducible (
float|None(default:0.5)) –split_half_cosinea concentration needs before it can be anything butsilent.Nonedrops the requirement, which is what a screen with one well per concentration has to do, at the cost of calling noise a phenotype.key_added (
str(default:'dose_direction')) – Name for the output table.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. Writesuns["mantispy"][key_added], one row per compound and concentration, withcompound,dose,n_wells,amplitude,amplitude_null,step_amplitude,split_half_cosine,cosine_to_top,viabilityandphase. The phase is broadcast toobs[key_added + "_phase"]so the window can be subset like any other annotation.amplitudeis the root-mean-square response over the features, in MADs of the controls, andamplitude_nullis what control wells spread over the same plates in the same numbers reach, so the two are read against each other.step_amplitudeis the same measure applied to the change from the concentration below, which is what tells a response that is still moving from one that has arrived.phaseis one ofDOSE_PHASES.- Raises:
KeyError –
obshas nocompound_key, nodose_key, or nosplit_bycolumn.ValueError – Fewer than two reference rows, so there is no scale to read a direction in.
Notes
The cosines are taken over the features scaled by the controls’ spread, so a feature the controls happen to measure loosely does not set the direction on its own. Features whose controls show no spread are left out.
amplitude_nullis the median over twenty-five draws, and is NaN when the controls cannot fill the layout, for instance when a plate carries treated wells but no vehicle.split_half_cosineneeds at least two wells at a concentration, and reproduces the plate structure whensplit_bynames it: halving by plate answers whether the direction survives a different plate, which is the harder and more useful question. With one well per concentration it is NaN, and the table then says nothing about whether any single concentration’s direction is real.