Rescaled introns

Make the plot prettier by rescaling introns into a smaller size

[1]:
import RNApysoforms as RNApy
[2]:
## Path to your ENSEMBL GTF file
ensembl_gtf_path = "../../tests/test_data/Homo_sapiens_chr21_and_Y.GRCh38.110.gtf"


## Read ENSEMBL gtf
annotation = RNApy.read_ensembl_gtf(ensembl_gtf_path)


## Filter gene name in annotation and counts matrix
sod1_annotation = RNApy.gene_filtering(annotation=annotation, target_gene="SOD1")

"""
Rescale introns (no need to run function "to_intron", shorten_gaps() already does this
by default if introns aren't already included in annotation.
"""
sod1_annotation = RNApy.shorten_gaps(sod1_annotation)


"""
Create traces for plotting, make sure to pass x_start and x_end
as "rescaled_start" and "rescaled_end" to get shortened introns.
You can also change hover_start and hover_end to reflext the
rescaled coordinates, but I find the original genomic coodrinates
for start and end more informative for the hover display.
"""
traces = RNApy.make_traces(annotation=sod1_annotation, x_start="rescaled_start", x_end="rescaled_end",
                         y='transcript_id', annotation_hue="transcript_biotype",
                         hover_start="start", hover_end="end")

## Put traces into figure
fig = RNApy.make_plot(traces = traces, subplot_titles = ["Transcript Structure"], width=1200, height=500)

## Show figure
fig.show()


Notes:

You can click on the legend items to make figure elements appear and disappear.

The legend title will get grayed out when clicking on the first legend item. I could not find a workaround for that with the current plotly release (version 5).

The hovering for exons and CDS works best if you hover your mouse over the corners of the CDS/exon boxes.