Color label of rainfall plot drawn by KaryoploteR

You can use the standard legend() command as outlined in this issue here:

Minimal example based on :


somatic.mutations <- read.table(file="", 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"]] <- toGRanges(sm[,c("chr", "start", "end", "mut.type", "ref", "alt")])
seqlevelsStyle( <- "UCSC"

variant.colors <- getVariantsColors($ref,$alt)
kp <- plotKaryotype(plot.type=4)
kpPlotRainfall(kp, data =, 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

Read more here: Source link