[genoPlotR-help] genoplotR: setting up colors for dna segments based on name

Lionel Guy guy.lionel at gmail.com
Fri Mar 7 09:14:29 CET 2014


Hi Migee,

There are various ways to do that. One is to have an extra "col" column 
in your tab file, giving colors for each gene. Color names have to be 
R-compatible, (e.g. look at colors() in R).

Otherwise, if you have a list of genes and a matching list if colors, 
you could do something like this:

## Just loading data, replacing names with bogus gene names
library(genoPlotR)
data(three_genes)
dna_segs[[1]]$name <- c("dnaA", "dnaA", "modB")
dna_segs[[2]]$name <- c("dnaA", "dnaC", "modD")
dna_segs[[3]]$name <- c("dnaC", "blaB", "modD")

## Creating a lookup table with gene names in one colum and colors in 
the second
lt <- data.frame(name=c("dnaA", "dnaC", "modB"),
                  col=c("red", "green", "yellow"),
                  stringsAsFactors=FALSE)

## Attributing colors to genes
for (i in 1:length(dna_segs)){
     dna_segs[[i]]$col <- "black"
     for (j in 1:nrow(lt)){
         dna_segs[[i]]$col[dna_segs[[i]]$name == lt$name[j]] <- lt$col[j]
     }
}

## Showing the result
annots <- list()
for (i in 1:length(dna_segs)){
     annots[[i]] <- auto_annotate(dna_segs[[i]], names=dna_segs[[i]]$name)
}
plot_gene_map(dna_segs, comparisons, annotations=annots)


If you still have problems, please send (part of) the data you have, it 
would help to solve it!

Cheers,

Lionel

On 03/06/2014 07:46 PM, Migun Shakya wrote:
> Hello,
>
> Is there a way to set the color of dna segments based on the name of the gene?
>
> I have set of genes with same name but from different genomes, i wanted to color the arrows based on its name.
> Right now when i read in my tab delimited file and convert it to dna_segs, it adds the default color blue.
>
>
>
> Thank you
>
> migee.
> _______________________________________________
> genoPlotR-help mailing list
> genoPlotR-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genoplotr-help
>


More information about the genoPlotR-help mailing list