Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Fix bug where the x-axis only renders when y-axis is also rendered.
* Fix issue when creating polygons with more than 2 siblings
* Use updated `R CMD check` CI/CD action
* `plotting.direction` generalizable to fishplots with CCF polygons

## Bug
* Resolved issue where the spread parameter was not applied in dendrogram mode.
Expand Down
1 change: 1 addition & 0 deletions R/SRCGrob.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ SRCGrob <- function(
axis.cex = axis.cex,
xaxis.label = xaxis.label,
min.width = min.width,
horizontal.padding = horizontal.padding,
label.nodes = label.nodes,
node.col = node.col,
label.cex = label.cex,
Expand Down
12 changes: 11 additions & 1 deletion R/make.clone.tree.grobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ make.clone.tree.grobs <- function(
xaxis.label,
min.width,
node.radius,
horizontal.padding = 0,
label.nodes,
node.col,
label.cex,
Expand Down Expand Up @@ -140,13 +141,22 @@ make.clone.tree.grobs <- function(
}
}

is.horizontal.direction <- if (is.character(plotting.direction)) {
plotting.direction %in% c('left', 'right')
} else {
sa <- start.angle %% (2 * pi);
abs(sa - pi / 2) < pi / 4 || abs(sa - 3 * pi / 2) < pi / 4
}

plot.size <- calculate.main.plot.size(
clone.out,
scale1,
wid,
min.width,
node.radius,
start.angle = start.angle
start.angle = start.angle,
horizontal.padding = if (is.horizontal.direction) 0 else horizontal.padding,
vertical.padding = if (is.horizontal.direction) horizontal.padding else 0
);

if (!no.ccf) {
Expand Down
25 changes: 15 additions & 10 deletions R/set.up.plot.area.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ calculate.main.plot.size <- function(
wid,
min.width,
node.radius,
start.angle = 0
start.angle = 0,
horizontal.padding = 0,
vertical.padding = 0
) {

padding <- 2 * node.radius / scale1;
x.padding <- horizontal.padding / scale1;
y.padding <- vertical.padding / scale1;

all.x <- clone.out$v$x;
all.y <- clone.out$v$y;
Expand All @@ -25,10 +28,10 @@ calculate.main.plot.size <- function(
all.y <- c(all.y, unlist(lapply(clone.out$clones, function(cl) cl$y)));
}

xmin <- min(all.x);
xmax <- max(all.x);
ymin <- min(all.y);
ymax <- max(all.y);
xmin <- min(all.x) - x.padding;
xmax <- max(all.x) + x.padding;
ymin <- min(all.y) - y.padding;
ymax <- max(all.y) + y.padding;

# Guard against degenerate scales (e.g. all nodes at x=0 when polygons are disabled)
if (xmax == xmin) {
Expand Down Expand Up @@ -163,7 +166,10 @@ add.axes <- function(

# Skip x-axis if plotting.direction is numeric (custom angle)
draw.xaxis <- !is.numeric(plotting.direction);

if (plotting.direction != 'down') {
message('Non-vertical plotting direction detected; skipping (nSNV) x-axis rendering.');
yaxis.position <- 'none';
}
if (!no.ccf && 'ccf' %in% colnames(clone.out$v) && all(!is.na(clone.out$v$ccf)) && draw.xaxis) {
add.xaxis(
clone.out,
Expand Down Expand Up @@ -320,8 +326,7 @@ add.xaxis <- function(
gp = gpar(cex = axis.label.cex),
main = (axis.position == 'left')
);
# clone.out$ylims <- unit(clone.out$ylims * 1.5, 'native')
xaxis <- extend.axis(xaxis, unit(clone.out$ylims * 1.5, 'native'), type = 'y');
xaxis <- extend.axis(xaxis, unit(clone.out$ylims, 'native'), type = 'y');
} else {
# For vertical plots, use xaxisGrob
xaxis <- xaxisGrob(
Expand All @@ -331,7 +336,7 @@ add.xaxis <- function(
gp = gpar(cex = axis.label.cex),
main = (axis.position == 'bottom')
);
xaxis <- extend.axis(xaxis, unit(clone.out$xlims * 1.5, 'native'), type = 'x');
xaxis <- extend.axis(xaxis, unit(clone.out$xlims, 'native'), type = 'x');
}
# Add the axis label
xaxis.gTree <- add.axis.label(
Expand Down
Loading