Answers.Body: <p>Assuming the datasets are arranged in matrices with one gene per row, this can be done by intersecting row names:</p>
  <pre><code>commonNames &lt;- sort(intersect(rownames(data1.mat), rownames(data2.mat)));
  filtered.data1.mat &lt;- data1.mat[commonNames,];
  filtered.data2.mat &lt;- data2.mat[commonNames,];
  </code></pre>
  <p>It would be helpful if you could provide more information about your datasets. There are many other ways to do this, and the way that works best for you will depend on your particular situation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-10T23:07:06.367Z
Answers.LastActivityDate: 2022-02-10T23:07:06.367Z
Answers.UserDisplayName: gringer
Body: <p>I have downloaded two datasets, and I am trying to remove the genes they do not share in common.  Is there a biocmanager package with a function that can compare their gene ids, match them and reorder them?</p>
  
Tags: <rna-seq><bioconductor>
Title: Best way to match genes in two RNA-seq count matrices from two geo accessions
ThreadText: # Best way to match genes in two RNA-seq count matrices from two geo accessions
  
  (Asked by: username_0 on 2022-02-10)
  
  I have downloaded two datasets, and I am trying to remove the genes they do not share in common. Is there a biocmanager package with a function that can compare their gene ids, match them and reorder them?
  
  **Tags:** rna-seq, bioconductor
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-02-10. Score: 3 | Accepted answer
  
  Assuming the datasets are arranged in matrices with one gene per row, this can be done by intersecting row names:
  
  ```
  commonNames <- sort(intersect(rownames(data1.mat), rownames(data2.mat)));
  filtered.data1.mat <- data1.mat[commonNames,];
  filtered.data2.mat <- data2.mat[commonNames,];
  
  ```
  
  It would be helpful if you could provide more information about your datasets. There are many other ways to do this, and the way that works best for you will depend on your particular situation.
  
  
  ---
  
  