Commit ef089fc1 authored by Daria Zenkova's avatar Daria Zenkova

there are labels in morpheus.js now

parent b7b95736
createES <- function(data, pData, labelDescription, colNames, rowNames) { createES <- function(data, pData, labelDescription, colNames, rowNames) {
exprs <- data exprs <- t(data)
colnames(exprs) <- colNames colnames(exprs) <- colNames
truePData <- pData truePData <- pData
pd <- data.frame(truePData, row.names = colNames) pd <- data.frame(truePData, row.names = colNames)
......
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
#' @examples #' @examples
#' pcaPlot(es.norm, 1, 2) + aes(color=time) #' pcaPlot(es.norm, 1, 2) + aes(color=time)
#' @export #' @export
pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="") { pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="", label="") {
n1 <- as.numeric(c1) n1 <- as.numeric(c1)
n2 <- as.numeric(c2) n2 <- as.numeric(c2)
stopifnot(require(ggplot2)) stopifnot(require(ggplot2))
stopifnot(require(ggrepel))
stopifnot(require(Biobase)) stopifnot(require(Biobase))
stopifnot(require(svglite))
if (is.null(rows)) { if (is.null(rows)) {
rows <- 1:nrow(exprs(es)) rows <- 1:nrow(exprs(es))
...@@ -34,7 +36,7 @@ pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="") { ...@@ -34,7 +36,7 @@ pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="") {
pData[[size]] <- as.numeric(pData[[size]]) pData[[size]] <- as.numeric(pData[[size]])
} }
pp <- ggplot(data=cbind(as.data.frame(pca$x), pData)) pp <- ggplot(data=cbind(as.data.frame(pca$x), pData, sampleNames(es)))
if (size != "" && colour != "") { if (size != "" && colour != "") {
aes <- aes_string(x=xs[n1], aes <- aes_string(x=xs[n1],
...@@ -51,7 +53,23 @@ pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="") { ...@@ -51,7 +53,23 @@ pcaPlot <- function(es, columns=c(), rows=c(), c1, c2, size="", colour="") {
y=xs[n2]) y=xs[n2])
} }
pp + g <- pp + aes +
geom_point(aes) + geom_point() +
xlab(xlabs[n1]) + ylab(xlabs[n2]) xlab(xlabs[n1]) + ylab(xlabs[n2])
if (label == "id") {
label <- "sampleNames(es)"
}
if (label != "") {
message("i'm here 2s")
g <- g + geom_text_repel(aes_string(label=label))
}
f <- tempfile(pattern="plot",tmpdir="~/morpheus.js/tmp",fileext=".svg")
ggsave(f, g)
print(capture.output(str(g)))
return(f)
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment