0

I have a table made of 10 rows and 6 columns, where each entry is a real value. After the application of kmeans algorithm, I would like R to plot 6*(6-1) = 30 plots, in which each couple of rows is the axis in turn.

When I do it with the original data, everything works fine. But if I try to quantile-normalize the data, it does not work anymore and the system just shows the first couple plot.

Here are the data (data.csv):

chrName-chrStart-chrEnd,gm12878,h1-hesc,hela-s3,hepg2,huvec,k562
chr1-66660-66810,0,0,2.825,0.75,0,0.85
chr1-564520-564670,15.6356435644,4.5469879518,57.7813793103,130.2263636364,5.8088888889,101.680952381
chr1-568060-568210,17.9069767442,3.6970588235,15.962745098,34.8866666667,4.1,31.0394736842
chr1-568900-569050,41.7029411765,7.4568181818,28.3984615385,59.464957265,8.5194444444,44.6583333333
chr1-601040-601190,0.4,0.75,0.5333333333,0.4,0.3,0.3
chr1-662500-662650,0,3.45,0.25,63,0.9923076923,5.7469879518
chr1-714040-714190,115.0871428571,125.6707142857,80.8081632653,153.9737931034,70.0197080292,166.5101351351
chr1-730400-730550,1.3730769231,0,0,0.9,7.6690140845,0.76
chr1-753400-753550,1.3517241379,4.1,0.4818181818,0,0.3,1.4285714286
chr1-762820-762970,43.6430769231,17.875,21.2659574468,123.1888888889,14.5743589744,56.7931034483

Here's my working code:

dnaseSignalFile = "data.csv"
originalDataTab <- read.csv(dnaseSignalFile, header=TRUE, sep=",")
originalDataTabSubMatrixChromSel_onlyData <- originalDataTab [,2:7]

cl0 <- kmeans(originalDataTabSubMatrixChromSel_onlyData , 2)
plot(originalDataTabSubMatrixChromSel_onlyData , col = cl0$cluster)
points(cl0$centers, col = 1:2, pch = 8, cex = 2)

It then correctly shows this image:

Correct six-plot

And that's fine! But if I tried to run a quantile-normalization, things do not work anymore:

library("slam"); library("preprocessCore"); library("nnet");

normQuant<- normalize.quantiles(as.matrix(originalDataTabSubMatrixChromSel_onlyData), copy=TRUE)
roundNormQuant <- round(normQuant)
roundNormQuantTab <- as.data.frame(roundNormQuant)
colnames(roundNormQuantTab) <- colnames(originalDataTabSubMatrixChromSel_onlyData)

roundNormQuantTab <- normQuant
colnames(roundNormQuantTab) <- colnames(originalDataTabSubMatrixChromSel_onlyData)
rownames(roundNormQuantTab) <- rownames(originalDataTabSubMatrixChromSel_onlyData)


dev.new()
cl <- kmeans(roundNormQuantTab, 2)
plot(roundNormQuantTab, col = cl$cluster)
points(cl$centers, col = 1:2, pch = 8, cex = 2)

'Cause the only thing that I see is the following picture:

Singular plot

Why can't I get the six plots in the second case, too? What's different between the former case and the latter one? How could I solve this problem?

DavideChicco.it
  • 3,318
  • 13
  • 56
  • 84
  • Yes it's a data.frame() – DavideChicco.it Mar 11 '15 at 17:32
  • 2
    you overwrite it later on `roundNormQuantTab <- normQuant` when you plot a data frame object, `plot.data.frame` creates that matrix you got in the first picture. if you were plotting something else like a matrix, that would explain the second behavior: compare `plot(mtcars); plot(as.matrix(mtcars))` – rawr Mar 11 '15 at 17:33
  • I see, what an idiot I've been... now it works, thanks! Reply to the question and I'll choose your answer as best answer – DavideChicco.it Mar 11 '15 at 17:36

0 Answers0