I am quite new to R and I am working with a large genomic matrix and I am preparing heatmaps using certain genes. I subset a matrix containing the genes of my interest.
I tried to do it this way:
vector_infertility_genes <- infertility$V1
matrix_for_heatmap_infertility <- subset(my_genomic_matrix, vector_infertility_genes)
But this gives me just the first x number of rows from my matrix where x is the number of characters I have in vector_infertility genes.
So far I was able to dodge this problem by doing something like this:
matrix_for_heatmap_infertility <- my_genomic_matrix[c('EPHX1', 'HSPB1', 'CLU', 'GAMT',  'PICK1', 'NR3C1',
                                                                 'SIRT1', 'NPAS2', 'SPRY4', 'MAP3K1', 'SOS1', 'SALL4', 
                                                                 'GRIP1', 'PUM2', 'SOX9', 'RIPK4', 'CHD7',  'BCOR', 
                                                                 'CCNB1', 'NFE2L2', 'CHD2', 'CYP1B1', 'MDM2', 'CREBBP',
                                                                 'ICK', 'ZFY', 'SIN3A', 'GATA4'), ]
If I will have to manually type the rowname of every gene to subset like this again I will kill myself. Is there an easier way to do this with creating a character vector and using it to subset?
 
    