Closed erikagedvilaite closed 4 years ago
Axis legends must be added after the plot is created. This is because the axes objects are only created when the comut is created with plot_comut
. Try putting toy_comut.add_axis_legend
after toy_comut.plot_comut(figsize = (15,10))
.
Thank you!
Another question - how do you order mutations based on their prevalence (ex. TP53 on top since it has most mutations) as seen in oncoplots/oncoprints
This isn't something that is natively built into CoMut (yet), but it isn't too hard to implement by the user. You can use pandas functions to extract the most frequent mutations and pass it to category_order
. In your case, you're passing mutation data as variant_col_df
, so you could use the following to define the order of mutations:
mut_order = variant_col_df.groupby('category').size().sort_values().index toy_comut.add_categorical_data(variant_col_df, name = 'Mutation type', category_order = mut_order)
Note that CoMut uses category_order
to determine both which mutations should be shown and their order - this means unless you want CoMut to show ALL the mutations in variant_col_df
(which may not be desirable if you parsed it from a MAF of all your mutations), you will need to subset mut_order
. For example, if you want to show just the 10 most frequent mutations, you should use category_order = mut_order[:10]
.
If you want to show a subset of genes but order them by frequency, you can do something like the following:
interesting_genes = ['TP53', 'BRCA2', 'MYC', 'BRAF'...] # define interesting genes
interesting_df = variant_col_df[variant_col_df['category'].isin(interesting_genes)] # subset df to genes
mut_order = interesting_df.groupby('category').size().sort_values().index # determine order
toy_comut.add_categorical_data(variant_col_df, name = 'Mutation type', category_order = mut_order)
Hope that helps!
Hello, can someone help me out with this error:
Code:
Error: