How to convert a binary matrix of gene presence or absence into a fasta sequence I have a binary matrix of gene presence or absence which looks like: [roary output]

Gene    sample1 sample2 sample3 sample4
fliI        1       1       1        1
patB_1      1       1       1        1
pgpA        1       1       1        1
osmB        1       1       1        1
cspA        1       0       1        1


How can I convert to fasta so it looks like and technically aligned:  

&gt;sample1
11111
&gt;sample2
11110


Is it possible to do this in R?
It's not a fasta file, but:

&gt; m
       sample1 sample2 sample3 sample4
fliI         1       1       1       1
patB_1       1       1       1       1
pgpA         1       1       1       1
osmB         1       1       1       1
cspA         1       0       1       1
&gt; # Collapse to labeled strings
&gt; blah = apply(m, 2, function(x) paste(x, collapse=''))
&gt; blah
sample1 sample2 sample3 sample4 
"11111" "11110" "11111" "11111" 
&gt; # Write that to a file with the appropriate format
&gt; cat(paste(mapply(function(x, y) sprintf("&gt;%s\n%s\n", x, y), names(blah), blah), collapse=""), file="some file.fa")


Make sure to change some file.fa. I have no idea why you would want to do all of this, but this will give you the output you want:

$ cat blah.txt 
&gt;sample1
11111
&gt;sample2
11110
&gt;sample3
11111
&gt;sample4
11111