ContactMapsDiff Input

I am having trouble using ContactMapsDiff. It states the input for the command should be a single tdata object. Yet the tutorial has a dictionary of tdata objects.

From: Scoring and visualizing a single variant — AlphaGenome

if output_type == 'CONTACT_MAPS':
  component = plot_components.ContactMapsDiff(
      tdata={'REF': ref_data, 'ALT': alt_data},
      colors=ref_alt_colors,
      ylabel_template=ylabel_template,
  )

When I try to set up my code to follow the tutorial, it fails due to the dictionary. I can input either the reference or the alternate track data individually, but this shows the contact map and not the differential contact map.

Am I missing something?

Please let me know if more information would be helpful towards solving this.

Thank you!

Hi @Sam_Campbell, thanks for reporting!

Unfortunately the example in the colab is wrong: you need to pass a single TrackData object. I’ll update the example, but you can create a single diff by doing alt_prediction - ref_prediction and using that. Even when doing this, it can be the case that the delta’s are too low to be discernible in the plot, so I’d multiply the diff by some scalar. Full example:

Example:

from alphagenome import colab_utils
from alphagenome.data import genome
from alphagenome.data import track_data
from alphagenome.models import dna_client
from alphagenome.visualization import plot_components


model = dna_client.create(colab_utils.get_api_key())
variant = genome.Variant.from_str('chr10:120714877:G>T')
interval = variant.reference_interval.resize(2**20)

predictions = model.predict_variant(
    interval,
    variant,
    requested_outputs=[dna_client.OutputType.CONTACT_MAPS],
    ontology_terms=['EFO:0001187'],
)

diff = track_data.TrackData(
    (
        predictions.alternate.contact_maps - predictions.reference.contact_maps
    ).values
    * 100,
    metadata=predictions.reference.contact_maps.metadata,
    resolution=2048,
    interval=interval,
)

_ = plot_components.plot(
    [plot_components.ContactMapsDiff(tdata=diff)],
    interval=interval,
)

Creates a view like this: