[R] Deleting multiple rows from a data matrix based on exp value
R. Michael Weylandt
michael.weylandt at gmail.com
Mon Nov 21 15:42:24 CET 2011
On Mon, Nov 21, 2011 at 5:41 AM, Peter Davidsen <pkdavidsen at gmail.com> wrote:
> Thanks for the quick reply.
> However, your suggestion doesn't solve the problem I'm afraid (i.e
> dim(Matrix) still the same). What I want is to reduce the number of
> rows (probesets) markedly based on their normalized intensity - thus
> I've chosen a cut-off of 1.11
How is normalized intensity calculated for a given row?
> When I run your code (as well as mine listed in my previous mail) R
> just give me a very long list (in two columns) with the probeset names
> as well as the expression value in column 17 (I've 25 columns in total
> in my data matrix).
> I have tried to generate a small matrix (4 rows and 3 colums) to test
> your code... when I type head(Matrix) it looks ok (now only 3 rows as
> expected), but when I type dim(matrix) it still states 4 rows and 3
Just jumping into this one mid-stream so my comments might be entirely
off base: if its a 4x3 matrix and you use dim() on it, what would you
have expected instead? dim returns the dimensions of an array, here
just the matrix size....your confusion might be easier for us to
interpret with some code or at least a copy of the console output.
Personally, I'm (much) more surprised that head() on a 4x3 matrix
gives a result of only 3 rows.
When you get your working example up, the easiest way to post it to
the list is to use the dput() function to get a plain text
> NB: When I write 'exp value' I mean log transformed, background
> corrected expression values derived from Affy chips (I used the
> 'justRMA' command to read my CEL files and compute an expression
> Kind regards,
> On Mon, Nov 21, 2011 at 05:09, Dennis Murphy <djmuser at gmail.com> wrote:
>> Without a reproducible example this is just a guess, but try
>> Matrix[apply(Matrix, 1, function(x) any(x > 1.11)), ]
>> This will retain all rows of Matrix where at least one value in a row
>> is above the threshold 1.11. If that doesn't do what you want, please
>> provide a small reproducible example and a clearer statement of the
>> desired output. It's not at all clear to me what 'exp. values' means -
>> I can devise at least three meanings off the top of my head, none of
>> which may conform to what you mean.
>> On Sun, Nov 20, 2011 at 2:45 PM, Peter Davidsen <pkdavidsen at gmail.com> wrote:
>>> Dear List,
>>> I have a data matrix that consists of ~4500 rows and 25 columns (i.e.
>>> an exprSet object that I converted via the 'exprs' function into a
>>> data matrix)
>>> Now I want to remove/delete the rows where all exp. values in that
>>> particular row are below or equal to a specific cut-off value (e.g
>>> I have tried using several commands to address this issue:
>>>>Matrix[rowSums(Matrix <= 1.11) <= 1.11, ]
>>>>Matrix[ !apply(Matrix<=1.11,1,all), ]
>>> The above commands seem to work fine when I generate a small "test" matrix like:
>>>>M <- matrix(c(2,5,8,0.4,0.8,0.5,4,12,3), nrow=3, byrow=T)
>>> However, non of the two commands decrease the number of rows in my real matrix!
>>> Any help would be appreciated
>>> Kind regards,
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help