Re: [R] How to make this binary hit matrix

2008-06-15 Thread ssls sddd
Thank you very much, Marc!

Have a great weekend!

Alex

On Sun, Jun 15, 2008 at 1:58 PM, Marc Schwartz <[EMAIL PROTECTED]>
wrote:

> on 06/15/2008 12:46 PM ssls sddd wrote:
>
>> Hi all,
>>
>> Basically I want to make a binary hit matrix.
>>
>> For instance, if I have a file called 'pair.txt':
>>
>> set_agene_1
>> set_agene_2
>> set_agene_3
>> set_bgene_3
>> set_bgene_4
>> set_bgene_5
>> set_cgene_1
>> set_cgene_3
>>
>> And I want to convert it to a binary matrix as:
>>
>> Rowsset_aset_bset_c
>> gene_1101
>> gene_2100
>> gene_3111
>> gene_4010
>> gene_5010
>>
>> Can anyone suggest how to do this?
>>
>> Thank you!
>>
>> Alex
>>
>
> Presuming that your data is contained in a data frame called 'DF':
>
> > DF
> V1 V2
> 1 set_a gene_1
> 2 set_a gene_2
> 3 set_a gene_3
> 4 set_b gene_3
> 5 set_b gene_4
> 6 set_b gene_5
> 7 set_c gene_1
> 8 set_c gene_3
>
>
> You can use:
>
> > t(table(DF))
>V1
> V2   set_a set_b set_c
>  gene_1 1 0 1
>  gene_2 1 0 0
>  gene_3 1 1 1
>  gene_4 0 1 0
>  gene_5 0 1 0
>
>
> See ?table and ?t
>
> HTH,
>
> Marc Schwartz
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


Re: [R] How to make this binary hit matrix

2008-06-15 Thread Marc Schwartz

on 06/15/2008 12:46 PM ssls sddd wrote:

Hi all,

Basically I want to make a binary hit matrix.

For instance, if I have a file called 'pair.txt':

set_agene_1
set_agene_2
set_agene_3
set_bgene_3
set_bgene_4
set_bgene_5
set_cgene_1
set_cgene_3

And I want to convert it to a binary matrix as:

Rowsset_aset_bset_c
gene_1101
gene_2100
gene_3111
gene_4010
gene_5010

Can anyone suggest how to do this?

Thank you!

Alex


Presuming that your data is contained in a data frame called 'DF':

> DF
 V1 V2
1 set_a gene_1
2 set_a gene_2
3 set_a gene_3
4 set_b gene_3
5 set_b gene_4
6 set_b gene_5
7 set_c gene_1
8 set_c gene_3


You can use:

> t(table(DF))
V1
V2   set_a set_b set_c
  gene_1 1 0 1
  gene_2 1 0 0
  gene_3 1 1 1
  gene_4 0 1 0
  gene_5 0 1 0


See ?table and ?t

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
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.


[R] How to make this binary hit matrix

2008-06-15 Thread ssls sddd
Hi all,

Basically I want to make a binary hit matrix.

For instance, if I have a file called 'pair.txt':

set_agene_1
set_agene_2
set_agene_3
set_bgene_3
set_bgene_4
set_bgene_5
set_cgene_1
set_cgene_3

And I want to convert it to a binary matrix as:

Rowsset_aset_bset_c
gene_1101
gene_2100
gene_3111
gene_4010
gene_5010

Can anyone suggest how to do this?

Thank you!

Alex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] How to make this binary hit matrix

2008-06-15 Thread ssls sddd
Hi all,

Basically I want to make a binary hit matrix.

For instance, if I have a file called 'pair.txt':

set_agene_1
set_agene_2
set_agene_3
set_bgene_3
set_bgene_4
set_bgene_5
set_cgene_1
set_cgene_3

And I want to convert it to a binary matrix as:

Rowsset_aset_bset_c
gene_1101
gene_2100
gene_3111
gene_4010
gene_5010

Can anyone suggest how to do this?

Thank you!

Alex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.