mantispy.pp.correct_plate_position#
- mantispy.pp.correct_plate_position(adata, method='b_score', by='Metadata_Plate', reference=None, plates=None, max_iter=10, tol=0.0001, key_added=None, copy=False)[source]#
Remove row and column position effects, per plate and per feature.
Both methods fit the row and column effects with Tukey’s two-way median polish, which is robust to a few extreme wells.
- Parameters:
adata (
AnnData) – Object to correct, at cell or well resolution.method (
str(default:'b_score')) –"b_score"(default) is the B-score of Brideau et al. [2003]: the median-polish residual, divided by the plate’s median absolute deviation, so each feature becomes a robust, position-corrected z-score per plate."median_polish"subtracts the row and column effects only, keeping each feature’s original level and units. The B-score is the screening standard for calling hits against a positional gradient; it also re-scales each plate, so it doubles as a normalization and should not be followed by a second per-plate scaling.by (
str(default:'Metadata_Plate')) – Column identifying the plate.reference (
str|None(default:None)) – Fit the row and column effects on these rows only."negcon"is the usual choice, so that treatments laid out in particular columns are not absorbed into a column effect.Nonefits on every well.plates (
Sequence[object] |None(default:None)) – Correct only thesebyvalues and leave every other plate untouched.Nonecorrects every plate. Pair it withdetect_plate_position()to correct only the plates whose artifact is learnable.max_iter (
int(default:10)) – Maximum number of median-polish iterations.tol (
float(default:0.0001)) – Convergence tolerance of the median polish.key_added (
str|None(default:None)) – Write tolayers[key_added]instead of overwritingX.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. WritesXorlayers[key_added], and the fitted effects per corrected plate touns["mantispy"]["plate_position"].- Raises:
ValueError – If
methodis unknown, a corrected plate holds no reference rows, orplatesnames a value absent fromby.
Notes
The polish is fitted on the well grid. At cell resolution each well is first reduced to its median, and the fit is then applied to every cell of that well. The B-score’s level and scale are taken from the fitted wells, so with a
referencethey are the reference wells’ median and spread. That scale is a per-well statistic; at cell resolution the per-cell B-score is therefore standardized only on average, not to an exact unit MAD.