2323# ' to calculate.
2424# ' @param histBreaks Numeric scalar, the number of breaks in the histograms
2525# ' to put in the diagonal panels.
26- # ' @param pointsType Either "points" or "smoothscatter", determining the
27- # ' type of plots that will be made.
26+ # ' @param pointsType Either "points", "smoothscatter", "scattermore" or
27+ # ' "scattermost" (the latter two require the "scattermore" package to be
28+ # ' installed), determining the type of plots that will be made.
2829# ' @param corSizeMult,corSizeAdd Numeric scalars determining how the
2930# ' absolute correlation value is transformed into a font size. The
3031# ' transformation is corSizeMult * abs(corr) + corSizeAdd.
@@ -71,7 +72,8 @@ plotPairs <- function(se, selAssay = "counts", doLog = TRUE, pseudocount = 1,
7172 validValues = c(" pearson" , " spearman" ))
7273 .assertScalar(x = histBreaks , type = " numeric" , rngExcl = c(0 , Inf ))
7374 .assertScalar(x = pointsType , type = " character" ,
74- validValues = c(" smoothscatter" , " points" ))
75+ validValues = c(" smoothscatter" , " points" , " scattermore" ,
76+ " scattermost" ))
7577 .assertScalar(x = corSizeMult , type = " numeric" , rngExcl = c(0 , Inf ))
7678 .assertScalar(x = corSizeAdd , type = " numeric" , rngIncl = c(0 , Inf ))
7779 .assertScalar(x = pointSize , type = " numeric" , rngExcl = c(0 , Inf ))
@@ -83,6 +85,9 @@ plotPairs <- function(se, selAssay = "counts", doLog = TRUE, pseudocount = 1,
8385 stopifnot(corrColorRange [2 ] > = corrColorRange [1 ])
8486 }
8587 .assertScalar(x = addIdentityLine , type = " logical" )
88+ if (pointsType %in% c(" scattermore" , " scattermost" )) {
89+ .assertPackagesAvailable(" scattermore" )
90+ }
8691
8792 # # ----------------------------------------------------------------------- ##
8893 # # Define shared theme elements
@@ -168,11 +173,61 @@ plotPairs <- function(se, selAssay = "counts", doLog = TRUE, pseudocount = 1,
168173 }
169174 }
170175
176+ # # Define function to create scattermore plot (for use with ggpairs)
177+ if (addIdentityLine ) {
178+ plotscattermore <- function (data , mapping , ... ) {
179+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
180+ ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
181+ linetype = " dashed" , color = " grey" ) +
182+ scattermore :: geom_scattermore(alpha = pointAlpha ,
183+ pointsize = pointSize ) +
184+ ggtheme
185+ }
186+ } else {
187+ plotscattermore <- function (data , mapping , ... ) {
188+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
189+ scattermore :: geom_scattermore(alpha = pointAlpha ,
190+ pointsize = pointSize ) +
191+ ggtheme
192+ }
193+ }
194+
195+ # # Define function to create scattermost plot (for use with ggpairs)
196+ if (addIdentityLine ) {
197+ plotscattermost <- function (data , mapping , ... ) {
198+ # # Get data
199+ xData <- GGally :: eval_data_col(data , mapping $ x )
200+ yData <- GGally :: eval_data_col(data , mapping $ y )
201+
202+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
203+ ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
204+ linetype = " dashed" , color = " grey" ) +
205+ scattermore :: geom_scattermost(xy = cbind(xData , yData ),
206+ pointsize = pointSize ) +
207+ ggtheme
208+ }
209+ } else {
210+ plotscattermost <- function (data , mapping , ... ) {
211+ # # Get data
212+ xData <- GGally :: eval_data_col(data , mapping $ x )
213+ yData <- GGally :: eval_data_col(data , mapping $ y )
214+
215+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
216+ scattermore :: geom_scattermost(xy = cbind(xData , yData ),
217+ pointsize = pointSize ) +
218+ ggtheme
219+ }
220+ }
221+
171222 # # Define the function to use for the plots
172223 if (pointsType == " smoothscatter" ) {
173224 lower <- list (continuous = smoothscat )
174225 } else if (pointsType == " points" ) {
175226 lower <- list (continuous = plotpoints )
227+ } else if (pointsType == " scattermore" ) {
228+ lower <- list (continuous = plotscattermore )
229+ } else if (pointsType == " scattermost" ) {
230+ lower <- list (continuous = plotscattermost )
176231 }
177232
178233 # # ----------------------------------------------------------------------- ##
0 commit comments