FeatureContribution#
- class alphagenome.visualization.plot_components.FeatureContribution(feature_contributions, *, width=1.0, fig_height=3.0, feature_colormap=immutabledict({'PROTEIN_TERMINATION': '#52606d', 'START_LOST': '#94a3b0', 'STOP_LOST': '#d2dae2', 'ALPHAMISSENSE': '#4393c3', 'PHASTCONS_470_WAY': '#80dab4', 'CACTUS_241_WAY': '#379577', 'MAX_ABS_CAGE': '#868beb', 'MAX_ABS_PROCAP': '#c3c4f5', 'MAX_ABS_RNA_SEQ': '#2a2d78', 'MERGED_SPLICING': '#f3a380', 'MAX_ABS_POLYADENYLATION': '#555ac6', 'MAX_ABS_ATAC': '#f0e801', 'MAX_ABS_DNASE': '#c5be0f', 'MAX_ABS_CHIP_TF': '#f5b8f5', 'MAX_ABS_CHIP_HISTONE': '#df62df', 'MAX_ABS_CONTACT_MAPS': '#fbf68d'}), feature_order=('MAX_ABS_ATAC', 'MAX_ABS_CONTACT_MAPS', 'MAX_ABS_DNASE', 'MAX_ABS_CHIP_TF', 'MAX_ABS_CHIP_HISTONE', 'MAX_ABS_CAGE', 'MAX_ABS_PROCAP', 'MAX_ABS_RNA_SEQ', 'MAX_ABS_POLYADENYLATION', 'MERGED_SPLICING', 'ALPHAMISSENSE', 'START_LOST', 'STOP_LOST', 'PROTEIN_TERMINATION', 'PHASTCONS_470_WAY', 'CACTUS_241_WAY'), ylabel='', show_legend=False, max_y_ticks=3, default_color='#888888')[source]#
Stacked SHAP bar chart showing feature importance per variant.
Initializes the
FeatureContributioncomponent.- Parameters:
feature_contributions (
AnnData) – AnnData with feature contribution scores shaped(n_variants, num_features). Must contain a'variant'column inobs. When multiple variants share a genomic position, the variant with the maximum sum of feature contributions is plotted.width (
float(default:1.0)) – Width of the bars.fig_height (
float(default:3.0)) – Height of the panel in inches.feature_colormap (
Mapping[str,str] (default:immutabledict({'PROTEIN_TERMINATION': '#52606d', 'START_LOST': '#94a3b0', 'STOP_LOST': '#d2dae2', 'ALPHAMISSENSE': '#4393c3', 'PHASTCONS_470_WAY': '#80dab4', 'CACTUS_241_WAY': '#379577', 'MAX_ABS_CAGE': '#868beb', 'MAX_ABS_PROCAP': '#c3c4f5', 'MAX_ABS_RNA_SEQ': '#2a2d78', 'MERGED_SPLICING': '#f3a380', 'MAX_ABS_POLYADENYLATION': '#555ac6', 'MAX_ABS_ATAC': '#f0e801', 'MAX_ABS_DNASE': '#c5be0f', 'MAX_ABS_CHIP_TF': '#f5b8f5', 'MAX_ABS_CHIP_HISTONE': '#df62df', 'MAX_ABS_CONTACT_MAPS': '#fbf68d'}))) – Mapping from feature names to colors. Defaults toFEATURE_CONTRIBUTIONS_COLORMAP.feature_order (
Sequence[str] (default:('MAX_ABS_ATAC', 'MAX_ABS_CONTACT_MAPS', 'MAX_ABS_DNASE', 'MAX_ABS_CHIP_TF', 'MAX_ABS_CHIP_HISTONE', 'MAX_ABS_CAGE', 'MAX_ABS_PROCAP', 'MAX_ABS_RNA_SEQ', 'MAX_ABS_POLYADENYLATION', 'MERGED_SPLICING', 'ALPHAMISSENSE', 'START_LOST', 'STOP_LOST', 'PROTEIN_TERMINATION', 'PHASTCONS_470_WAY', 'CACTUS_241_WAY'))) – Desired order of features in the plot. Defaults toFEATURE_CONTRIBUTIONS_ORDER.ylabel (
str(default:'')) – Y-axis label.show_legend (
bool(default:False)) – Whether to display a legend.max_y_ticks (
int|None(default:3)) – Maximum number of Y-axis tick divisions (default: 3).default_color (
str(default:'#888888')) – Fallback color for features not infeature_colormap.
- Raises:
ValueError – If
'variant'is not infeature_contributions.obs.
Methods
|
Returns the height of the axis. |
|
Plots the bar chart on the given axis. |