filtering a dataframe of DE GO terms with a dataframe containing GO terms of interest
1
1
Entering edit mode
3.7 years ago
peter.berry5 ▴ 60

I have a dataframe containing a list of enriched GO terms resulting from a differential expression analysis. I want to filter out GO terms of interest by filtering with a second dataframe containing those GO terms I'm looking for.

Based on this post

https://community.rstudio.com/t/dplyr-filter-from-another-dataframe/7207

I wrote the following code

Extracted_GO <- filter(BP_1_5, GO_Accession_Number == GO_Search$GO_Accession_Number)   

which gives the following error

longer object length is not a multiple of shorter object length

and

str(BP_1_5)

gives

 tibble [5,325 x 5] (S3: tbl_df/tbl/data.frame)
 $ GO_Accession_Number: chr [1:5325] "GO:0000028" "GO:0000045" "GO:0000045" "GO:0000070" ...
 $ Biological.Process : chr [1:5325] "ribosomal small subunit assembly" "autophagosome assembly" "autophagosome assembly" "mitotic sister chromatid segregation" ...
 $ HGNC_Symbol        : chr [1:5325] "ERAL1" "UBQLN1" "STX12" "INCENP" ...
 $ Gene.name          : chr [1:5325] "Eral1" "Ubqln1" "Stx12" "Incenp" ...
 $ GO.domain          : chr [1:5325] "P" "P" "P" "P" ...  data.frame':  5325 obs. of  6 variables:

and

str(GO_Search)

gives

tibble [1,727 x 2] (S3: tbl_df/tbl/data.frame)
 $ GO_Accession_Number: chr [1:1727] "GO:0062201" "GO:0098610" "GO:0075003" "GO:0075002" ...
 $ Description        : chr [1:1727] "actin wave" "adhesion between unicellular organisms" "adhesion of symbiont appressorium to host" "adhesion of symbiont germination tube to host" ...

Given my two dataframes are of fixed length and can't be changed is there a way of achieving my goal?

GeneOntology • 1.1k views
ADD COMMENT
0
Entering edit mode

you can also do inner join of GO terms of interest with main data frame.

ADD REPLY
2
Entering edit mode
3.7 years ago
 filtered <- BP_1_5[BP_1_5$GO_Accession_Number %in% GO_Search$GO_Accession_Number, ]
ADD COMMENT
0
Entering edit mode

@rpolicastro thanks, that worked beautifully

ADD REPLY

Login before adding your answer.

Traffic: 1122 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6