Thanks to the amazing package of KaryoploteR and a great tutorial website, I was able to make a rainfall plot.
https://bernatgel.github.io/karyoploter_tutorial//Examples/Rainfall/Rainfall.html

However, one thing that I am suffering from making a perfect rainfall plot is color label is missing.
I would like to know and visualize what color is what like C>A is yellow, C>G is red for example.
Tutorial website states to ask a question to Biostars, I am posting my question here.

Thank you very much in advance.


You can use the standard `legend()` command as outlined in this issue here: https://support.bioconductor.org/p/124328/

Minimal example based on https://bernatgel.github.io/karyoploter_tutorial//Examples/Rainfall/Rainfall.html :

```
library(karyoploteR)


somatic.mutations <- read.table(file="ftp://ftp.sanger.ac.uk/pub/cancer/AlexandrovEtAl/somatic_mutation_data/Pancreas/Pancreas_raw_mutations_data.txt", header=FALSE, sep="\t", stringsAsFactors=FALSE)
somatic.mutations <- setNames(somatic.mutations, c("sample", "mut.type", "chr", "start", "end", "ref", "alt", "origin"))

somatic.mutations <- split(somatic.mutations, somatic.mutations$sample)
sm <- somatic.mutations[["APGI_1992"]]
sm.gr <- toGRanges(sm[,c("chr", "start", "end", "mut.type", "ref", "alt")])
seqlevelsStyle(sm.gr) <- "UCSC"

variant.colors <- getVariantsColors(sm.gr$ref, sm.gr$alt)
kp <- plotKaryotype(plot.type=4)
kpPlotRainfall(kp, data = sm.gr, col=variant.colors)
uniq_cols <- variant.colors[!duplicated(variant.colors)]
legend(x = "bottomright", fill=uniq_cols, legend=names(uniq_cols))
```

Now you can customise the call to legend() in any way you like.

Looks like this:![example rainbow plot][1]


  [1]: /media/images/ab63d7b6-5198-4f0f-a350-d20d4ba4