What is wrong in chromomap packages and how to change the color and add legend?

Viewed 190

Here are my data

chr_anot

gene    chr start   end
wnt5    1A  670 900
wnt6    1A  512 635
wnt7    1A  225 315
wnt1    1A  125 400
lala    2A  200 400
BABA    3A  100 150

chr_file

chr start   end
1A  90  1000
2A  50  500
3A  60  600

I run chromomap packages in R studio using this script

library(chromoMap) 
chr.data <- read.csv("chr_file.csv", header=T) 
anno.data <- read.csv("chr_anot.csv", header = T) 
chromoMap(list(chr.data),list(anno.data), labels = T, data_based_color_map = T, data_color = list(c(col.set)))

However I got a warning message like this: warning message

Could anyone tell me what was wrong? I got the result like this.

result

I also would like to make every gene has different color and add legend. Does anyone know how to make that?

1 Answers

The warning message was caused because of the annotation data.frame, anno.data, as it does not have the additional data column (5th column in the annotations file, please see the docs for input format) while you indicated the chromoMap to color based on the feature-associated data by setting data_based_color_map = T.

If you'd like to add a color for each gene, you just need to add a 5th column to your anno.data preferably the names of your genes like:

anno.data <- cbind.data.frame(anno.data,Symbol=anno$gene)

and, then you can create the plot with each gene colored uniquely and create the legend by setting legend to TRUE and tweaking other arguments to make the plot as desired.

Please have look at how to create discrete color maps for categorical data using chromoMap here.

Here is something I tried for you:

chromoMap(list(chr.data),list(anno.data), 
          # labelling arguments 
          labels = T, 
          label_font = 12,
          label_angle = -55,
          # group annotation arguments
          data_based_color_map = T,
          data_type = "categorical",
          data_colors = list(c("red2","yellow3","blue2","orange3","purple","green2")),
          # for the  legend
          legend = T,
          #adjusting the legend along y-axis
          lg_y = 250,
          #increasing canvas width for legend
          canvas_width = 600,
          #playing with plot properties
          text_font_size = 12,
          chr_color = c("#d3d3d3"))

here is the output:

rplot

You can try a bunch of other configuration options and features offered by chromoMap. Please read the documentation for more details.

Disclosure: I am the chromoMap developer

chromoMap Website

Related