Skip to content

Commit a578a20

Browse files
committed
Fixed bug with plot output from noise correction, reduced example runtimes
1 parent 9a8cc6d commit a578a20

3 files changed

Lines changed: 23 additions & 21 deletions

File tree

R/preprocessExpressionMatrix.R

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#' expression.matrix <- as.matrix(read.csv(
3232
#' system.file("extdata", "expression_matrix.csv", package = "bulkAnalyseR"),
3333
#' row.names = 1
34-
#' ))[1:500, 1:4]
34+
#' ))[1:10, 1:4]
3535
#' expression.matrix.preproc <- preprocessExpressionMatrix(expression.matrix)
3636
preprocessExpressionMatrix <- function(
3737
expression.matrix,
@@ -91,7 +91,7 @@ preprocessExpressionMatrix <- function(
9191
#' expression.matrix <- as.matrix(read.csv(
9292
#' system.file("extdata", "expression_matrix.csv", package = "bulkAnalyseR"),
9393
#' row.names = 1
94-
#' ))[1:500, 1:4]
94+
#' ))[1:10, 1:4]
9595
#' expression.matrix.denoised <- noisyr_counts_with_plot(expression.matrix)
9696
noisyr_counts_with_plot <- function(
9797
expression.matrix,
@@ -109,24 +109,26 @@ noisyr_counts_with_plot <- function(
109109
}
110110
expression.summary <- noisyr::calculate_expression_similarity_counts(expression.matrix, ...)
111111

112-
plotlist <- noisyr::plot_expression_similarity(expression.summary = expression.summary)
113-
plotdf.line <- tibble::tibble()
114-
for(i in seq_len(ncol(expression.matrix))){
115-
lineid <- i * 2 - 1
116-
plotdf.line <- rbind(
117-
plotdf.line,
118-
dplyr::mutate(plotlist[[lineid]]$data, Sample = colnames(expression.matrix)[i]))
112+
if(output.plot){
113+
plotlist <- noisyr::plot_expression_similarity(expression.summary = expression.summary)
114+
plotdf.line <- tibble::tibble()
115+
for(i in seq_len(ncol(expression.matrix))){
116+
lineid <- i * 2 - 1
117+
plotdf.line <- rbind(
118+
plotdf.line,
119+
dplyr::mutate(plotlist[[lineid]]$data, Sample = colnames(expression.matrix)[i]))
120+
}
121+
p <- ggplot2::ggplot(plotdf.line) +
122+
ggplot2::theme_minimal() +
123+
ggplot2::geom_line(ggplot2::aes(x = .data$x, y = .data$y, colour = .data$Sample)) +
124+
ggplot2::geom_smooth(ggplot2::aes(x = .data$x, y = .data$y, colour = .data$Sample),
125+
method = "loess", formula = .data$y ~ .data$x, span = 0.1) +
126+
ggplot2::ylim(0, 1) +
127+
ggplot2::xlab("log2(expression)") +
128+
ggplot2::ylab("Similarity") +
129+
ggplot2::geom_hline(yintercept = similarity.threshold, color = "black")
130+
suppressWarnings(print(p))
119131
}
120-
p <- ggplot2::ggplot(plotdf.line) +
121-
ggplot2::theme_minimal() +
122-
ggplot2::geom_line(ggplot2::aes(x = .data$x, y = .data$y, colour = .data$Sample)) +
123-
ggplot2::geom_smooth(ggplot2::aes(x = .data$x, y = .data$y, colour = .data$Sample),
124-
method = "loess", formula = .data$y ~ .data$x, span = 0.1) +
125-
ggplot2::ylim(0, 1) +
126-
ggplot2::xlab("log2(expression)") +
127-
ggplot2::ylab("Similarity") +
128-
ggplot2::geom_hline(yintercept = similarity.threshold, color = "black")
129-
suppressWarnings(print(p))
130132

131133
if (base::length(similarity.threshold) > 1 | base::length(method.chosen) > 1) {
132134
base::message("Selecting parameters that minimise the coefficient of variation...")

man/noisyr_counts_with_plot.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/preprocessExpressionMatrix.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)