I have a txt file of transcripts ids (transcripts) and a dataframe (t2g) with 3 columns (transcripts ids, gene ids, gene symbols), they have the same length.
> head(transcripts)
V1
1 ENSMUST00000000266.8
2 ENSMUST00000000514.10
3 ENSMUST00000000834.3
4 ENSMUST00000001027.6
5 ENSMUST00000001166.13
6 ENSMUST00000001171.12
> head(t2g)
V1 V2 V3
1 ENSMUST00000001171.12 ENSMUSG00000102693.1 4933401J01Rik
2 ENSMUST00000001027.6 ENSMUSG00000064842.1 Gm26206
3 ENSMUST00000000834.3 ENSMUSG00000051951.5 Xkr4
4 ENSMUST00000000266.8 ENSMUSG00000051951.5 Xkr4
5 ENSMUST00000000514.10 ENSMUSG00000051951.5 Xkr4
6 ENSMUST00000001166.13 ENSMUSG00000102851.1 Gm18956
I'd need the data frame ordered as the txt file, that cannot be sorted.
I started in R by renaming dataframe rownames as the transcripts in the txt file
> vector <- transcripts[,1]
> rownames(t2g) <- vector
> head(t2g)
V1 V2 V3
ENSMUST00000000266.8 ENSMUST00000001171.12 ENSMUSG00000102693.1 4933401J01Rik
ENSMUST00000000514.10 ENSMUST00000001027.6 ENSMUSG00000064842.1 Gm26206
ENSMUST00000000834.3 ENSMUST00000000834.3 ENSMUSG00000051951.5 Xkr4
ENSMUST00000001027.6 ENSMUST00000000266.8 ENSMUSG00000051951.5 Xkr4
ENSMUST00000001166.13 ENSMUST00000000514.10 ENSMUSG00000051951.5 Xkr4
ENSMUST00000001171.12 ENSMUST00000001166.13 ENSMUSG00000102851.1 Gm18956
But I don't know how to move forward from here. Any idea? Thank you