ecotyper.discovery_steps¶
Cell state and ecotype discovery from purified (CIBERSORTx HiRes) or
presorted profiles: state_discovery_*.R, ecotypes.R,
ecotypes_assign_samples.R (bulk and presorted discovery wrappers).
Each R script becomes one function; values that R writes to a text file and
the next script reads back are passed through _rt() (r_exact) so the
port sees exactly the numbers R sees.
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Classes
|
|
|
|
|
|
|
- ecotyper.discovery_steps.log_transform(X)[source]¶
log2(x)if min >= 1,log2(x + 1)if min >= 0, else unchanged.
- ecotyper.discovery_steps.get_variable_genes(log_data)[source]¶
get_variable_genes(lib/misc.R): top 1000 genes by normalised dispersion within mean-expression bins, ordered by decreasing dispersion.
- ecotyper.discovery_steps.scale_data(data, by=None)[source]¶
scale_data(lib/misc.R): row z-scores within groups of samples.Note: the R pipeline passes the name of the annotation column (a single string) as
by, so every sample falls in the same group; pass a scalar to reproduce that, or one label per sample for true within-group scaling.
- class ecotyper.discovery_steps.Features(cell_type: 'str', log_data: 'pd.DataFrame', top_log2: 'pd.DataFrame', top_scaled: 'pd.DataFrame', full_scaled: 'pd.DataFrame')[source]¶
Bases:
object- Parameters:
- ecotyper.discovery_steps.extract_features(raw_input, cell_type, annotation=None, scale_column=None, specific_genes=None)[source]¶
state_discovery_extract_features.R.raw_input: genes x samples (read.delim(..., row.names = 1)). Returns None when fewer than 50 genes.
- ecotyper.discovery_steps.nmf_input(top_scaled, r_exact=True)[source]¶
posneg(as.matrix(read.delim("expression_top_genes_scaled.txt"))).
- ecotyper.discovery_steps.run_nmf(V, rank, restart, exact=True, method='brunet')[source]¶
state_discovery_NMF.R:nmf(V, rank, "brunet", seed = 1234 + restart).method="cd": the alternative solverecotyper.nmf.nmf_cd()(not R-equivalent).
- ecotyper.discovery_steps.rank_metrics(fits, rank)[source]¶
state_discovery_combine_NMF_restarts.Rfor one rank → (merged, metrics dict).
- ecotyper.discovery_steps.select_ranks(rank_tables, max_n_clusters, min_cophenetic, r_exact=True)[source]¶
state_discovery_rank_selection.R.rank_tables: cell type → DataFrame with one row per rank (columns as rank_data.txt).
- ecotyper.discovery_steps.get_fc_for_clusters(data, variable)[source]¶
get_FC_for_clusters(lib/misc.R).
- class ecotyper.discovery_steps.InitialStates(cell_type: 'str', rank: 'int', W: 'pd.DataFrame', H: 'pd.DataFrame', initial_abundances: 'pd.DataFrame', initial_assignment: 'pd.DataFrame', initial_gene_info: 'pd.DataFrame')[source]¶
Bases:
object- Parameters:
- ecotyper.discovery_steps.initial_states(merged, top_scaled, cell_type, rank, r_exact=True, gene_info=True)[source]¶
state_discovery_initial_plots.R(gene_info=False: the scRNA cross-correlation variant, which does not compute marker genes).- Parameters:
- Return type:
- class ecotyper.discovery_steps.States(cell_type: 'str', rank: 'int', first_filter_data: 'pd.DataFrame', mapping: 'pd.DataFrame', state_abundances: 'pd.DataFrame', state_assignment: 'pd.DataFrame', heatmap_top_ann: 'pd.DataFrame', gene_info: 'pd.DataFrame', heatmap_data: 'pd.DataFrame', log: 'list' = <factory>)[source]¶
Bases:
object- Parameters:
- ecotyper.discovery_steps.first_filter(init, feats, annotation, r_exact=True, csx_filter=True)[source]¶
state_discovery_first_filter.R(csx_filter=False:state_discovery_first_filter_scRNA.R, without the filter on genes whose imputed values are mostly identical).- Parameters:
init (InitialStates)
feats (Features)
annotation (DataFrame | None)
csx_filter (bool)
- Return type:
- class ecotyper.discovery_steps.Ecotypes(mapping_all_states: 'pd.DataFrame', binary: 'pd.DataFrame', jaccard: 'pd.DataFrame', silhouette_initial: 'float', initial_ecotypes: 'pd.DataFrame', ecotypes: 'pd.DataFrame', silhouette: 'float', n_clusters: 'int')[source]¶
Bases:
object- Parameters: