Gene-filterin In R

1

Hi All,

I am trying to filter out genes from my gene-fusion excel file. I want to remove any gene which is getting repeated more than 10 times in the column. I am doing this in R.

Any suggestions??

Thanks in advance.


R

• 28 views

Assuming you have your data stored in a data.frame named df, you could use dplyr::group_by and dplyr::n to count the number of instances of each value in the target column (e.g., a), and add these as a new column (b). Then you can filter the data.frame using this new column.

library(magrittr)
library(dplyr)

df %>% 
  group_by(a) %>% 
  mutate(b = n()) %>% 
  ungroup() %>% 
  filter(b <= 10) %>% 
  select(-b)
`


Login
before adding your answer.



Source link