This question already has an answer here:
I have a column with these values:
gene_id
ENSG00000228572.7_PAR_Y_AL954722.1
ENSG00000182378.13_PAR_Y_PLCXD1
ENSG00000223972.5_DDX11L1
ENSG00000243485.5_MIR1302-2HG
I am trying to separate these on the last occurence of underscore _
:
library(tidyverse)
expr <- expr %>%
separate(gene_id, c("gene_id", "gene_symbol"), sep = "\\_", extra = "merge") %>%
as.data.frame()
However, this results in:
gene_id gene_symbol
ENSG00000228572.7 PAR_Y_AL954722.1
ENSG00000182378.13 PAR_Y_PLCXD1
ENSG00000223972.5 DDX11L1
ENSG00000243485.5 MIR1302-2HG
Instead, I would like to separate on the last occurence of underscore so that the _PAR_Y piece remains in the gene_id column.