lets say I have the following dataframe:
Ensembl_ID A B C D E F G
ENSG00000236601.2 0 0 0 1 0 0 1
ENSG00000237094.12 2 187 442 109 88 144 486
ENSG00000269732.1 0 0 0 0 0 0 0
ENSG00000284733.1 0 0 0 0 0 0 0
ENSG00000233653.3 0 0 0 0 0 0 0
ENSG00000250575.1 1 11 17 5 5 8 17
ENSG00000278757.1 0 0 2 0 1 0 7
ENSG00000230021.9 0 25 30 27 9 8 11
ENSG00000235146.2 0 0 0 0 0 0 0
ENSG00000225972.1 0 7 3016 11 5 14 5
ENSG00000225630.1 1 113 194 76 91 47 94
ENSG00000237973.1 25 1037 9767 1160 886 1321 5220
What I would like to do is only keep the ~top 50 highly variable genes:
I thought it would be like this: dif_genes <- order(apply(df, 1, var), decreasing=TRUE)[1:50]
but that leaves me with a vector containing variances without genes.