02: Rescaled introns
Make the plot prettier by rescaling introns into a smaller size
[3]:
import RNApysoforms as RNApy
[4]:
## Path to your ENSEMBL GTF file
ensembl_gtf_path = "../dash_apps/RNApysoforms/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()