text: user1369: I have a gene expression data (read counts) table with many samples. Showing some of them below:
  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
  
  I want to select top 100 genes with reverse sort of variance. How to do that?
  
  user77: I assume by "reverse sort of variance" you mean "highest variance". Assuming you made a matrix out of that (set the row names to the first column and then remove it) and called it m:
  sel = order(apply(m, 1, var), decreasing=TRUE)[1:100]
  
  sel then contains the indices into your matrix (or the original dataframe).
  BTW, I hope you're not filtering by variance before performing differential expression. That would be incredibly incorrect. Doing this sort of filtering for performing PCA or something like that can be useful, though you should really be using normalized counts (or a transformation of them).
  
original_text: 1369: <p>I have a gene expression data (read counts) table with many samples. Showing some of them below:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I want to select top 100 genes with reverse sort of variance. How to do that?</p>
   77: <p>I assume by "reverse sort of variance" you mean "highest variance". Assuming you made a matrix out of that (set the row names to the first column and then remove it) and called it <code>m</code>:</p>
  
  <pre><code>sel = order(apply(m, 1, var), decreasing=TRUE)[1:100]
  </code></pre>
  
  <p><code>sel</code> then contains the indices into your matrix (or the original dataframe).</p>
  
  <p>BTW, I hope you're not filtering by variance before performing differential expression. That would be incredibly incorrect. Doing this sort of filtering for performing PCA or something like that can be useful, though you should really be using normalized counts (or a transformation of them).</p>
  