Question: Sorting Enhancers According To Transcription Factors In R

0

Diana •

**770**wrote:Hi everyone,

I have a file like this with enhancers from 4 different genes with their TFs:

```
gene1 gene2 gene3 gene4 TF
gene1Enhancer1 gene2Enhancer1 gene3Enhancer2 Gene4Enhancer1 V$GSH1
gene1Enhancer2 gene2Enhancer2 gene3Enhancer3 Gene4Enhancer2 V$GSH1
gene1Enhancer3 gene2Enhancer3 gene3Enhancer4 Gene4Enhancer3 V$GSH1
gene1Enhancer1 gene2Enhancer1 gene3Enhancer2 Gene4Enhancer1 V$REF
gene1Enhancer3 gene2Enhancer3 gene3Enhancer4 Gene4Enhancer3 V$AB
gene1Enhancer6 gene2Enhancer6 gene3Enhancer7 Gene4Enhancer6 V$LEF1
```

I want the output to be sorted such that the first 4 columns are sorted so that same enhancers from 4 columns are put together with their transcription factors so it should look like this:

```
gene1 gene2 gene3 gene4 TF
gene1Enhancer1 gene2Enhancer1 gene3Enhancer2 Gene4Enhancer1 V$GSH1
gene1Enhancer1 gene2Enhancer1 gene3Enhancer2 Gene4Enhancer1 V$REF
gene1Enhancer3 gene2Enhancer3 gene3Enhancer4 Gene4Enhancer3 V$GSH1
gene1Enhancer3 gene2Enhancer3 gene3Enhancer4 Gene4Enhancer3 V$AB
gene1Enhancer2 gene2Enhancer2 gene3Enhancer3 Gene4Enhancer2 V$GSH1
gene1Enhancer6 gene2Enhancer6 gene3Enhancer7 Gene4Enhancer6 V$LEF1
```

I was thinking of using aggregate function in R but that didn't help. Any advice?

Thanks a lot!!!

ADD COMMENT
• link
•
modified 6.0 years ago
by
Anthony Mathelier •

**870**• written 6.0 years ago by Diana •**770**