Re: [R] Selecting out certain values from a MATRIX
Thank you Dr. Burns, I tried that, but I don't think it accomplishes what I intended. Let me try to explain better. I have myMatrixmyMatrix2 (8000 by 20) (8000 by 1) myMatrix2 is the variance across the rows of myMatrix. I want to subset myMatrix to include only variances under a specific value ( i.e. a value I choose based a cutoff from myMatrix2) So I want to output a new myMatrix that includes only those variances under a specific value. thank you, On 4/4/06, Patrick Burns <[EMAIL PROTECTED]> wrote: > > I think you want something like: > > myMatrix2 <- myMatrix[ myMatrix[,1] < myVector, ] > > You may find the subscripting section of chapter 1 of > S Poetry to be useful. > > Patrick Burns > [EMAIL PROTECTED] > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S User") > > mark salsburg wrote: > > >I have two objects, one matrix and one vector. > > > >I want to use my vector to subset certain values out of my matrix. > > > >For example: > > > >I want to tell R, to select out all rows in myMatrix into a new myMatrix2 > IF > >that corresponding row is less than a 0.5 in myVector. > > > >So: > > > >myMatrix = a matrix of 8000 by 20 > >myVector = vector of 8000 > > > >myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in > >myVector) > > > >I hope this makes sense.. > > > > [[alternative HTML version deleted]] > > > >__ > >R-help@stat.math.ethz.ch mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > > > > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Selecting out certain values from a MATRIX
I have two objects, one matrix and one vector. I want to use my vector to subset certain values out of my matrix. For example: I want to tell R, to select out all rows in myMatrix into a new myMatrix2 IF that corresponding row is less than a 0.5 in myVector. So: myMatrix = a matrix of 8000 by 20 myVector = vector of 8000 myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in myVector) I hope this makes sense.. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] DISPLAYING A HISTOGRAM + finding NAs
I have a vector of values (about 8000 obs between 0 and 1). I want to display a histogram as follows: value of vector ( bw 0 and 1)| | | | | |__ all 8000 obs. So that each section of the x axis corresponds to a certain value... When I use hist(vector) it outputs out a frequency histogram. I tried transposing it with no luck. Any ideas?? Also, I'm told I have a missing value in my vector, how do I remove that observation??? (i.e. how do I search within my vector to find it???) thank you in advance [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] VARIANCE across each ROW
I have a very large matrix. I would like to display the variance across each row. In other words, I want to output a vector containing the values of variance across row. When I use the function var(), it seems to give me the variability of each column. Any ideas?? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ROWNAMES error message
I am getting an error message, which I do not know the source to. I have a matrix SAMPLES that has preexisting rownames that I would like to change. GENE_NAMES contains these rownames. > rownames(SAMPLES) = GENE_NAMES Error in "dimnames<-.data.frame"(`*tmp*`, value = list(list(V1 = c(3843, : invalid 'dimnames' given for data frame > dim(SAMPLES) [1] 1262620 > dim(GENE_NAMES) [1] 12626 1 > is.data.frame(SAMPLES) [1] TRUE > is.data.frame(GENE_NAMES) [1] TRUE I have tried converting GENE_NAMES to a factor, R will not allow me because its says "x must be atomic" ANY IDEAS?? Thank you [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] removing ROWS with missing values
I am trying to find out if R can recognize specific criteria for removing rows (i.e. a prexisting function) I have a matrix myMatrix that is 12000 by 20 I would like to remove rows from myMatrix that have: -999 across all columns -999 across all columns but one -999 across all columns but two -999 across all columns but three -999 across all columns but four -999 across all columns but five (-999 here is my missing value) Does R have a function for this, I've explored subset() so far [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] generating RANDOM ROWS from matrix
Dear group, I would like to generate a 1000 random rows from a MATRIX with dimensions 12,000 by 20 (i.e. to generate a 1000 by 20 matrix of random rows) Does the function sample() work for this??? thank you in advance [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] MEMORY limit in R
I sent this to Bioconductor, but I think it is more of an R listserv question, because of memory allocation trouble I am having trouble getting the function heatmap() to work on the following gene expression > dim(SAMPLES_log) [1] 1262620 sample1 sample2...sample20 gen1 gen2 gen3 gen12626 I have converted SAMPLES_log to a numeric matrix using: as.matrix(SAMPLES_log) when I use the following command: heatmap(SAMPLES_log) Error: cannot allocate vector of size 622668 Kb In addition: Warning messages: 1: Reached total allocation of 1022Mb: see help(memory.size) 2: Reached total allocation of 1022Mb: see help(memory.size) Is there some library in BioConductor that will allow me to output a heatmap. I want to compare the expression of the first 10 samples with the last 10 samples. I have tried running that command in a Linux environment, also with no success thank you, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Error with write.table
I'm having this error when I try to output out a gene expression data frame Error in file(file, ifelse(append, "a", "w")) : unable to open connection In addition: Warning message: cannot open file 'SAMPLES.txt' when issuing the command: write.table(SAMPLES, file = "SAMPLES.txt") write.table(SAMPLES) will work fine, but when I specify a location it gives me the above error [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Fwd: reading in only one column from text file
-- Forwarded message -- From: mark salsburg <[EMAIL PROTECTED]> Date: Mar 7, 2006 4:57 PM Subject: Re: [R] reading in only one column from text file To: Berton Gunter <[EMAIL PROTECTED]> I've tried that: read.table(myData, colClasses = NULL) colClasses doesn't seem to do anything when I put in NULL. How do I tell R to skip the 2nd column i'm reading in??? thank you, On 3/7/06, Berton Gunter <[EMAIL PROTECTED]> wrote: > > See the "NULL" value for argument colClasses of read.table(). > > -- Bert Gunter > Genentech Non-Clinical Statistics > South San Francisco, CA > > "The business of the statistician is to catalyze the scientific learning > process." - George E. P. Box > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto: [EMAIL PROTECTED] On Behalf Of mark salsburg > > Sent: Tuesday, March 07, 2006 1:30 PM > > To: R-help@stat.math.ethz.ch > > Cc: r-help@stat.math.ethz.ch > > Subject: [R] reading in only one column from text file > > > > How do I manipulate the read.table function to read in only the 2nd > > column??? > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] reading in only one column from text file
How do I manipulate the read.table function to read in only the 2nd column??? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Removing Rows
I have a data frame with the following dimensions 217 x 5 I want to create two data frames from the original. 1) One containing every tenth row of the original data frame 2) Other containing the rest of the rows. How do I do this? I've tried subset() and calling the index. thank you in advance, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Concurrence Matrix
Thank you for all the help. Can someone refer me to a function that can help with the creation of a concurrence matrix? I have two asymmetric vectors (C is length 217 and D is length 16063) that contain values of 0,1,2 I want to create a matrix E (where rows are D and columns are C) that ouputs a score where if C and D are the same number then E has value 1 if C and D are different numbers (i.e. 0 and 1, or 2 and 1) then E has a value 0 so for example: so if C is c(0,0,2,1,0,0) and D is c(0,0,1,1,1,1,1,1) E would look like: C 0 0 2 1 0 0 D0 1 1 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Classifying values in vector
I have a vector of size 217 called "A". the values of A are not sorted and range from 0 to 1 (normalized) I am having difficulty writing a program to create a new vector "B" where if A's value is 0< A <=0.333 then B is 0 if A's value is 0.333< A <=0.666 then B is 1 if A's value is 0.666< A <=1 then B is 2 so if A is 0.22 0.999 0.444 0 B would be 0 2 1 0 thank you, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help on T test
ok I created a matrix C with A B CA1 B1C1 .. . the columns contain the gene expression values.. I ran the following t.test: apply(C, 1, function(x) t.test( x[1:3], x[4,6] )$p.value ) which outputs out 16063 pvalues (the number of rows) I just want to output 3 pvalues showing if A's column is different from A1 etc.. any help would be great.. thank you.. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] T test across tissues
I cannot find in the literature a way to conduct the following t.test on 2 objects, A and B A B col1 col2 col3 col1 col2 col3 Where col(i)'s name is identical in both A and B (they are names of tissues). How do I test (t.test) if each tissue across the object is signifanctly different?? (i'm pretty sure I have to use tapply()) Also is there a way to multi plot all 89 tissues showing the A values and the B values.. thank you __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tapply t.test
I cannot find in the literature a way to conduct the following t.test on 2 objects, A and B A B col1 col2 col3 col1 col2 col3 Where col(i)'s name is identical in both A and B (they are names of tissues). How do I test (t.test) if each tissue across the object is signifanctly different?? (i'm pretty sure I have to use tapply()) Also is there a way to multi plot all 89 tissues showing the A values and the B values.. thank you __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Combining two matrices
The latter, I want to replicate A enough times to have the same rows as B. I realize that 16063 is not a mutliple 217, that doesn't really matter for this problem Assuming I change the colnames of one of them, how can I create a matrix C that is the composite of the replicated A with B. thank you again. On 7/20/05, Pedro de Barros <[EMAIL PROTECTED]> wrote: > Please clarify: > Is there a column of common values that you want to use to merge the two > matrices together? Or do you just want to replicate matrix A enough times > to have the same number of rows as B? I could think this was the case, but > 16063 is not a multiple of 217. > Anyway, you will have to change the colnames of at least one of them. > > Pedro > At 18:03 20/07/2005, you wrote: > >Can someone please refer me to a function or method that resolves this > >structuring issue: > > > >I have two matrices with identical colnames (89), but varying number > >of observations: > > > >matrix Amatrix B > > > >217 x 89 16063 x 89 > > > >I want to creat one matrix C that has both matrices adjacent to one > >another, where matrix A is duplicated many times to create the same > >row number for matrix B, i.e. 16063. > > > >matrixA matrix B > >matrixA > >matrixA > > > >so matrix C will be 16063 x 178 > > > >I've tried cbind() and merge() with no success.. > > > >__ > >R-help@stat.math.ethz.ch mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Combining two matrices
Can someone please refer me to a function or method that resolves this structuring issue: I have two matrices with identical colnames (89), but varying number of observations: matrix Amatrix B 217 x 89 16063 x 89 I want to creat one matrix C that has both matrices adjacent to one another, where matrix A is duplicated many times to create the same row number for matrix B, i.e. 16063. matrixA matrix B matrixA matrixA so matrix C will be 16063 x 178 I've tried cbind() and merge() with no success.. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] predict.lm - standard error of predicted means?
Can someone please refer me to a function or method that resolves this structuring issue: I have two matrices with identical colnames (89), but varying number of observations: matrix Amatrix B 217 x 89 16063 x 89 I want to creat one matrix C that has both matrices adjacent to one another, where matrix A is duplicated many times to create the same row number for matrix B, i.e. 16063. matrixA matrix B matrixA matrixA so matrix C will be 16063 x 178 I've tried cbind() and merge() with no success.. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] .gct file
This is all extremely helpful. The data turns out is a little atypical, the columns are tab-delemited except for the description columns DATA1.gct looks like this #1.2 23 3423 NAME DESCRIPTION VALUE gene1 "a protein inducer" 1123 . . .. How do I get R to read the data as tab delemited, but read in the 2nd coloumn as one value based on the quotation marks.. thanks.. On 7/19/05, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote: > On Tue, 2005-07-19 at 13:16 -0400, mark salsburg wrote: > > ok so the gct file looks like this: > > > > #1.2 (version number) > > 7283 19 (matrix size) > > Name Description Values > > ... .. > > > > How can I tell R to disregard the first two lines and start reading > > the 3rd line in this gct file. I would just delete them, but I do not > > know how to open a gct. file > > > > thank you > > > > On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > > > On 7/19/2005 12:10 PM, mark salsburg wrote: > > > > I have two files to compare, one is a regular txt file that I can read > > > > in no prob. > > > > > > > > The other is a .gct file (How do I read in this one?) > > > > > > > > I tried a simple > > > > > > > > read.table("data.gct", header = T) > > > > > > > > How do you suggest reading in this file?? > > > > > > > > > > .gct is not a standard filename extension. You need to know what is in > > > that file. Where did you get it? What program created it? > > > > > > Chances are the easiest thing to do is to get the program that created > > > it to export in a well known format, e.g. .csv. > > > > > > Duncan Murdoch > > > The above would be consistent with the info in my reply. > > I guess if the format is consistent, as per Mark's example above, you > can use: > > read.table("data.gct", skip = 2, header = TRUE) > > which will start by skipping the first two lines and then reading in the > header row and then the data. > > See ?read.table > > HTH, > > Marc Schwartz > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] .gct file
ok so the gct file looks like this: #1.2 (version number) 7283 19 (matrix size) Name Description Values ... .. How can I tell R to disregard the first two lines and start reading the 3rd line in this gct file. I would just delete them, but I do not know how to open a gct. file thank you On 7/19/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 7/19/2005 12:10 PM, mark salsburg wrote: > > I have two files to compare, one is a regular txt file that I can read > > in no prob. > > > > The other is a .gct file (How do I read in this one?) > > > > I tried a simple > > > > read.table("data.gct", header = T) > > > > How do you suggest reading in this file?? > > > > .gct is not a standard filename extension. You need to know what is in > that file. Where did you get it? What program created it? > > Chances are the easiest thing to do is to get the program that created > it to export in a well known format, e.g. .csv. > > Duncan Murdoch > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] .gct file
I have two files to compare, one is a regular txt file that I can read in no prob. The other is a .gct file (How do I read in this one?) I tried a simple read.table("data.gct", header = T) How do you suggest reading in this file?? thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] interactive plot showing label
I have the following data: gene_name microarray expression A 2323 B 1983 . I have about 10,000 observations. I would like to know if there is a way to create an interactive plot.. Mainly one that shows all the points, but when a point is clicked on it shows what gene_name it is If not, does anyone recommend another way to output a plot (using maybe bioconducter bc this is microarray expression) that is informative about the gene_names. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html