@@ -145,77 +145,80 @@ plotPairs <- function(se, selAssay = "counts", doLog = TRUE, pseudocount = 1,
145145 # # ----------------------------------------------------------------------- ##
146146 # # Scatter plots
147147 # # ----------------------------------------------------------------------- ##
148- # # Define function to create smoothscatter-like plot (for use with ggpairs)
149- smoothscat <- function (data , mapping , ... ) {
150- ggplot2 :: ggplot(data = data , mapping = mapping ) +
151- ggplot2 :: stat_density2d(ggplot2 :: aes(fill = ggplot2 :: after_stat(.data $ density )^ 0.25 ), geom = " tile" ,
152- contour = FALSE , n = 200 ) +
153- ggplot2 :: scale_fill_continuous(low = " white" , high = " darkgreen" ) +
154- ggtheme +
155- ggplot2 :: scale_x_continuous(expand = c(0 , 0 )) +
156- ggplot2 :: scale_y_continuous(expand = c(0 , 0 ))
157- }
158-
159- # # Define function to create scatter plot (for use with ggpairs)
160- if (addIdentityLine ) {
161- plotpoints <- function (data , mapping , ... ) {
162- ggplot2 :: ggplot(data = data , mapping = mapping ) +
163- ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
164- linetype = " dashed" , color = " grey" ) +
165- ggplot2 :: geom_point(alpha = pointAlpha , size = pointSize ) +
166- ggtheme
167- }
168- } else {
169- plotpoints <- function (data , mapping , ... ) {
170- ggplot2 :: ggplot(data = data , mapping = mapping ) +
171- ggplot2 :: geom_point(alpha = pointAlpha , size = pointSize ) +
172- ggtheme
173- }
174- }
175-
176- # # Define function to create scattermore plot (for use with ggpairs)
177- if (addIdentityLine ) {
178- plotscattermore <- function (data , mapping , ... ) {
148+ if (pointsType == " smoothscatter" ) {
149+ # # Define function to create smoothscatter-like plot (for use with ggpairs)
150+ smoothscat <- function (data , mapping , ... ) {
179151 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
152+ ggplot2 :: stat_density2d(
153+ ggplot2 :: aes(fill = ggplot2 :: after_stat(.data $ density )^ 0.25 ), geom = " tile" ,
154+ contour = FALSE , n = 200 ) +
155+ ggplot2 :: scale_fill_continuous(low = " white" , high = " darkgreen" ) +
156+ ggtheme +
157+ ggplot2 :: scale_x_continuous(expand = c(0 , 0 )) +
158+ ggplot2 :: scale_y_continuous(expand = c(0 , 0 ))
185159 }
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
160+ } else if (pointsType == " points" ) {
161+ # # Define function to create scatter plot (for use with ggpairs)
162+ if (addIdentityLine ) {
163+ plotpoints <- function (data , mapping , ... ) {
164+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
165+ ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
166+ linetype = " dashed" , color = " grey" ) +
167+ ggplot2 :: geom_point(alpha = pointAlpha , size = pointSize ) +
168+ ggtheme
169+ }
170+ } else {
171+ plotpoints <- function (data , mapping , ... ) {
172+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
173+ ggplot2 :: geom_point(alpha = pointAlpha , size = pointSize ) +
174+ ggtheme
175+ }
192176 }
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
177+ } else if (pointsType == " scattermore" ) {
178+ # # Define function to create scattermore plot (for use with ggpairs)
179+ if (addIdentityLine ) {
180+ plotscattermore <- function (data , mapping , ... ) {
181+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
182+ ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
183+ linetype = " dashed" , color = " grey" ) +
184+ scattermore :: geom_scattermore(alpha = pointAlpha ,
185+ pointsize = pointSize ) +
186+ ggtheme
187+ }
188+ } else {
189+ plotscattermore <- function (data , mapping , ... ) {
190+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
191+ scattermore :: geom_scattermore(alpha = pointAlpha ,
192+ pointsize = pointSize ) +
193+ ggtheme
194+ }
208195 }
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
196+ } else if (pointsType == " scattermost" ) {
197+ # # Define function to create scattermost plot (for use with ggpairs)
198+ if (addIdentityLine ) {
199+ plotscattermost <- function (data , mapping , ... ) {
200+ # # Get data
201+ xData <- GGally :: eval_data_col(data , mapping $ x )
202+ yData <- GGally :: eval_data_col(data , mapping $ y )
203+
204+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
205+ ggplot2 :: geom_abline(slope = 1 , intercept = 0 ,
206+ linetype = " dashed" , color = " grey" ) +
207+ scattermore :: geom_scattermost(xy = cbind(xData , yData ),
208+ pointsize = pointSize ) +
209+ ggtheme
210+ }
211+ } else {
212+ plotscattermost <- function (data , mapping , ... ) {
213+ # # Get data
214+ xData <- GGally :: eval_data_col(data , mapping $ x )
215+ yData <- GGally :: eval_data_col(data , mapping $ y )
216+
217+ ggplot2 :: ggplot(data = data , mapping = mapping ) +
218+ scattermore :: geom_scattermost(xy = cbind(xData , yData ),
219+ pointsize = pointSize ) +
220+ ggtheme
221+ }
219222 }
220223 }
221224
0 commit comments