Question: matrix transposing in R
0
gravatar for Angel
3.9 years ago by
Angel40
Berlin
Angel40 wrote:

hello,

i have a file normalized by mas5, i want to transpose that, i typed these codes 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)
affy mas5 • 1.4k views
ADD COMMENTlink modified 3.9 years ago by arfranco130 • written 3.9 years ago by Angel40
Answer: matrix transposing in R
2
gravatar for arfranco
3.9 years ago by
arfranco130
European Union
arfranco130 wrote:

I gave a look to GSE33964, and this is file with RAW data containing 12 different sub-samples, each of them in CEL format

I don't see how you can transpose this data in a usable format. I don't see with the information you give how you could normalize that data

It is sort of confusing..

ADD COMMENTlink written 3.9 years ago by arfranco130
Answer: matrix transposing in R
2
gravatar for arfranco
3.9 years ago by
arfranco130
European Union
arfranco130 wrote:

 

Simply run the following into R

>head(rawData)

>str(rawData)

And you will see how your downloaded  data have been read with the readAffy() from the original gz compressed file to become a special file (rawData) that encompasses many different parts (data.frames, vector, factors, matrix) organized into a special class file (type) that includes all of the necessary information for Affy to proceed

If you want to transpose something, it has to be part of this special class file, and you need to learn how to name it or extract it

 

ADD COMMENTlink written 3.9 years ago by arfranco130
1

And anyway... Why do you want or need to transpose your data for ?

ADD REPLYlink modified 3.9 years ago • written 3.9 years ago by arfranco130

i want to do pearson coeficient correlation which needs a transposed matrix

ADD REPLYlink written 3.9 years ago by Angel40

i changed directory towhere  my CEL files are there and typed:

> head(rawData)
Error in head(rawData) : object 'rawData' not found
>
> str(rawData)
Error in str(rawData) : object 'rawData' not found

did i wrong?
 

ADD REPLYlink written 3.9 years ago by Angel40
1

You have writting the following code

rawData = ReadAffy(filenames=fileNames)

So after reading your data or having that file in the global environment is when you have to run the head(rawData), str(rawData) or even summarize(rawData) and class(rawData)

This will allow you to see the internal structure of this file. Then you have to learn how to find and discover where into this file is your data, and how to use it

ADD REPLYlink written 3.9 years ago by arfranco130

thank you Antonio

ADD REPLYlink written 3.9 years ago by Angel40
Answer: matrix transposing in R
1
gravatar for Angel
3.9 years ago by
Angel40
Berlin
Angel40 wrote:

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)

i dont know how to transpose the resulted file now, i file containing NA...

ADD COMMENTlink modified 3.9 years ago by Martin Morgan ♦♦ 23k • written 3.9 years ago by Angel40
1

Rather than working with files, work with the object that you have available. Extract the matrix of expression values from the eset, and transpose that

t(exprs(eset))

See the Biobase vignette for working with ExpressionSet objects.

ADD REPLYlink written 3.9 years ago by Martin Morgan ♦♦ 23k

thank you Martin

ADD REPLYlink written 3.9 years ago by Angel40

sorry martin, i named my text file resulted from mas5 normalizing GSE33964 which stored in E:\New folder

i typed:


> library("Biobase")
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following object is masked from ‘package:stats’:

    xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, as.vector, cbind, colnames,
    do.call, duplicated, eval, evalq, Filter, Find, get, intersect,
    is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax,
    pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rep.int,
    rownames, sapply, setdiff, sort, table, tapply, union, unique,
    unlist, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

> library(convert)
Error in library(convert) : there is no package called ‘convert’
> dataDirectory <- system.file("extdata", package="Biobase")
> "E:\New folder" <- file.path(dataDirectory, "GSE33964")
Error: '\N' is an unrecognized escape in character string starting ""E:\N"
> "E:/New folder" <- file.path(dataDirectory, "GSE33964")
> exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep="\t",
+ row.names=1,
+ as.is=TRUE))
Error in read.table(exprsFile, header = TRUE, sep = "\t", row.names = 1,  :
  object 'exprsFile' not found
> exprs <- as.matrix(read.table(exprsGSE33964, header=TRUE, sep="\t",
+ row.names=1,
+ as.is=TRUE))
Error in read.table(exprsGSE33964, header = TRUE, sep = "\t", row.names = 1,  :
  object 'exprsGSE33964' not found
>  exprs <- as.matrix(read.table(exprsGSE33964, header=TRUE, sep="\t",
+ + row.names=1,
Error: unexpected '=' in:
" exprs <- as.matrix(read.table(exprsGSE33964, header=TRUE, sep="\t",
+ row.names="
>  exprs <- as.matrix(read.table("E:/New folder" , header=TRUE,  sep="\t",
+ row.names=1,
+ as.is=TRUE))
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'E:/New folder': Permission denied
>  exprs <- as.matrix(read.table("E:/New folder/GSE33964" , header=TRUE,  sep="\t",
+ row.names=1,
+  as.is=TRUE))
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'E:/New folder/GSE33964': No such file or directory

really i got confused to transpose my text file....

ADD REPLYlink written 3.9 years ago by Angel40

Please edit your code to remove errors that you know you took, e.g., trying to load the 'convert' package when it was not yet installed, and your various typos and so on. I guess you're just trying to read a file in to R, and you have failed to identify the correct location. Try

fname = file.choose()

This should open a dialog box which allows you to choose the file that you would like to input. Verify that you've chosen the correct file by typing fname, and by testing it's existence

fname
file.exists(fname)

Finally, read in the data (maybe the options you give are correct, but maybe not, it depends on your file format)

exprs <- as.matrix(read.table(fname , header=TRUE,  sep="\t", 
                              row.names=1, as.is=TRUE))

Please also take a few minutes to look at the output, and to compare it to the commands you tried to enter, and to read introductory R documentation; it doesn't make sense to try to run before walking. It might help to find a colleague at your local institution with whom you can explore the basics of R together.

ADD REPLYlink modified 3.9 years ago • written 3.9 years ago by Martin Morgan ♦♦ 23k

thank you, you all right

ADD REPLYlink written 3.9 years ago by Angel40
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 228 users visited in the last hour