0

I am very new to the R interface but need to use the program in order to run the relevant analyses for my clinical doctorate thesis. So, apologies in advance if this is a novice question.

I have a matrix of beta methylation values with the following dimensions:485577x894. The row names of the matrix refer to cpg sites which range in non-numerical and non-ascending order (e.g. "cg00000029" "cg00000108" "cg00000109" "cg00000165"), while the column names refer to participant IDs which are also in non-numerical and non-ascending order (e.g. "11209" "14140" "1260" "5414").

I would like to identify which beta methylation values are > 0.5 so that I can exclude them from further analyses. In doing so, I need the data to stay in a matrix format. All attempts I have made to conduct this analysis have resulted in retrieval of integer variables rather than the data in a matrix format.

I would be so grateful if someone could please advise me of the code to conduct this analysis.

Thank you for your time.

Cheers,

Alicia

  • Check this out first. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example . Let's say your matrix is `dat`, you can tell R to convert anything in that matrix that's > 0.5 to `NA` with `dat[dat > 0.5] <- NA`. Now depending on the analysis you can use the method for ignoring `NA`. For example, see `na.rm` in `?mean` – Brandon Bertelsen Jan 24 '14 at 13:36
  • 2
    Also see this resource: http://cran.r-project.org/doc/manuals/r-release/R-intro.html – Roman Luštrik Jan 24 '14 at 13:37
  • Thank you so much for your response, it is really appreciated. I will have a look at the link you have recommended. Cheers, Alicia – user2828469 Jan 25 '14 at 02:44

1 Answers1

0
set.seed(1)                             # so example is reproduceable     
m <- matrix(runif(1000,0,0.6),nrow=100) # 100 rows X 10 cols, data in U[0,0.6]
m[m>0.5]<-NA                            # anything > 0.5 set to NA
z <- na.omit(m)                         # remove all rows with any NA's
jlhoward
  • 58,004
  • 7
  • 97
  • 140
  • Thank you so much for your response, it is really appreciated! I will attempt the commands you have recommended!! – user2828469 Jan 25 '14 at 02:44