11: Making expression plot only

Here is one possible way of generating only the expression plot without the RNA isoform annotation

[3]:
import RNApysoforms as RNApy
[4]:
## Path to your ENSEMBL GTF file, counts matrix file, and metadata file
ensembl_gtf_path = "../dash_apps/RNApysoforms/tests/test_data/Homo_sapiens_chr21_and_Y.GRCh38.110.gtf"
counts_matrix_path = "../dash_apps/RNApysoforms/tests/test_data/counts_matrix_chr21_and_Y.tsv"
metadata_path = "../dash_apps/RNApysoforms/tests/test_data/sample_metadata.tsv"


## Read ENSEMBL GTF and counts matrix with metadata and normalization
annotation = RNApy.read_ensembl_gtf(ensembl_gtf_path)
counts_matrix = RNApy.read_expression_matrix(expression_matrix_path=counts_matrix_path,
                                          metadata_path=metadata_path,
                                           cpm_normalization=True, relative_abundance=True)


## Filter APP gene and keep only top 5 expressed transcripts
app_annotation, app_expresison_matrix = RNApy.gene_filtering(annotation=annotation, expression_matrix=counts_matrix, target_gene="APP",
                                                        order_by_expression=True, order_by_expression_column="counts",
                                                        keep_top_expressed_transcripts=5)

## Rescale introns
app_annotation = RNApy.shorten_gaps(app_annotation)


## Create traces without annotation
traces = RNApy.make_traces(expression_matrix=app_expresison_matrix,
                        x_start="rescaled_start", x_end="rescaled_end",
                         y='transcript_id', hover_start="start", hover_end="end",
                         expression_columns=["counts", "CPM", "relative_abundance"],
                         expression_hue="AD status", marker_size=3, arrow_size=7)

## Make figure only with RNA isoform expression plots
fig = RNApy.make_plot(traces=traces, subplot_titles=["Counts", "CPM", "Relative Abundance"],
                   width=1200, height=500, boxgap=0.1, boxgroupgap=0.5)

## Show figure
fig.show()

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 edges of the CDS/exon boxes.