trackViewer icon indicating copy to clipboard operation
trackViewer copied to clipboard

Plot with more than eight colors

Open rimjhimroy opened this issue 2 years ago • 1 comments

Hi, I am using the lolliplot() function to create SNP plots along Zscore values. The problem is I have 16 categories for the SNPs and even if I define my own colors the package is taking just 8 colors out of it and creating duplicates such that two categories have same color.

How can I define and use more than 8 colors?

Here is how I use it:

`legend=scales::viridis_pal()(length(unique(dat2$trait))) names(legend)<- gsub("", " ", levels(dat2$trait)) legend <- c(1:length(levels(dat2$trait))) names(legend) <- gsub("", " ", levels(dat2$trait)) dat2$color=legend[factor(dat2$trait)] SNP <- c(dat2$GENPOS)

features<- GRanges(paste0("chr",gene_loc$chromosome_name), IRanges(c(c(exons$exon_chrom_start)), width=c(c(exons$width)), names=NULL), fill = c(rep("#FF8833",nrow(exons))))

Zscore2 <- GRanges(paste0("chr",gene_loc$chromosome_name), IRanges(SNP, width=1, names=NULL), color = dat2$color, score = c(dat2$zval))

lolliplot(Zscore2,features, legend=legend,jitter="label")`

rimjhimroy avatar Apr 07 '22 10:04 rimjhimroy

Thank you for trying trackViewer. If you are using number (length of the factor levels) to set the colors, yes, it will only shown as 8 colors. See ?graphics::par section 'Color Specification'. Let me know if you still have any question.

jianhong avatar May 04 '22 11:05 jianhong