... | ... |
@@ -12,6 +12,7 @@ |
12 | 12 |
#' @param showTrendLine boolean, whether to show the trendline |
13 | 13 |
#' @param showTitle boolean, whether to show the title |
14 | 14 |
#' @param alpha value from 0-1, where 0 indicates transparent points |
15 |
+#' @param numberColPrefix a prefix to add to column names that start with a number that causes issues with ggplot (DEFAULT: X) |
|
15 | 16 |
#' |
16 | 17 |
#' @return a ggplot object |
17 | 18 |
#' |
... | ... |
@@ -44,7 +45,7 @@ |
44 | 45 |
plotCellMiner2D <- function(df, xCol="x", yCol="y", xLabel=xCol, yLabel=yCol, |
45 | 46 |
title=NULL, colorPalette=NULL, classCol=NULL, tooltipCol=NULL, |
46 | 47 |
showLegend=FALSE, showTrendLine=TRUE, showTitle=TRUE, |
47 |
- alpha=1) { |
|
48 |
+ alpha=1, numberColPrefix="X") { |
|
48 | 49 |
|
49 | 50 |
# nci60DrugActZ <- exprs(getAct(rcellminerData::drugData)) |
50 | 51 |
# nci60GeneExpZ <- getAllFeatureData(rcellminerData::molData)[["exp"]] |
... | ... |
@@ -72,6 +73,20 @@ plotCellMiner2D <- function(df, xCol="x", yCol="y", xLabel=xCol, yLabel=yCol, |
72 | 73 |
# showTitle <- TRUE |
73 | 74 |
# alpha <- 1 |
74 | 75 |
|
76 |
+ # Fix column names if they start with a number |
|
77 |
+ if (grepl("^[0-9]", xCol)) { |
|
78 |
+ tmpXCol <- paste0(numberColPrefix, xCol) |
|
79 |
+ df[, tmpXCol] <- df[, xCol] |
|
80 |
+ xCol <- tmpXCol |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ if (grepl("^[0-9]", yCol)) { |
|
84 |
+ tmpYCol <- paste0(numberColPrefix, yCol) |
|
85 |
+ df[, tmpYCol] <- df[, yCol] |
|
86 |
+ yCol <- tmpYCol |
|
87 |
+ } |
|
88 |
+ |
|
89 |
+ # Create title |
|
75 | 90 |
if(is.null(title)) { |
76 | 91 |
corResults <- cor.test(df[,xCol], df[,yCol], use="pairwise.complete.obs") |
77 | 92 |
title <- paste0(paste(yLabel, '~', xLabel), |
... | ... |
@@ -7,7 +7,7 @@ |
7 | 7 |
plotCellMiner2D(df, xCol = "x", yCol = "y", xLabel = xCol, |
8 | 8 |
yLabel = yCol, title = NULL, colorPalette = NULL, classCol = NULL, |
9 | 9 |
tooltipCol = NULL, showLegend = FALSE, showTrendLine = TRUE, |
10 |
- showTitle = TRUE, alpha = 1) |
|
10 |
+ showTitle = TRUE, alpha = 1, numberColPrefix = "X") |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
\item{df}{a data.frame with at least two columns} |
... | ... |
@@ -33,6 +33,8 @@ plotCellMiner2D(df, xCol = "x", yCol = "y", xLabel = xCol, |
33 | 33 |
\item{showTitle}{boolean, whether to show the title} |
34 | 34 |
|
35 | 35 |
\item{alpha}{value from 0-1, where 0 indicates transparent points} |
36 |
+ |
|
37 |
+\item{numberColPrefix}{a prefix to add to column names that start with a number that causes issues with ggplot (DEFAULT: X)} |
|
36 | 38 |
} |
37 | 39 |
\value{ |
38 | 40 |
a ggplot object |