[R] Help: calculations based on three matrices

2013-09-24 Thread JiangZhengyu
Dear R experts, I have 3 matrices - Mx, My and geno that have the same exact dimensions (attached). I want to calculate a expression matrix (ME) of the same dimension as well. It is a little complicated. To calculate and for a specific cell in ME, e.g. ME[2,2], if value of

[R] change cell values

2013-07-03 Thread JiangZhengyu
Dear R experts, I have two matrices (mat1 mat2) with the same dimension the cells (row and column) are corresponding to each other. I want to change cell values to NA given values of the corresponding cells in mat1 and mat2 are both 1. E.g. both mat1[2,3] and mat2[2,3] are 1, I will

Re: [R] change cell values

2013-07-03 Thread JiangZhengyu
the second condition is evaluated, and so mat1 is full of NA values. Try the following. tmp - mat1 # Make a copy tmp[mat1 1 mat2 1] - NA # And change that copy mat2[mat1 1 mat2 1] - NA mat1 - tmp rm(tmp) Hope this helps, Rui Barradas Em 03-07-2013 22:27, JiangZhengyu

[R] recover log of matrix

2013-05-13 Thread JiangZhengyu
Dear all, I have a matrix with all values being log transformed. I want them back to the values before the transformation. i.e. 2^matrix M. Is there any easy code to do this? Thanks,Zhengyu [[alternative HTML version deleted]]

[R] Ask for help: find corresponding elements between matrix

2013-02-21 Thread JiangZhengyu
Dear R experts, I have two matrix (seq mat) I want to retrieve in a new matrix all the numbers from mat that =1 (corresponding to the same row/ column position) in seq, or all the numbers in mat that =-1 in seq. - Replace all the numbers with NA if it's not 1/-1 in seq. There are

[R] Thank you! RE: Ask for help: find corresponding elements between matrix

2013-02-21 Thread JiangZhengyu
Date: Thu, 21 Feb 2013 16:35:08 +0100 CC: r-help@r-project.org To: zhyjiang2...@hotmail.com On 21-02-2013, at 15:39, JiangZhengyu zhyjiang2...@hotmail.com wrote: Dear R experts, I have two matrix (seq mat) I want to retrieve in a new matrix all the numbers from mat that =1

[R] Index out SNP position

2013-01-03 Thread JiangZhengyu
Dear R experts, I have 2 matix: A B. I am trying to index B against A - (1) find out B rows that fall between the col 1 and 2 of A put them into a new vector SNP.I made code as below, but I cannot think of a right way to do it. Could anyone help me with the code? Thanks,Jiang A

Re: [R] Index out SNP position

2013-01-03 Thread JiangZhengyu
,]) B = max(A[x,])]) SNP [[1]] [1] 36003918 35838399 35838589 [[2]] [1] 35838589 [[3]] numeric(0) [[4]] [1] 36003918 [[5]] numeric(0) On Thu, Jan 3, 2013 at 4:54 PM, JiangZhengyu zhyjiang2...@hotmail.com wrote: Dear R experts, I have 2 matix: A B. I am

Re: [R] Index out SNP position

2013-01-03 Thread JiangZhengyu
(B), function(i) any(B[i]A[,1] B[i]A[,2])) SNP - B[indx] SNP [1] 36003918 35838399 35838589 --- David -Original Message- From: David L Carlson [mailto:dcarl...@tamu.edu] Sent: Thursday, January 03, 2013 4:23 PM To: 'JiangZhengyu'; 'r-help@r-project.org' Subject

Re: [R] smoothScatter plot

2012-10-10 Thread JiangZhengyu
Hi John,I installed but somehow it did not work on my computer, while I tried another computer - it works. Thanks for all your communications.Best,Zhengyu Date: Tue, 9 Oct 2012 05:16:59 -0800 From: jrkrid...@inbox.com Subject: RE: [R] smoothScatter plot To: zhyjiang2...@hotmail.com Glad

Re: [R] smoothScatter plot

2012-10-05 Thread JiangZhengyu
Hi John, Thanks for your link. Those plots look pretty but way too complicated in terms of making R code. Maybe my decription is not clear. But could you take a look at the attached png? I saw several publications showing smoothed plots like this but not sure how to make one...

Re: [R] smoothScatter plot

2012-10-04 Thread JiangZhengyu
Hi John, Thanks for your email. Your way works good. However, I was wondering if you can help with a smoothed scatter plot that has shadows with different darker blue color representing higher density of points. Zhengyu Date: Thu, 4 Oct 2012 05:46:46 -0800 From: jrkrid...@inbox.com Subject:

[R] smoothScatter plot

2012-10-02 Thread JiangZhengyu
Hi, I want to make a plot similar to sm1 (attached). The code I tried is: dcols - densCols(x,y) smoothScatter(x,y, col = dcols, pch=20,xlab=A,ylab=B) abline(h=0, col=red) But it turned out to be s1 (attached) with big dots. I was wondering if anything wrong with my code. Thanks,Zhengyu

[R] Errors in if statement

2012-09-28 Thread JiangZhengyu
Hi guys, I have many rows (1000) and columns (30) of geno matrix. I use the following loop and condition statement (adapted from someone else code). I always have an error below. I was wondering if anyone knows what's the problem how to fix it. Thanks,Zhengyu ### geno matrix P1

[R] replace string values with numbers

2012-09-26 Thread JiangZhengyu
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3.Gene[Gene==GG]-3 It always give me: Warning in `[-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does any

Re: [R] replace string values with numbers

2012-09-26 Thread JiangZhengyu
. - Original Message - From: JiangZhengyu zhyjiang2...@hotmail.com To: r-help@r-project.org Cc: Sent: Wednesday, September 26, 2012 3:52 PM Subject: [R] replace string values with numbers Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC