unravel.allen_institute.abca.scRNA_seq.expression_summary module#

Use abca_scRNAseq_expression_summary or rna_exp_summary from UNRAVEL to summarize log2(CPM+1) expression across every level of the ABCA cell-type ontology.

The input should be a CSV produced by abca_scRNAseq_expression / rna_exp with ABCA cell-type annotations and one or more gene-expression columns.

Mouse hierarchy:

neurotransmitter -> class -> subclass -> supertype -> cluster

Human hierarchy:

neurotransmitter -> supercluster -> cluster -> subcluster

For each gene and cell type, the script calculates:
  • cell_count

  • percent_cells (percentage of cells in the input assigned to the cell type at the given ontology level.)

  • expressing_cell_count

  • mean_expression

  • percent_expression above the selected log2(CPM+1) threshold

Outputs:
  • <input>__LEVEL.csv One wide CSV per ontology level. Identical cell-type labels that occur under different parent ontology paths are combined into one row.

Notes

  • Example of collapsing: if Cell type A occurs under two different neurotransmitter parents, the output contains one Cell type A row combining cells from both parent paths.

  • cell_count counts all rows assigned to a cell type.

  • Mean expression is calculated from non-missing expression values.

  • Percent expression uses non-missing expression values as the denominator.

  • By default, outputs are saved to expression_summary_thr<value> in the input directory.

  • source_path_count is the number of unique ontology paths contributing to a collapsed cell-type row.

  • source_ontology_paths lists those contributing ontology paths.

Genes:
  • Use -g/–genes to summarize selected genes.

  • If -g is omitted, all columns after the last column containing ‘_color’ are assumed to contain gene-expression values.

Species:
  • Species is inferred automatically from the ABCA ontology columns

Usage for mouse:#

rna_exp_summary -i path/expression_data_log2.csv [-g Htr2a Htr2b Drd1 Drd2] [-t 3]

Usage for human:#

rna_exp_summary -i path/expression_data_Neurons_log2.csv [-g HTR2A HTR2B DRD1 DRD2] [-t 3]

Usage for parallel processing:#

fd -e csv -d 1 -j 4 -x rna_exp_summary -i {}

unravel.allen_institute.abca.scRNA_seq.expression_summary.parse_args()[source]#
unravel.allen_institute.abca.scRNA_seq.expression_summary.infer_species(columns)[source]#

Infer species from ABCA ontology columns.

Parameters:

columns (list[str]) –

Return type:

str

unravel.allen_institute.abca.scRNA_seq.expression_summary.infer_genes(columns, requested_genes)[source]#

Return requested genes or infer gene columns from column order.

Parameters:
Return type:

list[str]

unravel.allen_institute.abca.scRNA_seq.expression_summary.format_number(value)[source]#

Format a numeric CLI value for compact file names.

Parameters:

value (float) –

Return type:

str

unravel.allen_institute.abca.scRNA_seq.expression_summary.natural_sort_text(value)[source]#

Return a zero-padded text key for natural sorting without extra dependencies.

Return type:

str

unravel.allen_institute.abca.scRNA_seq.expression_summary.load_expression_data(input_path, species, genes)[source]#

Load required ontology, color, and gene-expression columns.

Parameters:
Return type:

tuple[DataFrame, list[str]]

unravel.allen_institute.abca.scRNA_seq.expression_summary.source_paths_dataframe(cell_df, level, path_columns)[source]#

Summarize unique ontology paths contributing to each cell-type label.

Parameters:
  • cell_df (DataFrame) –

  • level (str) –

  • path_columns (list[str]) –

Return type:

DataFrame

unravel.allen_institute.abca.scRNA_seq.expression_summary.summarize_level(cell_df, input_name, species, genes, threshold, hierarchy_levels, level_index)[source]#

Create one collapsed wide expression summary for an ontology level.

Parameters:
  • cell_df (DataFrame) –

  • input_name (str) –

  • species (str) –

  • genes (list[str]) –

  • threshold (float) –

  • hierarchy_levels (list[str]) –

  • level_index (int) –

Return type:

DataFrame

unravel.allen_institute.abca.scRNA_seq.expression_summary.save_outputs(cell_df, input_name, output_dir, output_prefix, species, genes, threshold, hierarchy_levels)[source]#

Save one collapsed wide CSV per ontology level.

Parameters:
  • cell_df (DataFrame) –

  • input_name (str) –

  • output_dir (Path) –

  • output_prefix (str) –

  • species (str) –

  • genes (list[str]) –

  • threshold (float) –

  • hierarchy_levels (list[str]) –

Return type:

list[Path]

unravel.allen_institute.abca.scRNA_seq.expression_summary.main()[source]#