Skip to content

Commit 679f2cf

Browse files
author
Chen Ying
committed
correct PC percentage calculation
1 parent 4178499 commit 679f2cf

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

R/plotBambu_utilityFunctions.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ plotPCA <- function(se, count.data, group.variable) {
8888
p <- ggplot2::ggplot(plotData, ggplot2::aes(x = PC1, y = PC2)) +
8989
ggplot2::geom_point(ggplot2::aes(col = groupVar)) +
9090
ggplot2::ylab(paste0("PC2 (",
91-
round(pca_result$sdev[2] / sum(pca_result$sdev) * 100, 1), "%)")) +
91+
round(pca_result$sdev[2]^2 / sum(pca_result$sdev^2) * 100, 1), "%)")) +
9292
ggplot2::xlab(paste0("PC1 (",
93-
round(pca_result$sdev[1] / sum(pca_result$sdev) * 100, 1), "%)")) +
93+
round(pca_result$sdev[1]^2 / sum(pca_result$sdev^2) * 100, 1), "%)")) +
9494
ggplot2::theme_minimal()
9595
} else {
9696
pca_result <- prcomp(t(as.matrix(count.data)))
@@ -99,9 +99,9 @@ plotPCA <- function(se, count.data, group.variable) {
9999
p <- ggplot2::ggplot(plotData, ggplot2::aes(x = PC1, y = PC2)) +
100100
ggplot2::geom_point(ggplot2::aes(col = runname)) +
101101
ggplot2::ylab(paste0("PC2 (",
102-
round(pca_result$sdev[2] / sum(pca_result$sdev) * 100, 1), "%)")) +
102+
round(pca_result$sdev[2]^2 / sum(pca_result$sdev^2) * 100, 1), "%)")) +
103103
ggplot2::xlab(paste0("PC1 (",
104-
round(pca_result$sdev[1] / sum(pca_result$sdev) * 100, 1), "%)")) +
104+
round(pca_result$sdev[1]^2 / sum(pca_result$sdev^2) * 100, 1), "%)")) +
105105
ggplot2::theme_minimal()
106106
}
107107
return(p)
@@ -140,4 +140,4 @@ plotHeatmap <- function(se, count.data, group.variable) {
140140
show_row_names = FALSE, column_names_gp = grid::gpar(fontsize = 9))
141141
}
142142
return(p)
143-
}
143+
}

0 commit comments

Comments
 (0)