Rcircos - Changing Maximum Number Of Genes
3
1
Entering edit mode
8.2 years ago

Hi everyone. I am using Rcircos package to show genes mutated in a disease and the location of each on the chromosome.

I use the code exactly as example:

#RCIRCOS
library(RCircos)
data(UCSC.HG19.Human.CytoBandIdeogram)
cyto.info <- UCSC.HG19.Human.CytoBandIdeogram
num.inside <- 5
num.outside <- 0
chr.exclude <- "chrY"
RCircos.Set.Core.Componentscyto.info,chr.exclude, num.inside, num.outside)
RCircos.Set.Plot.Area()
RCircos.Chromosome.Ideogram.Plot()
genomic.data <- read.table(file.choose(),sep="\t",header=T)
RCircos.Gene.Connector.Plot(genomic.data, track.num=1, side="in")
RCircos.Gene.Name.Plot(genomic.data, name.col=4, track.num=2, side="in")

But there is a default maximum number of genes I can annotate to each chromosome. The function neglects all the extra values:

Maximum lables for  chr1 is 16 . Extra ones are ignored.
Maximum lables for  chr7 is 10 . Extra ones are ignored.
Maximum lables for  chr11 is 9 . Extra ones are ignored.
Maximum lables for  chr12 is 9 . Extra ones are ignored.
Maximum lables for  chr16 is 6 . Extra ones are ignored.
Maximum lables for  chr17 is 5 . Extra ones are ignored.
Maximum lables for  chr19 is 4 . Extra ones are ignored.
Maximum lables for  chr20 is 4 . Extra ones are ignored.
Maximum lables for  chr21 is 3 . Extra ones are ignored.

Does anyone know how I can change these defaults?

Thank you.

Mehran

gene • 3.4k views
ADD COMMENT
0
Entering edit mode

I made a get around by modifying the Gene connector and gene name functions:

    mod.gene.label <- function (gene.data = NULL, name.col = NULL, track.num = NULL, 
    side = "in", inside.pos = NULL, outside.pos = NULL, genomic.columns = 3, 
    is.sorted = FALSE,cex = .4,ex = NULL) 
{
    if (is.null(gene.data)) 
        stop("Genomic data missing in RCircos.Gene.Name.Plot().\n")
    if (is.null(genomic.columns)) 
        stop("Missing number of columns for genomic position.\n")
    if (is.null(name.col) || name.col <= genomic.columns) 
        stop("Data column must be ", genomic.columns + 1, " or bigger.\n")
    RCircos.Pos <- RCircos.Get.Plot.Positions()
    RCircos.Par <- RCircos.Get.Plot.Parameters()
    textColors <- RCircos.Get.Plot.Colors(gene.data, RCircos.Par$text.color)
    boundary <- RCircos.Get.Plot.Boundary(track.num, side, inside.pos, 
        outside.pos, FALSE)
    gene.data <- RCircos.Get.Single.Point.Positions(gene.data, 
        genomic.columns)
    sizes <- RCircos.Get.Gene.Name.Plot.Parameters()
    sizesdf <- within(sizes,widths <- sizes$endLoc - sizes$startLoc)
    newlocation <- NULL
    for (location in 1:nrow(gene.data)){
      if (location == 1){
        oldchrom <- 200
      }
      row <- gene.data[location,]
      chrom <- as.numeric(as.character(row[,1]))
      chromsize <- sizesdf[sizesdf$chromosomes == chrom,]$widths
      chromstart <- sizesdf[sizesdf$chromosomes == chrom,]$startLoc
      fraction <- 1/nrow(subset(gene.data,Chromsome == as.numeric(chrom)))
      if (oldchrom == chrom){
        sep <- sep + 1
      } else {
        sep <- 1
      }
      if (nrow(subset(gene.data,Chromsome == as.numeric(chrom))) == 1){
        add <- chromstart
      } else {
        add <- ((fraction*(chromsize+ex))*sep)+chromstart
      }
      newlocation <- c(newlocation,add)
      oldchrom <- chrom
    }
    gene.data$Location <- unname(unlist(newlocation))
    # gene.data <- RCircos.Get.Gene.Label.Locations(gene.data, 
        # genomic.columns, is.sorted)
    rightSide <- nrow(RCircos.Pos)/2
    thePoints <- as.numeric(gene.data[, ncol(gene.data)])
    if (side == "in") {
        labelPos <- boundary[1]
        textSide <- rep(4, nrow(gene.data))
        textSide[thePoints <= rightSide] <- 2
    }
    else {
        labelPos <- boundary[2]
        textSide <- rep(2, nrow(gene.data))
        textSide[thePoints <= rightSide] <- 4
    }
    for (aText in seq_len(nrow(gene.data))) {
        geneName <- as.character(gene.data[aText, name.col])
        rotation <- as.numeric(RCircos.Pos$degree[thePoints[aText]])
        text(RCircos.Pos[thePoints[aText], 1] * labelPos, RCircos.Pos[thePoints[aText], 
            2] * labelPos, label = geneName, pos = textSide[aText], 
            cex = cex, srt = rotation, offset = 0, 
            col = textColors[aText])
    }
}
ADD REPLY
0
Entering edit mode
mod.gene.connector <- function (genomic.data = NULL, track.num = NULL, side = "in", 
        inside.pos = NULL, outside.pos = NULL, genomic.columns = 3, 
        is.sorted = FALSE,ex = NULL) 
    {
        if (is.null(genomic.data)) 
            stop("Genomic data missing for RCircos.Gene.Connector.Plot().\n")
        boundary <- RCircos.Get.Plot.Boundary(track.num, side, inside.pos, 
            outside.pos, erase.area = FALSE)
        outerPos <- boundary[1]
        innerPos <- boundary[2]
        RCircos.Pos <- RCircos.Get.Plot.Positions()
        RCircos.Par <- RCircos.Get.Plot.Parameters()
        geneData <- RCircos.Get.Single.Point.Positions(genomic.data, 
            genomic.columns)
        # labelData <- RCircos.Get.Gene.Label.Locations(geneData, genomic.columns, 
        #     is.sorted)
        newlocation <- NULL
        sizes <- RCircos.Get.Gene.Name.Plot.Parameters()
        sizesdf <- within(sizes,widths <- sizes$endLoc - sizes$startLoc)
        for (location in 1:nrow(geneData)){
          if (location == 1){
            oldchrom <- 200
          }
          row <- geneData[location,]
          chrom <- as.numeric(as.character(row[,1]))
          chromsize <- sizesdf[sizesdf$chromosomes == chrom,]$widths
          chromstart <- sizesdf[sizesdf$chromosomes == chrom,]$startLoc
          fraction <- 1/nrow(subset(geneData,Chromsome == as.numeric(chrom)))
          if (oldchrom == chrom){
            sep <- sep + 1
          } else {
            sep <- 1
          }
          if (nrow(subset(gene.data,Chromsome == as.numeric(chrom))) == 1){
            add <- chromstart
          } else {
            add <- ((fraction*(chromsize+ex))*sep)+chromstart
          }
          newlocation <- c(newlocation,add)
          oldchrom <- chrom
        }
        labelData <- geneData
        labelData$Location <- unname(unlist(newlocation))
        connectData <- data.frame(geneData$Location,labelData$Location)
        if (outerPos < RCircos.Par$chr.ideo.pos) {
            genomicCol <- ncol(connectData) - 1
            labelCol <- ncol(connectData)
        }
        else {
            genomicCol <- ncol(connectData)
            labelCol <- ncol(connectData) - 1
        }
        vHeight <- round((outerPos - innerPos)/10, digits = 4)
        hRange <- outerPos - innerPos - 2 * vHeight
        topLoc <- outerPos - vHeight
        botLoc <- innerPos + vHeight
        lineColors <- RCircos.Get.Plot.Colors(labelData, RCircos.Par$text.color)
        chroms <- unique(connectData[, 1])
        for (aChr in seq_along(chroms)) {
            chrRows <- which(connectData[, 1] == chroms[aChr])
            total <- length(chrRows)
            for (aPoint in seq_len(total)) {
                p1 <- connectData[chrRows[aPoint], genomicCol]
                p2 <- connectData[chrRows[aPoint], labelCol]
                lines(c(RCircos.Pos[p1, 1] * outerPos, RCircos.Pos[p1, 
                    1] * topLoc), c(RCircos.Pos[p1, 2] * outerPos, 
                    RCircos.Pos[p1, 2] * topLoc), col = lineColors[chrRows[aPoint]])
                lines(c(RCircos.Pos[p2, 1] * botLoc, RCircos.Pos[p2, 
                    1] * innerPos), c(RCircos.Pos[p2, 2] * botLoc, 
                    RCircos.Pos[p2, 2] * innerPos), col = lineColors[chrRows[aPoint]])
                lines(c(RCircos.Pos[p1, 1] * topLoc, RCircos.Pos[p2, 
                    1] * botLoc), c(RCircos.Pos[p1, 2] * topLoc, 
                    RCircos.Pos[p2, 2] * botLoc), col = lineColors[chrRows[aPoint]])
            }
        }
    }

Incorporate it into your code with the following:

mod.gene.connector(genomic.data = swapnames,track.num = 1,side = "out",ex = 100) mod.gene.label(gene.data = swapnames,name.col = 4,track.num = 2,side = "out",cex = .6,ex = 100)

Play around with "ex" until the spacing works.

ADD REPLY
4
Entering edit mode
7.6 years ago

Looking at the Rcircos's code, it seems that the max number of labels depends from the default text size (see line 2526, and the definition of size.factor on line 2509). Have you tried to reduce the font size of labels?

In any case, I would suggest you to contact the author of Rcircos and report him the problem. By the way, you can tell him that there is a spelling typo in the error message.

ADD COMMENT
0
Entering edit mode

Font size is already at its best but thanks for the thought!

I will contact the author...

Cheers,

R

ADD REPLY
1
Entering edit mode
7.6 years ago
rhubaux ▴ 10

Hi there,

Any news concerning this issue?

I have the same problem. I think there are useful options in the Circos software to modify scaling of individual chromosomes but not sure if this is available using the R package?

Is there any trick using the parameters or modifying some functions with hidden thresholds?

Thanks for any advice!

Roland

ADD COMMENT
1
Entering edit mode

Hi there,

I faced the same problem. Got it working by reducing the default character width. I changed it using "rcircos.params$char.width". It automatically calculates the number of labels that can be fit.

Rachel

ADD REPLY
0
Entering edit mode
15 months ago
DanyBioinf • 0

Hi :),

Same as Rachel here. I changed the maximun labels per chromosome by modifying parameters such as rcircos.params$base.per.unit, rcircos.params$char.width and rcircos.params$text.size. Dont forget to update the modifications with RCircos.Reset.Plot.Parameters(rcircos.params).

Dany

ADD COMMENT

Login before adding your answer.

Traffic: 1678 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6