grassp.tl.ccompass#
- ccompass(data, marker_key='markers', *, condition_key=None, replicate_key=None, layer=None, scale=True, nn_params=None, reliability=None, key_added='ccompass', max_processes=1, aggregate=True, set_colors=True, inplace=True)[source]#
Predict compartment class contributions with the C-COMPASS neural network.
Converts
datainto the profile dictionaries expected by C-COMPASS, trains its multi-organelle network (per condition x replicate, ensembled overroundsxsubrounds), and – whenaggregateisTrue– runs C-COMPASS’sstats_proteome()to obtain reliability-filtered class contributions. Results are written intodatafollowing the same conventions ascompetitive_propagation().- Parameters:
- data
AnnData AnnDatawith proteins in.obsand fractions in.var..X(orlayers[layer]) holds the fractionation profiles.- marker_key
str(default:'markers') .obscolumn with known compartment labels (e.g. added bygrassp.pp.add_markers()).NaNentries are treated as unlabeled proteins to be predicted.- condition_key
str|None(default:None) Optional
.varcolumns identifying biological condition and replicate. Whenreplicate_keyis given, each replicate is trained as an independent network and averaged afterwards (C-COMPASS’s"separate"combination mode). When omitted, all samples are treated as a single condition/replicate.- replicate_key
str|None(default:None) Optional
.varcolumns identifying biological condition and replicate. Whenreplicate_keyis given, each replicate is trained as an independent network and averaged afterwards (C-COMPASS’s"separate"combination mode). When omitted, all samples are treated as a single condition/replicate.- layer
str|None(default:None) Layer to use as the profile matrix.
Noneuses.X.- scale
bool(default:True) If
True(default), min-max scale each protein profile to[0, 1]across fractions, reproducing C-COMPASS’s per-profile normalization. Disable if the profiles are already normalized.- nn_params
Any(default:None) Neural-network / training / fCC hyperparameters. One of:
None(grassp defaults), adictof overrides, a path to a YAML/JSON parameter file (the same pydantic serialization C-COMPASS uses for its own settings/session files), or a fully-builtccompass.core.NeuralNetworkParametersModel. Every C-COMPASS hyperparameter is settable this way (upsampling,svm_filter,mixed_part,NN_epochs,rounds,subrounds,reliability, …). ForNone/dict/file inputs the first-hidden-layer search defaults toNN_optimization="short"(matching the C-COMPASS paper) unless you set it explicitly; a fully-built model is used exactly as given. The resolved hyperparameters are recorded inadata.uns[f"{key_added}_nn_params"]. Callccompass_default_params()to inspect every field and its default, or to write an editable YAML template.- reliability
int|None(default:None) Percentile (0-100) for the false-positive filter that produces
fCC/fNN_winner. Overridesnn_params.reliabilitywhen given.- key_added
str(default:'ccompass') Prefix for the result slots (default
"ccompass"). With more than one condition, the condition name is appended ("{key_added}_{condition}").- max_processes
int(default:1) Number of worker processes for C-COMPASS (one per condition x round).
- aggregate
bool(default:True) If
True(default), reconcile rounds/replicates viastats_proteome()and write both raw (CC) and reliability-filtered (fCC) contributions. IfFalse, only average the raw per-round network outputs.- set_colors
bool(default:True) If
True, assign compartment colors to the new.obslabel columns viagrassp.pp.set_sensible_compartment_colors().- inplace
bool(default:True) If
True(default) write intodataand returnNone; otherwise return the C-COMPASSclass_predictionsdictionary.
- data
- Returns:
Modified
data(in place) with, per conditionsuffix(""for a single condition, else"_{condition}"):.obsm[f"{key_added}{suffix}_contributions"]– proteins x compartments class-contribution matrix (rows sum to ~1)..uns[f"{key_added}{suffix}_categories"]– ordered compartment names..obs[f"{key_added}{suffix}"]– winning compartment (argmax,NN_winner).When
aggregate:.obsm[f"{key_added}{suffix}_fcontributions"]and.obs[f"{key_added}{suffix}_fwinner"]– reliability-filtered outputs.
Notes
C-COMPASS distinguishes genuine multi-localization from measurement noise by training on synthetic mixtures of marker profiles, ensembling over many training rounds, and thresholding each contribution against the values that markers of other compartments receive (the
reliabilitypercentile). This differs from grassp’s native permutation-null approach inresolve_soft_labels(), so results are complementary rather than identical.