Wednesday, June 10, 2015

Select rows based on column values in R

To select rows that have in column 5 entry "neurological system process" use subset function:

head(id_merge)
  affy_mouse430_2    ensembl_gene_id external_gene_name      go_id
1      1445219_at ENSMUSG00000056959            Olfr315 GO:0005575
2      1445219_at ENSMUSG00000056959            Olfr315 GO:0008150
3      1445219_at ENSMUSG00000056959            Olfr315 GO:0050877
4      1445219_at ENSMUSG00000056959            Olfr315 GO:0007165
5      1445219_at ENSMUSG00000056959            Olfr315 GO:0005623
6      1445219_at ENSMUSG00000056959            Olfr315 GO:0005886
                    name_1006
1          cellular_component
2          biological_process
3 neurological system process
4         signal transduction
5                        cell
6             plasma membrane


newdata<-subset(id_merge,name_1006=="neurological system process")

head(newdata)
     affy_mouse430_2    ensembl_gene_id external_gene_name      go_id
3         1445219_at ENSMUSG00000056959            Olfr315 GO:0050877
417       1443936_at ENSMUSG00000047352            Olfr976 GO:0050877
1582      1420784_at ENSMUSG00000034115             Scn11a GO:0050877
3259      1417415_at ENSMUSG00000021609             Slc6a3 GO:0050877
4109      1448026_at ENSMUSG00000041235               Chd7 GO:0050877
4110      1437745_at ENSMUSG00000041235               Chd7 GO:0050877
                       name_1006
3    neurological system process
417  neurological system process
1582 neurological system process
3259 neurological system process
4109 neurological system process
4110 neurological system process

No comments:

Post a Comment