ecotyper.recovery_steps¶
Cell state and ecotype recovery (pipeline/state_recovery_*.R,
ecotypes_recovery*.R, spatial_states.R, spatial_ecotypes.R).
All functions take and return pandas objects laid out like the R objects
(genes x samples matrices, data frames with an ID column) so every
intermediate file of the R pipeline can be reproduced. r_exact=True
reproduces the places where the R pipeline writes a table with 15
significant digits and the next script reads it back, which is necessary for
bit-identical results downstream.
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
Recover the cell states of one cell type ( |
|
|
|
|
Classes
|
|
|
- ecotyper.recovery_steps.prepare_bulk_expression(expr)[source]¶
data[is.na(data)] = 0; log2(x + 1) if all values >= 0 and max > 50.
- ecotyper.recovery_steps.align_rows(expr, genes)[source]¶
data[match(genes, rownames(data)), ]; rownames = genes; NA -> 0.
- ecotyper.recovery_steps.read_clinical(sample_list, annotation)[source]¶
read_clinical(lib/misc.R): annotation rows matched to the samples.
- class ecotyper.recovery_steps.StateRecovery(cell_type: 'str', expression: 'pd.DataFrame', scaled: 'pd.DataFrame', H: 'pd.DataFrame', initial_abundances: 'pd.DataFrame', initial_assignment: 'pd.DataFrame', abundances: 'pd.DataFrame', assignment: 'pd.DataFrame', niter: 'int', annotation: 'pd.DataFrame | None' = None, heatmap_data: 'pd.DataFrame | None' = None, heatmap_top_ann: 'pd.DataFrame | None' = None, extra: 'dict' = <factory>)[source]¶
Bases:
object- Parameters:
cell_type (str)
expression (DataFrame)
scaled (DataFrame)
H (DataFrame)
initial_abundances (DataFrame)
initial_assignment (DataFrame)
abundances (DataFrame)
assignment (DataFrame)
niter (int)
annotation (DataFrame | None)
heatmap_data (DataFrame | None)
heatmap_top_ann (DataFrame | None)
extra (dict)
- ecotyper.recovery_steps.recover_states(expr, ct, rng, annotation=None, *, kind='bulk', exact=True, threads=1)[source]¶
Recover the cell states of one cell type (
state_recovery_{bulk,visium,scRNA}.R).expris the genes x samples matrix after the dataset-level preparation (NA -> 0 and optional log2 for bulk/Visium viaprepare_bulk_expression(); per-cell-type log2 for scRNA).rngis consumed exactly as R consumes its RNG (onernmfdraw).exact=Falseruns NMFpredict with BLAS updates (seeecotyper.nmf.run_brunet()).annotationis the result ofread_clinical()(bulk/Visium) or the cell annotation (scRNA).- Parameters:
- Return type:
- ecotyper.recovery_steps.average_fc_marker_genes(data, gene_info, assignment)[source]¶
averge_FC_marker_genes(lib/ecotyper.R).
- class ecotyper.recovery_steps.EcotypeRecovery(combined_state_abundances: 'pd.DataFrame', ecotype_abundance: 'pd.DataFrame', assignment_p_vals: 'pd.DataFrame', initial_assignment: 'pd.DataFrame', assignment: 'pd.DataFrame', ecotypes: 'pd.DataFrame')[source]¶
Bases:
object- Parameters:
- ecotyper.recovery_steps.recover_ecotypes(state_results, model_ecotypes, cell_types, annotation, *, r_exact=True)[source]¶
ecotypes_recovery.R(bulk).state_results: cell type -> StateRecovery.
- ecotyper.recovery_steps.recover_ecotypes_scrna(state_results, model, cell_annotation, top_cols=('Ecotype',))[source]¶
ecotypes_recovery_scRNA.R: ecotype abundance per sample (columnSampleof the cell annotation) from per-cell initial state assignments.- Parameters:
- Return type: