### Example Usage of print.CELL_META Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/print.CELL_META.html Demonstrates the output when the print.CELL_META method is called. Currently, there are no specific examples provided in the documentation. ```R # There is no example NULL #> NULL ``` -------------------------------- ### Install circlize from GitHub Source: https://github.com/jokergoo/circlize/blob/master/README.md Install the development version of the circlize package directly from GitHub using the devtools package. ```r devtools::install_github("jokergoo/circlize") ``` -------------------------------- ### Install circlize Package Source: https://github.com/jokergoo/circlize/blob/master/docs/index.html Install the circlize package from CRAN or directly from GitHub using devtools. ```r install.packages("circlize") ``` ```r devtools::install_github("jokergoo/circlize") ``` -------------------------------- ### Install circlize from CRAN Source: https://github.com/jokergoo/circlize/blob/master/README.md Install the circlize package from the Comprehensive R Archive Network (CRAN). ```r install.packages("circlize") ``` -------------------------------- ### Basic circos.axis setup Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.axis.html Initializes a circos plot with sectors and then draws a basic x-axis on sector 'a'. ```R sectors = letters[1:8] circos.par(points.overflow.warning = FALSE) circos.initialize(sectors, xlim = c(0, 10)) circos.trackPlotRegion(sectors, ylim = c(0, 10), track.height = 0.1, bg.border = NA, panel.fun = function(x, y) { circos.text(5, 10, get.cell.meta.data("sector.index")) }) circos.trackPlotRegion(sectors, ylim = c(0, 10)) circos.axis(sector.index = "a") ``` -------------------------------- ### Initialize Circos and Generate Genomic Rainfall Plot Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicRainfall.html This example demonstrates how to initialize the circos plot with ideogram data and then generate a genomic rainfall plot using a list of bed-formatted data. It also includes adding genomic density tracks for comparison. Ensure the 'circlize' package and its example data are loaded. ```R library(circlize) # Load example data load(system.file(package = "circlize", "extdata", "DMR.RData")) # Initialize circos with ideogram circos.initializeWithIdeogram(plotType = c("axis", "labels")) # Define bed data as a list bed_list <- list(DMR_hyper, DMR_hypo) # Generate genomic rainfall plot circos.genomicRainfall(bed_list, pch = 16, cex = 0.4, col = c("#FF000080", "#0000FF80")) # Add genomic density tracks circos.genomicDensity(bed_list[[1]], col = c("#FF000080"), track.height = 0.1) circos.genomicDensity(bed_list[[2]], col = c("#0000FF80"), track.height = 0.1) # Clear the circos plot circos.clear() ``` -------------------------------- ### Draw Arrows with Reversed Arrow Position Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.arrow.html Example showing how to draw arrows with the arrow head at the 'start' position, effectively reversing the arrow's direction. This is controlled by the 'arrow.position' argument. ```R circos.initialize(letters[1:4], xlim = c(0, 1)) tail = c("point", "normal", "point", "normal") circos.track(ylim = c(0, 1), panel.fun = function(x, y) { circos.arrow(x1 = 0, x2 = 1, y = 0.5, width = 0.4, arrow.head.width = 0.6, arrow.head.length = cm_x(1), col = col[CELL_META$sector.numeric.index], tail = tail[CELL_META$sector.numeric.index], arrow.position = "start") }, bg.border = NA, track.height = 0.4) ``` -------------------------------- ### get.all.sector.index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Get index for all sectors. ```APIDOC ## get.all.sector.index() ### Description Get index for all sectors. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r get.all.sector.index() ``` ### Response None specified in the source. ``` -------------------------------- ### Example: Update and draw a rectangle in a specific cell Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.updatePlotRegion.html This example demonstrates initializing a Circos plot, adding a track with text, then updating a specific cell ('b', track 1) and drawing a semi-transparent red rectangle within it. ```r circos.initialize(letters[1:8], xlim = c(0, 1)) circos.track(ylim = c(0, 1), panel.fun = function(x, y) { circos.text(CELL_META$xcenter, CELL_META$ycenter, CELL_META$sector.index) }) circos.update(sector.index = "b", track.index = 1) circos.rect(CELL_META$cell.xlim[1], CELL_META$cell.ylim[1], CELL_META$cell.xlim[2], CELL_META$cell.ylim[2], col = "#FF000080") circos.clear() ``` -------------------------------- ### Initialize sectors and tracks, then convert coordinates Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circlize.html This example demonstrates initializing sectors and tracks using `circos.initialize` and `circos.track`, followed by converting a specific data point (x=0.5, y=0.5) to polar coordinates using `circlize`. It also shows how to clear the circos plot afterwards. ```R pdf(NULL) sectors = c("a", "b") circos.initialize(sectors, xlim = c(0, 1)) circos.track(ylim = c(0, 1)) # x = 0.5, y = 0.5 in sector a and track 1 circlize(0.5, 0.5, sector.index = "a", track.index = 1) circos.clear() dev.off() ``` -------------------------------- ### Setting start.degree Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.par.html Configures the starting degree from which the circle drawing begins. The degree is measured in the standard polar coordinate system, which is counter-clockwise. ```R circos.par(start.degree = 90) ``` -------------------------------- ### get.current.sector.index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Get current sector index. ```APIDOC ## get.current.sector.index() ### Description Get current sector index. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r get.current.sector.index() ``` ### Response None specified in the source. ``` -------------------------------- ### Add points to a stacked track with dynamic size and color Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicPoints.html This example adds points to a stacked genomic track, with point size and color dynamically mapped from the data. It also draws reference lines. ```R circos.genomicTrack(bed_list, stack = TRUE, panel.fun = function(region, value, ...) { cex = (value[[1]] - min(value[[1]]))/(max(value[[1]]) - min(value[[1]])) i = getI(...) circos.genomicPoints(region, value, cex = cex, pch = 16, col = i, ...) cell.xlim = get.cell.meta.data("cell.xlim") circos.lines(cell.xlim, c(i, i), lty = 2, col = "#00000040") }) ``` -------------------------------- ### circos.par() Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Sets or gets parameters for the circular layout. ```APIDOC ## circos.par() ### Description Parameters for the circular layout. ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters N/A (R function) ### Request Example N/A (R function) ### Response N/A (R function) ``` -------------------------------- ### get.current.track.index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Get current track index. ```APIDOC ## get.current.track.index() ### Description Get current track index. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r get.current.track.index() ``` ### Response None specified in the source. ``` -------------------------------- ### Basic Violin Plot Example Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.violin.html Initializes a circos plot and draws multiple violin plots with default settings within a track. This is useful for visualizing distributions at different positions. ```R circos.initialize(letters[1:4], xlim = c(0, 10)) circos.track(ylim = c(0, 1), panel.fun = function(x, y) { for(pos in seq(0.5, 9.5, by = 1)) { value = runif(10) circos.violin(value, pos) } }) circos.clear() ``` -------------------------------- ### Plotting Genomic Points with Scaled Size and Color Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicPoints.html This example demonstrates plotting genomic points where the size (cex) and color are dynamically determined by the data values. It also adds a horizontal line for context using circos.lines. ```R [circos.genomicTrack](circos.genomicTrack.html)(bed, stack = TRUE, panel.fun = function(region, value, ...) { cex = (value[[1]] - [min](https://rdrr.io/r/base/Extremes.html)(value[[1]]))/([max](https://rdrr.io/r/base/Extremes.html)(value[[1]]) - [min](https://rdrr.io/r/base/Extremes.html)(value[[1]])) i = [getI](getI.html)(...) circos.genomicPoints(region, value, cex = cex, pch = 16, col = i, ...) cell.xlim = [get.cell.meta.data](get.cell.meta.data.html)("cell.xlim") [circos.lines](circos.lines.html)(cell.xlim, [c](https://rdrr.io/r/base/c.html)(i, i), lty = 2, col = "#00000040") }) ``` -------------------------------- ### Initialize with Human Species (hg18) Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the circular plot by automatically downloading cytoband data for a specified species, using 'hg18' as an example for human. ```R circos.initializeWithIdeogram(species = "hg18") ``` -------------------------------- ### Add specific points with custom styling Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.points.html Adds points to a specific sector and track with custom point shape and color. This example shows how to target a particular cell and override default graphical parameters. ```r circos.points(runif(10), runif(10), sector.index = "c", pch = 16, col = "red") ``` -------------------------------- ### Add points to a stacked genomic track Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicPoints.html This example shows how to add points to a stacked genomic track. It includes drawing dashed lines for visual reference within each cell. ```R circos.genomicTrack(bed, stack = TRUE, panel.fun = function(region, value, ...) { circos.genomicPoints(region, value, pch = 16, cex = 0.5, ...) i = getI(...) cell.xlim = get.cell.meta.data("cell.xlim") circos.lines(cell.xlim, c(i, i), lty = 2, col = "#00000040") }) ``` -------------------------------- ### Draw Genomic Rectangles with Specified Y-positions Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicRect.html This example shows how to draw genomic rectangles with explicitly defined top and bottom y-positions using the ytop and ybottom arguments. It also adds dashed lines to each cell, indicating the cell's y-position. ```R circos.genomicTrack(bed_list, ylim = c(0, 3), panel.fun = function(region, value, ...) { i = getI(...) circos.genomicRect(region, value, ytop = i+0.4, ybottom = i-0.4, col = f(value[[1]]), border = NA, ...) cell.xlim = get.cell.meta.data("cell.xlim") circos.lines(cell.xlim, c(i, i), lty = 2, col = "#000000") }) ``` -------------------------------- ### Draw Genomic Rectangles with Color Mapping Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicRect.html This example demonstrates drawing genomic rectangles using circos.genomicRect. It maps values from the input data to colors using a colorRamp2 function. It also adds dashed lines to each cell, indicating the cell's y-position. ```R circos.par("track.height" = 0.1, cell.padding = c(0, 0, 0, 0)) circos.initializeWithIdeogram(plotType = NULL) bed1 = generateRandomBed(nr = 100) bed2 = generateRandomBed(nr = 100) bed_list = list(bed1, bed2) f = colorRamp2(breaks = c(-1, 0, 1), colors = c("green", "black", "red")) circos.genomicTrack(bed_list, stack = TRUE, panel.fun = function(region, value, ...) { circos.genomicRect(region, value, col = f(value[[1]]), border = NA, ...) i = getI(...) cell.xlim = get.cell.meta.data("cell.xlim") circos.lines(cell.xlim, c(i, i), lty = 2, col = "#000000") }) ``` -------------------------------- ### getI Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Which data that `panel.fun` is using. ```APIDOC ## getI() ### Description Which data that `panel.fun` is using. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r getI() ``` ### Response None specified in the source. ``` -------------------------------- ### Initialize with tick labels starting from non-zero Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicInitialize.html Initializes a circular plot with a custom data frame, disabling tick labels from starting at zero. ```R circos.clear() circos.genomicInitialize(df, tickLabelsStartFromZero = FALSE) ``` -------------------------------- ### circos.initializeWithIdeogram() Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Initializes the circular layout using an ideogram. ```APIDOC ## circos.initializeWithIdeogram() ### Description Initialize the circular layout with an ideogram. ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters N/A (R function) ### Request Example N/A (R function) ### Response N/A (R function) ``` -------------------------------- ### circos.heatmap.initialize() Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Initializes circular heatmaps. ```APIDOC ## circos.heatmap.initialize() ### Description Initialize circular heatmaps. ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters N/A (R function) ### Request Example N/A (R function) ### Response N/A (R function) ``` -------------------------------- ### Real-time Clock with Circos Axis Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.axis.html Demonstrates how to create a real-time clock visualization using circos.axis. Requires initialization of circos plot and sectors. The loop updates clock hands every second. ```R if(FALSE) { ############### real-time clock ################# factors = letters[1] circos.par("gap.degree" = 0, "cell.padding" = c(0, 0, 0, 0), "start.degree" = 90) circos.initialize(sectors, xlim = c(0, 12)) circos.trackPlotRegion(sectors, ylim = c(0, 1), bg.border = NA) circos.axis(sector.index = "a", major.at = 0:12, labels = "", direction = "inside", major.tick.length = mm_y(3)) circos.text(1:12, rep(0.5, 12), 1:12, facing = "downward") while(1) { current.time = as.POSIXlt(Sys.time()) sec = ceiling(current.time$sec) min = current.time$min hour = current.time$hour # erase the clock hands draw.sector(rou1 = 0.8, border = "white", col = "white") sec.degree = 90 - sec/60 * 360 arrows(0, 0, cos(sec.degree/180*pi)*0.8, sin(sec.degree/180*pi)*0.8) min.degree = 90 - min/60 * 360 arrows(0, 0, cos(min.degree/180*pi)*0.7, sin(min.degree/180*pi)*0.7, lwd = 2) hour.degree = 90 - hour/12 * 360 - min/60 * 360/12 arrows(0, 0, cos(hour.degree/180*pi)*0.4, sin(hour.degree/180*pi)*0.4, lwd = 2) Sys.sleep(1) } circos.clear() } ``` -------------------------------- ### circos.heatmap.initialize Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.heatmap.initialize.html Initializes circular heatmaps by setting up the necessary structures and parameters based on the input matrix and optional configurations. ```APIDOC ## circos.heatmap.initialize ### Description Initializes circular heatmaps. ### Function Signature `circos.heatmap.initialize(mat, split = NULL, cluster = TRUE, clustering.method = "complete", distance.method = "euclidean", dend.callback = function(dend, m, si) reorder(dend, rowMeans(m))) ### Arguments * **mat** (matrix or vector) - The input data matrix or vector. If a vector, it is transformed into a one-column matrix. * **split** (categorical variable, optional) - Used to split the matrix into a list of matrices. * **cluster** (boolean, optional) - Whether to apply clustering on rows. Defaults to TRUE. * **clustering.method** (string, optional) - The clustering method to use, passed to `hclust`. Defaults to "complete". * **distance.method** (string, optional) - The distance method to use, passed to `dist`. Defaults to "euclidean". * **dend.callback** (function, optional) - A callback function applied to the dendrogram in every sector. Defaults to a function that reorders the dendrogram based on row means. ### See Also [https://jokergoo.github.io/2020/05/21/make-circular-heatmaps/](https://jokergoo.github.io/2020/05/21/make-circular-heatmaps/) ``` -------------------------------- ### get.cell.meta.data Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Get the meta data of a cell. ```APIDOC ## get.cell.meta.data() ### Description Get the meta data of a cell. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r get.cell.meta.data() ``` ### Response None specified in the source. ``` -------------------------------- ### Generate and display the first Chord diagram Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/calc_gap.html This snippet demonstrates how to create and visualize a Chord diagram using `chordDiagram`. It sets directional flow, grid colors, transparency, and specific gap values. ```R set.seed(123) mat1 = matrix(sample(20, 25, replace = TRUE), 5) chordDiagram(mat1, directional = 1, grid.col = rep(1:5, 2), transparency = 0.5, big.gap = 10, small.gap = 1) ``` -------------------------------- ### Initialize with default settings Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicInitialize.html Initializes a circular plot using genomic data from a cytoband data frame with default settings. ```R df = read.cytoband()$df circos.genomicInitialize(df) ``` -------------------------------- ### circos.polygon Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.polygon.html Draws a polygon on the circos plot. The start and end points of the polygon should overlap. ```APIDOC ## circos.polygon ### Description Draws a polygon on the circos plot. The start and end points of the polygon should overlap. ### Function Signature `circos.polygon(x, y, sector.index = get.current.sector.index(), track.index = get.current.track.index(), ...)` ### Arguments - **x** (numeric vector): Data points on the x-axis. - **y** (numeric vector): Data points on the y-axis. - **sector.index** (character or numeric): Index for the sector where the polygon will be drawn. Defaults to the current sector. - **track.index** (numeric): Index for the track where the polygon will be drawn. Defaults to the current track. - **...**: Additional arguments passed to the `polygon` function. ### Details This function is similar to the base R `polygon` function. Ensure that the start point of the polygon data overlaps with the end point for proper rendering. ``` -------------------------------- ### Get Current Sector Index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/get.current.sector.index.html Retrieves the name of the current sector. This function does not take any arguments. ```APIDOC ## get.current.sector.index() ### Description Retrieves the name of the current sector. ### Method Function Call ### Parameters This function does not take any parameters. ### Response #### Success Response - **sector_name** (string) - The name of the current sector. ### Response Example ```json "sector_name" ``` ``` -------------------------------- ### Initialize with Cytoband File Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the circular plot using a specified cytoband file. Ensure the file path is correct. ```R cytoband.file <- system.file(package = "circlize", "extdata", "cytoBand.txt") circos.initializeWithIdeogram(cytoband.file) ``` -------------------------------- ### Default Initialization Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the Circos plot with default settings. ```APIDOC ## Default Initialization ### Description Initializes the Circos plot with default settings. ### Method `circos.initializeWithIdeogram()` ### Parameters None ### Request Example ```R circos.initializeWithIdeogram() ``` ### Response None (modifies the Circos plotting state) ``` -------------------------------- ### Clear Circos Plot Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.barplot.html Clears the current circos plot. This should be called after drawing is complete or before starting a new plot. ```R circos.clear() ``` -------------------------------- ### cm_h Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/cm_h.html Converts units, specifically height, within the circlize package. For detailed usage and examples, refer to the convert_length documentation. ```APIDOC ## cm_h(h) ### Description Converts units, specifically height. ### Arguments #### h - **h** (numeric) - The height in numeric. ### Details See explanations in `[convert_length](convert_length.html)` page. ### Examples ```r # see examples in `convert_length` page NULL ``` ``` -------------------------------- ### Create a Matrix for Chord Diagram Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/chordDiagram.html Generates a sample matrix with specified dimensions and labels, suitable for input into the chordDiagram function. Ensure row and column names are set appropriately for your data. ```R set.seed(999) mat = matrix(sample(18, 18), 3, 6) rownames(mat) = paste0("S", 1:3) colnames(mat) = paste0("E", 1:6) ``` -------------------------------- ### Initialize Circos and Add Points Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.trackPoints.html Initializes a circos plot with 8 sectors and sets the x-axis limits. Then, it creates a data frame with random sectors, x, and y values. A track is added with y-axis limits, and finally, points are added to the track using circos.trackPoints with specified point type and color based on a factor. ```R circos.initialize(letters[1:8], xlim = c(0, 1)) df = data.frame(sectors = sample(letters[1:8], 100, replace = TRUE), x = runif(100), y = runif(100)) circos.track(ylim = c(0, 1)) circos.trackPoints(df$sectors, x = df$x, y = df$y, pch = 16, col = as.numeric(factor(df$fa))) circos.clear() ``` -------------------------------- ### Initialize with Default Cytoband Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the circular plot using the default cytoband data. This is a basic setup for a human genome ideogram. ```R circos.initializeWithIdeogram() ``` -------------------------------- ### Initialize with custom data frame Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicInitialize.html Initializes a circular plot using a custom data frame with gene names, start, and end positions. ```R df = data.frame(name = c("TP53", "TP63", "TP73"), start = c(7565097, 189349205, 3569084), end = c(7590856, 189615068, 3652765), stringsAsFactors = FALSE) circos.genomicInitialize(df) ``` -------------------------------- ### Get meta data names Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/names.CELL_META.html Use this function to retrieve all available meta data names for the current cell. It is an S3 method for CELL_META. ```R names(CELL_META) ``` -------------------------------- ### Initialize and Configure Tracks with Different Height Units Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/convert_length.html Demonstrates how to initialize a circular plot and add tracks with heights defined in millimeters, centimeters, and inches. This showcases the flexibility in specifying track dimensions using various units. ```R sectors = letters[1:10] circos.par(cell.padding = c(0, 0, 0, 0), track.margin = c(0, 0)) circcos.initialize(sectors, xlim = cbind(rep(0, 10), runif(10, 0.5, 1.5))) circcos.track(ylim = c(0, 1), track.height = mm_h(5)) circcos.par(track.margin = c(0, mm_h(2))) circcos.track(ylim = c(0, 1), track.height = cm_h(1)) circcos.par(track.margin = c(0, mm_h(5))) circcos.track(ylim = c(0, 1), track.height = inch_h(1)) circcos.clear() ``` -------------------------------- ### Draw Boxplots with Custom Colors Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.boxplot.html Demonstrates drawing multiple boxplots with distinct colors assigned to each. This example uses replicated random data for each boxplot. ```R circos.initialize(letters[1:4], xlim = c(0, 10)) circos.track(ylim = c(0, 1), panel.fun = function(x, y) { value = replicate(runif(10), n = 10, simplify = FALSE) circos.boxplot(value, 1:10 - 0.5, col = 1:10) }) circos.clear() ``` -------------------------------- ### circos.initialize Function Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initialize.html Initializes the circular layout by defining sectors and their properties. This function prepares the plotting area for creating circular visualizations. ```APIDOC ## circos.initialize ### Description Initializes the circular layout. ### Arguments * **sectors** (factor or character vector) - Represents data categories for sectors. * **x** (vector) - Data on x-axes. * **xlim** (vector or matrix) - Ranges for values on x-axes. * **sector.width** (vector) - Width for each sector. Can be a single value for all sectors or a vector with lengths equal to the number of sectors. * **factors** (factor or character vector) - Alias for `sectors`. Will be removed in future versions. ### Details The function allocates sectors based on x-axis values or `xlim`. Sector positions are calculated based on x-axis values or `xlim`. If `x` is provided, its length must match `factors`. If `xlim` is a matrix, row names should cover all sector names for automatic adjustment. Sector widths can be manually set but it's generally recommended to let the function calculate them based on data ranges. ### See Also [https://jokergoo.github.io/circlize_book/book/circular-layout.html](https://jokergoo.github.io/circlize_book/book/circular-layout.html) ``` -------------------------------- ### get.cell.meta.data Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/get.cell.meta.data.html Retrieves metadata for a specified cell. This function is useful within `panel.fun` to get detailed information about the current cell being rendered in a circular layout. ```APIDOC ## get.cell.meta.data ### Description Get the meta data of a cell. ### Method `get.cell.meta.data(name, sector.index = get.current.sector.index(), track.index = get.current.track.index()) ` ### Arguments * **name** - The name of the meta information to retrieve. Only one name is supported at a time. * **sector.index** - (Optional) The index of the sector. Defaults to the current sector index. * **track.index** - (Optional) The index of the track. Defaults to the current track index. ### Details The following meta information for a cell can be obtained: * `sector.index`: The name (index) for the sector * `sector.numeric.index`: Numeric index for the sector * `track.index`: Numeric index for the track * `xlim`: Minimal and maximal values on the x-axis * `ylim`: Minimal and maximal values on the y-axis * `xrange`: Range of `xlim`. It equals to `xlim[2] - xlim[1]` * `yrange`: Range of `ylim` * `xcenter`: Center of x-axis. It equals to `(xlim[2] + xlim[1])/2` * `ycenter`: Center of y-axis * `cell.xlim`: Minimal and maximal values on the x-axis extended by cell paddings * `cell.ylim`: Minimal and maximal values on the y-axis extended by cell paddings * `xplot`: Degrees for right and left borders of the cell. The values ignore the direction of the circular layout. * `yplot`: Radius for top and bottom borders of the cell. * `cell.width`: Width of the cell, in degrees. * `cell.height`: Height of the cell, simply `yplot[2] - yplot[1]` * `cell.start.degree`: Same as `xplot[1]` * `cell.end.degree`: Same as `xplot[2]` * `cell.bottom.radius`: Same as `yplot[1]` * `cell.top.radius`: Same as `yplot[2]` * `track.margin`: Margin for the cell * `cell.padding`: Padding for the cell ### Example ```r # Initialize circos sectors = letters[1:4] circo.initialize(sectors, xlim = c(0, 1)) # Plot a track and print xlim for each cell circos.trackPlotRegion(ylim = c(0, 1), panel.fun = function(x, y) { print(get.cell.meta.data("xlim")) }) # Get specific meta data print(get.cell.meta.data("xlim", sector.index = "a", track.index = 1)) # Clear circos circo.clear() ``` ``` -------------------------------- ### Add points to a genomic track Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicPoints.html This snippet demonstrates how to add points to a genomic track using circos.genomicPoints. It requires prior setup with circos.par and circos.initializeWithIdeogram. ```R circos.par("track.height" = 0.1) circos.initializeWithIdeogram(plotType = NULL) bed = generateRandomBed(nr = 100) circos.genomicTrack(bed, panel.fun = function(region, value, ...) { circos.genomicPoints(region, value, pch = 16, cex = 0.5, ...) }) ``` -------------------------------- ### highlight.sector Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Highlight sectors and tracks. ```APIDOC ## highlight.sector() ### Description Highlight sectors and tracks. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r highlight.sector() ``` ### Response None specified in the source. ``` -------------------------------- ### Get X-axis Limits for Current Cell Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/get.cell.meta.data.html Demonstrates how to retrieve the x-axis limits of the current cell within a track. This is useful for understanding the plotting boundaries for the active cell. ```R sectors <- letters[1:4] circos.initialize(sectors, xlim = c(0, 1)) circos.trackPlotRegion(ylim = c(0, 1), panel.fun = function(x, y) { print(get.cell.meta.data("xlim")) }) ``` -------------------------------- ### circos.genomicInitialize() Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Initializes a circular plot with any genomic data. ```APIDOC ## circos.genomicInitialize() ### Description Initialize circular plot with any genomic data. ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters N/A (R function) ### Request Example N/A (R function) ### Response N/A (R function) ``` -------------------------------- ### Initialize Circos with Ideogram and Add Genomic Axis Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicAxis.html Initializes a circos plot with an ideogram and adds a genomic axis to the top of the plot. This is a common setup for genomic visualizations. ```R circos.initializeWithIdeogram(chromosome.index = paste0("chr", 1:4), plotType = NULL) circos.track(ylim = c(0, 1), panel.fun = function(x, y) circos.genomicAxis()) ``` -------------------------------- ### Initialize with Mouse Species (mm10) Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the circular plot by automatically downloading cytoband data for a specified species, using 'mm10' for mouse. ```R circos.initializeWithIdeogram(species = "mm10") ``` -------------------------------- ### Get X-axis Limits for a Specific Cell Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/get.cell.meta.data.html Shows how to retrieve the x-axis limits for a specific cell identified by its sector and track index. This allows targeted data retrieval for non-current cells. ```R print(get.cell.meta.data("xlim", sector.index = "a", track.index = 1)) ``` -------------------------------- ### show.index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/index.html Label the sector index and the track index on each cell. ```APIDOC ## show.index() ### Description Label the sector index and the track index on each cell. ### Method Not specified (likely a function call in an R package) ### Endpoint Not applicable (function call) ### Parameters None specified in the source. ### Request Example ```r show.index() ``` ### Response None specified in the source. ``` -------------------------------- ### Basic Sector Drawing Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/draw.sector.html Draws a basic sector with default parameters. Requires a plot to be initialized. ```R plot(c(-1, 1), c(-1, 1), type = "n", axes = FALSE, ann = FALSE, asp = 1) draw.sector(20, 0) ``` -------------------------------- ### Draw segments between points Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.segments.html This example demonstrates how to draw multiple segments within a circos plot. It initializes the circos plot, defines a track, and then uses circos.segments to draw horizontal and vertical lines. ```R circos.initialize(letters[1:8], xlim = c(0, 1)) circos.track(ylim = c(0, 1), track.height = 0.3, panel.fun = function(x, y) { x = seq(0.2, 0.8, by = 0.2) y = seq(0.2, 0.8, by = 0.2) circos.segments(x, 0.1, x, 0.9) circos.segments(0.1, y, 0.9, y) }) circos.clear() ``` -------------------------------- ### Draw Genomic Rectangles with Color as Index Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicRect.html This example draws genomic rectangles where the color of each rectangle is determined by its index within the track. This provides a simple way to differentiate adjacent rectangles visually. ```R circos.genomicTrack(bed_list, panel.fun = function(region, value, ...) { i = getI(...) circos.genomicRect(region, value, col = i, border = NA, ...) }) ``` -------------------------------- ### Draw Arrows with Different Tail Shapes Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.arrow.html Example demonstrating how to draw arrows with different tail shapes ('point' and 'normal') within a circos track. The arrow position is set to 'end' by default. ```R op = par(no.readonly = TRUE) par(mfrow = c(1, 2)) circos.initialize(letters[1:4], xlim = c(0, 1)) col = rand_color(4) tail = c("point", "normal", "point", "normal") circos.track(ylim = c(0, 1), panel.fun = function(x, y) { circos.arrow(x1 = 0, x2 = 1, y = 0.5, width = 0.4, arrow.head.width = 0.6, arrow.head.length = cm_x(1), col = col[CELL_META$sector.numeric.index], tail = tail[CELL_META$sector.numeric.index]) }, bg.border = NA, track.height = 0.4) circos.clear() ``` -------------------------------- ### Initialize and Highlight Sectors Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/highlight.sector.html Initializes a circular plot with sectors and then highlights specific sectors with different colors and borders. This is useful for visually distinguishing parts of the circular plot. ```R sectors <- letters[1:8] circos.initialize(sectors, xlim = c(0, 1)) for(i in 1:4) { circos.trackPlotRegion(ylim = c(0, 1)) } circos.info(plot = TRUE) highlight.sector(c("a", "h"), track.index = 1) highlight.sector("c", col = "#00FF0040") highlight.sector("d", col = NA, border = "red", lwd = 2) highlight.sector("e", col = "#0000FF40", track.index = c(2, 3)) highlight.sector(c("f", "g"), col = NA, border = "green", lwd = 2, track.index = c(2, 3)) highlight.sector(sectors, col = "#FFFF0040", track.index = 4) circos.clear() ``` -------------------------------- ### Create Chord Diagram from Matrix Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/chordDiagram.html Generates a chord diagram directly from a numeric matrix. Ensure the matrix is properly formatted. ```R df <- data.frame(from = rep(rownames(mat), times = ncol(mat)), to = rep(colnames(mat), each = nrow(mat)), value = as.vector(mat), stringsAsFactors = FALSE) chordDiagram(mat) ``` -------------------------------- ### Initialize with custom sector names Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.genomicInitialize.html Initializes a circular plot with a custom data frame and provides custom names for each sector. ```R circos.clear() circos.genomicInitialize(df, sector.names = c("tp53", "tp63", "tp73")) ``` -------------------------------- ### Apply color interpolation function Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/colorRamp2.html Applies the generated color interpolation function to a vector of numeric values to get corresponding colors. Values outside the defined breaks will be assigned the color of the nearest break. ```R col_fun(c(-2, -1, -0.5, 0, 0.5, 1, 2)) ``` -------------------------------- ### circos.initializeWithIdeogram Source: https://github.com/jokergoo/circlize/blob/master/docs/reference/circos.initializeWithIdeogram.html Initializes the circular plot with chromosome ideograms. It can take a path to a cytoband file, a species name to download data, or a pre-read data frame. It also allows customization of chromosome sorting and which components to plot. ```APIDOC ## circos.initializeWithIdeogram ### Description Initializes the circular plot where each sector corresponds to a chromosome. It can use a cytoband file or download species-specific data. Options are available to control chromosome order, sorting, and what elements (ideogram, axis, labels) are drawn. ### Arguments * **cytoband** (path or data frame) - Path to the cytoband file or a data frame containing cytoband data. Defaults to hg19 cytoband. * **species** (string, optional) - Abbreviation for species (e.g., "hg19", "mm10"). If specified, downloads cytoband data from UCSC. * **sort.chr** (boolean) - Whether to sort chromosome names. Defaults to TRUE. If `chromosome.index` is set, this is enforced to FALSE. * **chromosome.index** (vector, optional) - A subset of chromosomes to use and to reorder chromosomes. * **major.by** (numeric, optional) - Increment for major ticks. Passed to `circos.genomicInitialize`. * **plotType** (vector of strings) - Which tracks to draw: "ideogram", "axis", "labels". Defaults to c("ideogram", "axis", "labels"). If no ideogram is available for the species, "ideogram" is excluded. If NULL, only initializes the plot without drawing. * **track.height** (numeric, optional) - Height of the track containing "axis" and "labels". * **ideogram.height** (numeric, optional) - Height of the ideogram track. Defaults to convert_height(2, "mm"). * **...** - Additional arguments passed to `circos.genomicInitialize`. ### Details This function prepares the circular plot for genomic data visualization. It handles the loading and ordering of chromosome information, passing the processed data to `circos.genomicInitialize`. Customization of the ideogram style is possible through user-defined code. ### See Also [https://jokergoo.github.io/circlize_book/book/initialize-genomic-plot.html#initialize-cytoband](https://jokergoo.github.io/circlize_book/book/initialize-genomic-plot.html#initialize-cytoband) ### Examples ```R # Initialize with default settings (hg19 cytoband) circos.initializeWithIdeogram() # Initialize using a local cytoband file cytoband.file <- system.file(package = "circlize", "extdata", "cytoBand.txt") circos.initializeWithIdeogram(cytoband.file) # Initialize using a species name (e.g., human hg18) circos.initializeWithIdeogram(species = "hg18") # Initialize using a specific subset of chromosomes circos.initializeWithIdeogram(chromosome.index = c("chr1", "chr2")) # Initialize with custom chromosome order and no sorting cytoband <- read.table(cytoband.file, sep = "\t", colClasses = c("character", "numeric", "numeric", "character", "character")) circos.initializeWithIdeogram(cytoband, sort.chr = FALSE) # Initialize with custom factor levels for chromosome order cytoband[[1]] <- factor(cytoband[[1]], levels = paste0("chr", c(22:1, "X", "Y"))) circos.initializeWithIdeogram(cytoband, sort.chr = FALSE) ``` ```