This is a test version of Biostars. For the public version, visit https://www.biostars.org.
matrix transpose in R

Hi friends,

Using some commands I normalized an array with mas5, may you please tell me exactly with which commands I can transpose the produced matrix. text file in R?

For example I changed the directory to where I saved my produced file, opened R and typed:

> t()
Error in t.default() : argument "x" is missing, with no default
microarray affy r mas5

Hello sarah!

We believe that this post does not fit the main topic of this site.

This is solely programming question and belongs to stack overflow. Or you can simply solve it yourself by typing ?t and reading the documentation.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ok as you order!!

............

2 answers

Sarah,

To transpose a matrix, the function is t()

Suppose your matrix is saved in an object matrix

# transposing a matrix
transpose_matrix <- t(matrix)

Hi Deepak,

I had a file. First I normalized GSE33964, with below commands

library(affy)
library(methods)

inFilePattern = "*CEL.gz"
outFilePath = "GSE33964.matrix"
fileNames = list.files(pattern=glob2rx(inFilePattern))
rawData = ReadAffy(filenames=fileNames)
eset <- mas5(rawData)
write.exprs(eset, file=outFilePath, col.names=NA)

Now I have a file containing NA...

I typed these codes to transpose that but no new file was produced or no changed I saw in primary file. then where is transposed matrix please or if I did right?

changedir

GSE33964_new <- t(GSE33964)
GSE33964 <- matrix(1:30, 5, 6)
tGSE33964 <- t(GSE33964) ##-- i.e., GSE33964[i, j] == tGSE33964[j, i] for all i,j :
for(j in seq(ncol(a)))
  if(! all(GSE33964[, j] == tGSE33964[j, ])) stop("wrong transpose")
  transpose_GSE33964 <- t(GSE33964)

t() is correct, but you (A) have to have the matrix loaded and (B) tell t() what it is. For example, if your matrix is named m, then, m_new <- t(m).

Log in to answer this question.