You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to create a circular plot with mixed results.
I'm trying to make a plot with stacked bars for ancestry values in one track, diversity values as points in a separate track, along with a yaxis label for each along chr_1, and the x axis would be the chrom labels and track. Furthermore, I'm trying to create black dashed boxes around relevant genes in my study.
"Error: There is no numeric column in your data frame which calculation of ylim depends on. Or you can set ylim explicitely."
I'm not understanding the error since all of my variables are numeric besides chr, which should be fine? I have tried setting ylim explicitly and I still get the same error.
Thanks,
The text was updated successfully, but these errors were encountered:
Hi there,
I'm very new to creating circular plots! :)
I have been trying to create a circular plot with mixed results.
I'm trying to make a plot with stacked bars for ancestry values in one track, diversity values as points in a separate track, along with a yaxis label for each along chr_1, and the x axis would be the chrom labels and track. Furthermore, I'm trying to create black dashed boxes around relevant genes in my study.
Here is what the code looks like:
plot_single_population_circle <- function(
genome_info_bed,
bed_hsp_filtered,
diversity_win,
ancestry_win,
diversity_col,
ancestry_cols,
ancestry_labels,
pop_name,
outfile
) {
diversity_win$pi <- as.numeric(diversity_win$pi)
ancestry_win$African <- as.numeric(ancestry_win$African)
ancestry_win$EastEurope <- as.numeric(ancestry_win$EastEurope)
ancestry_win$MiddleEast <- as.numeric(ancestry_win$MiddleEast)
ancestry_win$WestEurope <- as.numeric(ancestry_win$WestEurope)
ragg::agg_png(outfile, width=12, height=12, units="in", res=300)
op <- par(no.readonly = TRUE)
par(mar = c(1, 1, 1, 1), oma = c(0, 0, 0, 0))
circos.clear()
circos.par(gap.degree = 5)
circos.genomicInitialize(genome_info_bed, major.by = 5e6)
circos.genomicTrackPlotRegion(
genome_info_bed,
panel.fun = function(region, value, ...) {
circos.genomicLabels(
genome_info_bed,
labels.column = 1,
side = "outside",
niceFacing = TRUE
)
},
track.height = 0.05
)
circos.genomicTrack(
diversity_win,
panel.fun = function(region, value, ...) {
circos.genomicPoints(region, value$pi, pch=16, col=diversity_col, cex=0.5)
},
track.height = 0.1
)
circos.yaxis(side = "left")
circos.genomicTrack(
ancestry_win,
panel.fun = function(region, value, ...) {
ancestry_cols <- c("red", "gold", "cyan2", "black")
running_bottom <- 0
for(i in seq_along(ancestry_cols)) {
height <- value[[ i ]] # the fraction
ybottom <- running_bottom
ytop <- ybottom + height
circos.genomicRect(
region,
ybottom = ybottom,
ytop = ytop,
col = ancestry_cols[i],
border = NA
)
running_bottom <- ytop
}
},
track.height = 0.15
)
circos.yaxis(side = "right")
gene_bins <- bed_hsp_filtered %>%
mutate(bin = floor(start / 1e4))
circos.genomicTrackPlotRegion(
gene_bins,
panel.fun = function(region, value, ...) {
circos.genomicRect(
region,
ybottom = 0,
ytop = 1,
border = "black",
lty = 2,
col = NA
)
},
track.height = 0.2
)
legend (under construction)
pushViewport(viewport(x = unit(0.85, "npc"), y = unit(0.85, "npc"),
width=unit(0.15, "npc"), height=unit(0.15,"npc"),
just=c("left", "top")))
grid.text("Ancestry", x=unit(0, "npc"), y=unit(1, "npc"), just=c("left","top"))
popViewport()
par(op)
dev.off()
}
SoCal
plot_single_population_circle(
genome_info_bed = genome_info_bed,
bed_hsp_filtered = bed_hsp_filtered,
diversity_win = diversity_socal_win,
ancestry_win = ancestry_socal_win,
diversity_col = "#ab2f5e",
ancestry_cols = c("red","gold","cyan2","black"),
ancestry_labels = c("African","EastEurope","MiddleEast","WestEurope"),
pop_name = "SoCal",
outfile = "socal_circle_plot.png"
)
Here is the structure of my data:
"Error: There is no numeric column in your data frame which calculation of
ylim
depends on. Or you can setylim
explicitely."I'm not understanding the error since all of my variables are numeric besides chr, which should be fine? I have tried setting ylim explicitly and I still get the same error.
Thanks,
The text was updated successfully, but these errors were encountered: