@@ -68,11 +68,11 @@ globalVariables(names = c("bin", "score", "bw"), package = "Signac")
6868# ' for every region.
6969# ' @param ranges.title Y-axis title for ranges track. Only
7070# ' relevant if `ranges_list` parameter is set.
71- # ' @param max.downsample Minimum number of positions kept when
72- # ' downsampling. Downsampling rate is adaptive to the window
73- # ' size, but this parameter will set the minimum possible
74- # ' number of positions to include so that plots do not become
75- # ' too sparse when the window size is small.
71+ # ' @param max.downsample Maximum amount of downsampling to apply. Corresponds to
72+ # ' the minimum number of positions to be kept when downsampling. The
73+ # ' downsampling rate is adaptive to the window size, but this parameter will set
74+ # ' the minimum possible number of positions to include so that plots do not
75+ # ' become too sparse when the window size is small.
7676# ' @param downsample.rate Fraction of positions to retain when
7777# ' downsampling. Retaining more positions can give a
7878# ' higher-resolution plot but can make the number of points
@@ -596,8 +596,9 @@ MultiCoveragePlot <- function(
596596# ' help remove the effect of extreme values that may otherwise distort the
597597# ' scale.
598598# ' - numeric: manually define a Y-axis limit
599- # ' @param max.downsample Minimum number of positions kept when downsampling.
600- # ' Downsampling rate is adaptive to the window size, but this parameter will set
599+ # ' @param max.downsample Maximum amount of downsampling to apply. Corresponds to
600+ # ' the minimum number of positions to be kept when downsampling. The
601+ # ' downsampling rate is adaptive to the window size, but this parameter will set
601602# ' the minimum possible number of positions to include so that plots do not
602603# ' become too sparse when the window size is small.
603604# ' @param downsample.rate Fraction of positions to retain when downsampling.
@@ -681,8 +682,8 @@ BigwigTrack <- function(
681682 }
682683 all.data $ bw <- factor (x = all.data $ bw , levels = names(x = bigwig ))
683684 window.size <- width(x = region )
684- sampling <- ceiling( x = max( max .downsample , window.size * downsample.rate ) )
685- coverages <- slice_sample(.data = all.data , n = sampling )
685+ sampling <- min( max.downsample , window.size * downsample.rate )
686+ coverages <- slice_sample(.data = all.data , n = as.integer( x = sampling ) )
686687
687688 covmax <- signif(x = max(coverages $ score , na.rm = TRUE ), digits = 2 )
688689 if (is.null(x = ymax )) {
@@ -2005,7 +2006,8 @@ SingleCoveragePlot <- function(
20052006 bigwig = bigwig [bw.use ],
20062007 type = unique.types [[i ]],
20072008 bigwig.scale = bigwig.scale ,
2008- ymax = ymax
2009+ ymax = ymax ,
2010+ max.downsample = max.downsample
20092011 )
20102012 }
20112013 bigwig.tracks <- CombineTracks(
@@ -2530,8 +2532,9 @@ CoverageTrack <- function(
25302532# ' for each combination of celltype and batch.
25312533# ' @param heights Relative heights for each track (accessibility, gene
25322534# ' annotations, peaks, links).
2533- # ' @param max.downsample Minimum number of positions kept when downsampling.
2534- # ' Downsampling rate is adaptive to the window size, but this parameter will set
2535+ # ' @param max.downsample Maximum amount of downsampling to apply. Corresponds to
2536+ # ' the minimum number of positions to be kept when downsampling. The
2537+ # ' downsampling rate is adaptive to the window size, but this parameter will set
25352538# ' the minimum possible number of positions to include so that plots do not
25362539# ' become too sparse when the window size is small.
25372540# ' @param downsample.rate Fraction of positions to retain when downsampling.
0 commit comments