unravel.allen_institute.abca.scRNA_seq.expression_plot module#
Use abca_scRNAseq_expression_plot (rna_exp_plot) from UNRAVEL to plot expression summary CSVs.
- Inputs:
Wide CSVs produced by
abca_scRNAseq_expression_summary(rna_exp_summary).
- Plots:
Dot plot (default): dot color = mean log2(CPM+1) expression; dot size = percent expression above the threshold used by expression_summary.py.
Heatmap: mean expression, percent expression, or both.
The script auto-detects genes from columns ending in _mean_expression.
# Top 50 by expression, ordered by expression –rank-by mean
# Top 50 by expression, then reorder those 50 by prevalence –rank-by mean –sort-by cells
Usage (sorting by mean expression by default):#
rna_exp_plot -i path/expression_summary_thr3/5HTR__Human_NAC__supercluster.csv [-ct cell_type1 cell_type2 …] [-g gene1 gene2 …] [-n 50] [–rank-by …] [–sort-by …] [–no-cell-stats] [-p dotplot|heatmap|both] [–heatmap-metric <value>] [–mean-max <value>] [–percent-max <value>] [–size-min <value>] [–size-max <value>] [–mean-cmap <cmap>] [–percent-cmap <cmap>] [–annotate] [-o output_dir] [-op output_prefix] [-f png|pdf|svg] [–dpi <value>] [-v]
Usage for selected cell types and genes (ranked by mean expression and sorted by cell count):#
rna_exp_plot -i path/expression_summary_thr3/5HTR__Human_NAC__supercluster.csv -ct “Medium spiny neuron” “Eccentric medium spiny neuron” -g DRD1 DRD2 –sort-by cells
Usage for the 50 most abundant cell types sorted by abundance:#
rna_exp_plot -i file.csv –rank-by cells
Usage for parallel processing:#
fd -e csv -d 1 -j 4 -x rna_exp_plot -i {}
- unravel.allen_institute.abca.scRNA_seq.expression_plot.safe_name(value)[source]#
Convert text to a file-name-safe string.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.natural_sort_text(value)[source]#
Return a zero-padded natural-sort key.
- Return type:
- unravel.allen_institute.abca.scRNA_seq.expression_plot.color_cell_type_tick_labels(ax, df)[source]#
Bold and color y-axis cell-type labels.
- Parameters:
ax (Axes) –
df (DataFrame) –
- Return type:
None
- unravel.allen_institute.abca.scRNA_seq.expression_plot.detect_genes(columns)[source]#
Detect genes from wide mean-expression column names.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.validate_and_select_genes(df, requested_genes)[source]#
Return requested or detected genes and validate plot metrics.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.row_rank(df, genes, rank_by)[source]#
Calculate the metric used to select and sort cell types.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.prepare_plot_dataframe(df, genes, cell_types, contains, min_cells, min_percent_cells, top, rank_by, sort_by, show_cell_stats)[source]#
Filter, rank, sort, and label summary rows for plotting.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.summary_context(df)[source]#
Return species, level, and threshold labels from a summary CSV.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.default_title(df, custom_title)[source]#
Create a base title from summary metadata.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.automatic_figure_size(n_rows, n_genes, width, height)[source]#
Choose a readable figure size while allowing explicit overrides.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.matrix_for_metric(df, genes, suffix)[source]#
Return a numeric cell-type by gene matrix.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.finite_max(values, fallback=1.0)[source]#
Return a positive finite maximum suitable for a color scale.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.save_figure(fig, output_path, dpi)[source]#
Save and close a Matplotlib figure.
- unravel.allen_institute.abca.scRNA_seq.expression_plot.plot_dotplot(df, genes, title, output_path, threshold, width, height, mean_max, percent_max, size_min, size_max, mean_cmap, dpi)[source]#
Plot mean expression as color and percent expression as dot size.