|
a |
|
b/man/spiral_newrle.Rd |
|
|
1 |
% Generated by roxygen2: do not edit by hand |
|
|
2 |
% Please edit documentation in R/EnrichmentSpiralize.R |
|
|
3 |
\name{spiral_newrle} |
|
|
4 |
\alias{spiral_newrle} |
|
|
5 |
\title{Render a Spiral Plot Using Run-Length Encoding} |
|
|
6 |
\usage{ |
|
|
7 |
spiral_newrle(x, samples, values, colors, labels = FALSE) |
|
|
8 |
} |
|
|
9 |
\arguments{ |
|
|
10 |
\item{x}{A vector representing categories or segments.} |
|
|
11 |
|
|
|
12 |
\item{samples}{A vector indicating the sample each segment belongs to.} |
|
|
13 |
|
|
|
14 |
\item{values}{Numeric vector indicating the lengths of each segment.} |
|
|
15 |
|
|
|
16 |
\item{colors}{Character vector specifying the colors for each segment.} |
|
|
17 |
|
|
|
18 |
\item{labels}{Logical, whether to add labels to each segment.} |
|
|
19 |
} |
|
|
20 |
\value{ |
|
|
21 |
No return value, called for side effects. This function generates a spiral plot and optionally adds labels. |
|
|
22 |
} |
|
|
23 |
\description{ |
|
|
24 |
This function creates a spiral plot for visualizing sequential data in a compact and visually appealing way. |
|
|
25 |
It uses run-length encoding to represent the lengths and colors of sequences in the spiral. |
|
|
26 |
} |
|
|
27 |
\examples{ |
|
|
28 |
# Example: Creating a spiral plot using the spiral_newrle function |
|
|
29 |
|
|
|
30 |
# Define example data |
|
|
31 |
x <- c("A", "A", "B", "C") |
|
|
32 |
samples <- c("Sample1", "Sample1", "Sample2", "Sample2") |
|
|
33 |
values <- c(20, 30, 15, 35) |
|
|
34 |
colors <- c("red", "blue", "green", "purple") |
|
|
35 |
labels <- TRUE |
|
|
36 |
|
|
|
37 |
# Initialize the spiral plot, setting the x-axis range and scaling |
|
|
38 |
spiralize::spiral_initialize(xlim = c(0, sum(values)), scale_by = "curve_length", |
|
|
39 |
vp_param = list(x = grid::unit(0, "npc"), just = "left")) |
|
|
40 |
|
|
|
41 |
# Create a track for the spiral plot |
|
|
42 |
spiralize::spiral_track(height = 0.5) |
|
|
43 |
|
|
|
44 |
# Add segments to the spiral plot using run-length encoding |
|
|
45 |
spiral_newrle(x, samples, values, colors, labels) |
|
|
46 |
|
|
|
47 |
} |