Without a reproducible example, or at least a non-mangled one (please
don't post in HTML), I'm not inclined to try it, but why not use
sig_values to index row.names() and col.names() if you're after the
names?

Sarah

On Mon, Jul 20, 2015 at 1:44 PM, gaurav kandoi <kandoigau...@gmail.com> wrote:
> Hi All
>
> I've two big matrices (5k*4k) with the same structure, i.e. :
>
>   mRNA1 mRNA2 mRNA3  lncRNA1 0.395646 0.94995 0.76177  lncRNA2 0.03791
> 0.661258 0.558658  lncRNA3 0.67846 0.652364 0.359054  lncRNA4 0.57769 0.003
> 0.459127
> Now, I would like to extract the names of the row,col pairs whose value is
> less than 0.05. In this case, I should get the output as (lncRNA2,mRNA1)
> and (lncRNA4,mRNA2) alongwith their values (0.03791 and 0.003). Since the
> structure of both the matrix is same, I would also like to retrieve the
> corresponding values and row,col names from the second matrix.
> (lncRNA2,mRNA1 and lncRNA4,mRNA2 alongwith their values in the second
> matrix.)
>
> I'm using the following code:
>
> Pmatrix = read.table("pmatrix.csv", header=T, sep="," , row.names=1)
>> sig_values <- which(Pmatrix<0.05, arr.ind=TRUE)
>> sig_values
>> Corr_Matrix = read.csv("corr_matrix.csv", header = T, row.names=1)
>> Corr_Matrix[sig_values]
>
>
> However, it only prints the row,col number (sig_values command) or only the
> values (Corr_Matrix[sig_values]) command. How can I get the row and column
> names alongwith their values?
>
> Regards
>
> --
> *Gaurav Kandoi*
>
>         [[alternative HTML version deleted]]

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to