tidy_scores

Contents

tidy_scores#

alphagenome.models.v2.variant_scorers.tidy_scores(scores, match_gene_strand=True, include_extended_metadata=True, filter_protein_coding=False)[source]#

Formats scores into a tidy (long) pandas DataFrame.

This function reformats variant or interval scores into a more readable DataFrame with one score per row. This function supports both scores generated from variant scorers (e.g., the output of score_variant or score_variants) or interval scorers (e.g., the output of score_interval or score_intervals).

It handles both variant/interval-centric scoring (producing one score row per variant/interval-track pair) and gene-centric scoring (one score row per variant/interval-gene-track combination).

The function accepts these score input types:

  • A sequence of AnnData objects (e.g., output of score_variant with one or more scorers).

  • A nested sequence of AnnData objects (e.g., output of score_variants with multiple variants).

Scores from multiple scorers or multiple variants/intervals are concatenated together into a single pandas DataFrame, containing the union of all applicable columns across scorers.

Parameters:
  • scores (Sequence[AnnData] | Sequence[Sequence[AnnData]]) – Scoring output as either a sequence of AnnData objects, or a nested sequence of AnnData objects (for example, the outputs of score_variant and score_variants, respectively).

  • match_gene_strand (bool (default: True)) – If True (and using gene-centric scoring), rows with mismatched gene and track strands are removed.

  • include_extended_metadata (bool (default: True)) – Argument passed to tidy_anndata to include additional metadata columns where available.

  • filter_protein_coding (bool (default: False)) – Argument passed to tidy_anndata to filter rows to only those where gene_type == 'protein_coding'.

Return type:

DataFrame | None

Returns:

One row per score, with the columns below.

  • variant_id (when applicable): Variant of interest (e.g. chr22:36201698:A>C).

  • scored_interval: Genomic interval scored (e.g. chr22:36100000-36300000).

  • gene_id: ENSEMBL gene identifier without version number. (e.g. ENSG00000100342), or None if not applicable.

  • gene_name: HGNC gene symbol (e.g. APOL1), or None if not applicable.

  • gene_type: Gene biotype (e.g. protein_coding, lncRNA), or None if not applicable.

  • gene_strand: Strand of the gene (‘+’, ‘-’, ‘.’), or None if not applicable.

  • output_type: Type of the output from the model (e.g. RNA_SEQ, DNASE).

  • interval_scorer (when applicable): Name of the interval scorer used.

  • variant_scorer (when applicable): Name of the variant scorer used.

  • track_name: Name of the output track (e.g. UBERON:0036149 total RNA-seq).

  • track_strand: Strand of the track (‘+’, ‘-’, or ‘.’).

  • imputation_mode: The imputation mode of the track (‘observed’, ‘imputed_supported’ or ‘imputed_exploratory’).

  • biosample_curie: A ‘_’ delimited string of ontology CURIEs that represent this biosample.

  • biosample_type: Type of biosample (e.g. ‘tissue’ or ‘primary cell’).

  • biosample_name: Name of the biosample.

  • raw_score: Raw variant score.

  • quantile_score (when applicable): Quantile score.

Optional columns:

  • Assay title: Subtype of the assay (e.g., ‘total RNA-seq’).

  • data_source: Data source for the track (e.g. ‘encode’, ‘gtex’).

  • histone_mark: Name of the histological mark (e.g. ‘H3K4ME3’).

  • transcription_factor: Name of the transcription factor (e.g. ‘CTCF’).

  • splice_site_type: The type of splice site (‘donor’, ‘acceptor’).

  • suspension_type: The suspension type for single-cell assays (‘nucleus’, ‘cell’).

  • endedness: The sequence reading endedness (‘single’, ‘paired’).

  • genetically_modified: Boolean indicating whether the sample was genetically modified.

  • cellxgene_dataset_id: The CELLxGENE dataset ID if applicable.

  • paper_doi: The DOI of the dataset paper if applicable.

Raises:

ValueError – If the input is not a valid type (sequence of AnnData or nested sequence of AnnDatas).