mmc.threshold()
- mmochi.thresholding.threshold(markname, adata, data_key=utils.DATA_KEY, preset_threshold=None, include_zeroes=False, n=0, force_model=False, plot=True, title_addition='', interactive=True, fancy=False, run=False, bins=100, external_holdout=False, key_added='lin')
Performs thresholding for marker, displays expression distribution (colored by “pos”, “?”, and “neg”) for visualization and interactive adjustment, and optionally returns thresholds and thresholded events. Thresholded events are returned as a list of “pos” for positive (at or above the higher threshold), “neg” for negative (at or below the lower threshold), and “?” for undefined (between the two thresholds). Uses utils.get_data() to identify the data to threshold.
- Parameters:
markname (
str) – Name of the marker being used. Markers can also have “_lo” or “_hi” appended to them to specify multiple thresholds on the same marker at the same level.adata (
AnnData) – AnnData object for creating thresholds, containing expression in the .X and/or the .obsm[data_key].data_key (
Union[str,list,None] (default:utils.DATA_KEY)) – Name of the key in .obsm or .var[utils.MODALITY_COLUMN] to look for when searching for markname. See utils.get_data for details on how searching is performed.present_threshold – Max and minimum thresholds to apply for positive and negative populations, overrides automated calculation
included_zeroes – Whether to include zeroe expression values when calculating the Gaussian mixture model.
n (
int(default:0)) – Determines the number of Gaussians to fit. Can be 1, 2, or 3.force_model (
bool(default:False)) – Whether to force the creation of a Gaussian mixture model. If preset thresholds are defined, this model is only used to create msw.plot (
bool(default:True)) – Whether to display histograms of expression distribution with Gaussian mixes overlayed.title_addition (
str(default:'')) – Other information you would like to include in the title after the marker nameinteractive (
bool(default:True)) – Whether to prompt the user to enter thresholds (uses defaults if invalid entry)fancy (
bool(default:False)) – Whether to create adjustable float sliders to enter thresholds. Returns a list of float sliders. This should only be used by the run_all_thresholds command.run (
bool(default:False)) – Whether to run the thresholding to return thresholded databins (
int(default:100)) – The number of bins to plot in the histogramexternal_holdout (
bool(default:False)) – If external hold out was defined in adata.obsm[key_added], removes external hold out from threshold calculations and from graphs used for manual thresholdingkey_added (
str(default:'lin')) – If external_holdout is true, the place in adata.obsm[key_added] to search for the external hold out column (bool T F column used to indicate whether an event should be set aside for hold out)
- Return type:
Union[Tuple[float,float],Tuple[Tuple[float,float],List[str]]]- Returns:
thresh – Threshold values (numerics)
thresholded – if run == true returns thresholded data index aligned to thresh, with values of “pos”, “neg”, and “?”.