vanallenlab / comut

CoMut is a Python library for visualizing genomic and phenotypic information via comutation plots
MIT License
88 stars 28 forks source link

Can you add a box or border around add_categorical_data category? #12

Closed erikagedvilaite closed 4 years ago

erikagedvilaite commented 4 years ago

Hello team,

Thank you for such a useful tool. Just a quick question - is it possible to put borders around part of the whole add_categorical_data? Let's say you want to bring attention to the mutation calls or a subgroup of genes in the mutation calls?

Also, any updates on being able to order genes in the oncoplot way? I am currently doing it manually.

Thank you again and l look forward to chatting with you soon.

Best, Erika

jett-crowdis commented 4 years ago

Hi Erika,

No update yet on being able to order genes the way that oncoplot does - it is currently on my list.

As far as drawing a box around a row, you can do this by quite simply drawing a box onto the axis object that contains that categorical data. For example, the following code, when added to the code that makes the melanoma_comut in documentation.ipynb, draws a box around the NRAS and NF1 rows in the mutation data.

import matplotlib.patches as patches

# clip_on allows the rectangle to extend outside the axis.
rect = patches.Rectangle((-3.2, 2), len(sample_order) + 3.2, 2, clip_on = False, fill = False, edgecolor = 'black')
melanoma_comut.axes['Mutation type'].add_patch(rect)

You may need to adjust y_padding to prevent crowding. See the syntax for adding rectangles to an axis